Skip to content

Commit 8ad0ab0

Browse files
authored
Merge pull request #95 from JuliaImages/vs/docs-doctests
docs: doctests, versioning merge, generated wrapped-functions list
2 parents 307a023 + 5336ff5 commit 8ad0ab0

6 files changed

Lines changed: 79 additions & 24 deletions

File tree

β€Ž.gitignoreβ€Ž

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ deps/src/
1616
# Build artifacts for creating documentation generated by the Documenter package
1717
docs/build/
1818
docs/site/
19+
# generated from gen/funclist.csv by docs/make.jl
20+
docs/src/wrapped_functions.md
1921

2022
# File generated by Pkg, the package manager, based on a corresponding Project.toml
2123
# It records a fixed state of all packages used by the project. As such, it should not be

β€ŽProject.tomlβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "OpenCV"
22
uuid = "f878e3a2-a245-4720-8660-60795d644f2a"
33
authors = ["Archit Rungta <architrungta120@gmail.com>"]
4-
version = "4.10.0"
4+
version = "4.9.0"
55

66
[deps]
77
CxxWrap = "1f15a43c-97ca-5a2a-ae31-89f07a497df4"

β€Ždocs/make.jlβ€Ž

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,48 @@ using Documenter
44

55
DocMeta.setdocmeta!(OpenCV, :DocTestSetup, :(using OpenCV); recursive=true)
66

7+
# Generate the "Wrapped functions" page from gen/funclist.csv at build time, so the
8+
# list of wrapped OpenCV APIs in the docs stays in lockstep with the bindings.
9+
function generate_wrapped_functions_page()
10+
csv = joinpath(@__DIR__, "..", "gen", "funclist.csv")
11+
out = joinpath(@__DIR__, "src", "wrapped_functions.md")
12+
entries = String[]
13+
for line in eachline(csv)
14+
s = strip(line)
15+
(isempty(s) || startswith(s, "#")) && continue
16+
startswith(s, "cv.") && push!(entries, String(s[4:end]))
17+
end
18+
free = sort(unique(filter(e -> !occursin('.', e), entries)))
19+
groups = Dict{String, Vector{String}}()
20+
for e in filter(e -> occursin('.', e), entries)
21+
cls, rest = split(e, '.'; limit = 2)
22+
push!(get!(groups, String(cls), String[]), String(rest))
23+
end
24+
for (k, v) in groups
25+
groups[k] = sort(unique(v))
26+
end
27+
nfuncs = length(free) + sum(length, values(groups); init = 0)
28+
open(out, "w") do io
29+
println(io, "# Wrapped functions\n")
30+
println(io, "!!! note")
31+
println(io, " This page is generated from [`gen/funclist.csv`](https://github.com/JuliaImages/OpenCV.jl/blob/master/gen/funclist.csv) at build time β€” the authoritative list of every OpenCV function exposed by the bindings ($nfuncs functions).\n")
32+
println(io, "Names follow the `cv::` β†’ `OpenCV.` convention (see [Core concepts](@ref)): " *
33+
"free functions map directly (`cv.add` β†’ `OpenCV.add`); class *static* methods " *
34+
"flatten with `_` (`cv.ORB.create` β†’ `OpenCV.ORB_create`); and *instance* methods " *
35+
"dispatch on the object (`cv.FileStorage.open` β†’ `OpenCV.open(fs, …)`). Everything is " *
36+
"reached through the `OpenCV.` prefix.\n")
37+
println(io, "## Free functions\n")
38+
println(io, join(("`OpenCV.$f`" for f in free), " Β· "), "\n")
39+
println(io, "## Classes and submodules\n")
40+
for cls in sort(collect(keys(groups)))
41+
println(io, "### `$cls`\n")
42+
println(io, join(("`cv.$cls.$m`" for m in sort(groups[cls])), " Β· "), "\n")
43+
end
44+
end
45+
return out
46+
end
47+
generate_wrapped_functions_page()
48+
749
makedocs(;
850
modules=[OpenCV],
951
sitename="OpenCV.jl",
@@ -13,6 +55,7 @@ makedocs(;
1355
"Core concepts" => "core_concepts.md",
1456
"Reading and Writing of Images" => "Getting started with Images.md",
1557
"API reference" => "api.md",
58+
"Wrapped functions" => "wrapped_functions.md",
1659
]
1760
)
1861

β€Ždocs/src/api.mdβ€Ž

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@ The thousands of *wrapped* OpenCV functions (`imread`, `cvtColor`, `GaussianBlur
1515
`ORB_create`, …) keep their C++ names with the `cv::` namespace stripped and are
1616
reached through the `OpenCV.` prefix β€” e.g. `cv::cvtColor` is `OpenCV.cvtColor` and
1717
the flag `cv::IMREAD_GRAYSCALE` is `OpenCV.IMREAD_GRAYSCALE`. See
18-
[Core concepts](@ref) for the naming and data conventions, and the generated
19-
[`gen/funclist.csv`](https://github.com/JuliaImages/OpenCV.jl/blob/master/gen/funclist.csv)
20-
for the complete list of wrapped methods.
18+
[Core concepts](@ref) for the naming and data conventions, and
19+
[Wrapped functions](@ref) for the complete generated list.
2120

2221
## Image and array types
2322

β€Ždocs/src/core_concepts.mdβ€Ž

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,16 @@ Any `AbstractArray{T,3}` with `T` one of the supported element types is accepted
5050
wherever an image is expected (this Union is `OpenCV.InputArray`), so you can pass a
5151
plain Julia array directly and wrap one as a `Mat` with `OpenCV.Mat(A)`:
5252

53-
```julia
54-
A = rand(UInt8, 3, 640, 480) # (channels, cols, rows)
55-
img = OpenCV.Mat(A) # zero-copy view; shares memory with A
56-
gray = OpenCV.cvtColor(A, OpenCV.COLOR_BGR2GRAY) # plain arrays work too
53+
```jldoctest
54+
julia> using OpenCV
55+
56+
julia> A = rand(UInt8, 3, 640, 480); # (channels, cols, rows)
57+
58+
julia> size(OpenCV.Mat(A)) # zero-copy view; shares memory with A
59+
(3, 640, 480)
60+
61+
julia> size(OpenCV.cvtColor(A, OpenCV.COLOR_BGR2GRAY)) # plain arrays work too
62+
(1, 640, 480)
5763
```
5864

5965
The supported element types are `UInt8`, `Int8`, `UInt16`, `Int16`, `Int32`,

β€Ždocs/src/index.mdβ€Ž

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,30 @@ extraction, calibration, and much more β€” backed by the compiled library throug
1818
This installs the package and the precompiled OpenCV binaries; no system OpenCV is
1919
required.
2020

21-
## OpenCV version
21+
## Versioning
2222

23-
This release wraps **OpenCV 4.13.0**, pinned in `gen/OPENCV_VERSION` and provided at
24-
runtime by `OpenCV_jll` 4.13.x. Query the version and build configuration from Julia:
23+
```@eval
24+
using Markdown, OpenCV
25+
v = OpenCV.getVersionString()
26+
Markdown.parse(
27+
"This release wraps **OpenCV $v**, pinned in " *
28+
"[`gen/OPENCV_VERSION`](https://github.com/JuliaImages/OpenCV.jl/blob/master/gen/OPENCV_VERSION) " *
29+
"and provided at runtime by `OpenCV_jll`. Query it from Julia with " *
30+
"`OpenCV.getVersionString()` (or `OpenCV.getBuildInformation()` for the full " *
31+
"build configuration):"
32+
)
33+
```
2534

26-
```julia
35+
```@repl
2736
using OpenCV
28-
OpenCV.getVersionString() # "4.13.0"
29-
OpenCV.getBuildInformation() # full build info string
37+
OpenCV.getVersionString()
3038
```
3139

40+
The package version itself tracks the wrapped OpenCV release. Within a given OpenCV
41+
major/minor line, breaking changes to the *Julia* API are signalled by bumping the
42+
package's minor version and called out in release notes β€” they do not require bumping
43+
the OpenCV major.
44+
3245
## Quick start
3346

3447
```julia
@@ -63,23 +76,15 @@ mosaic(img_orig, img_back; nrow=1)
6376
scalars, and Julia-array interop.
6477
- [Reading and Writing of Images](@ref) β€” `imread`/`imwrite` and the FileIO
6578
`load`/`save` interface, with flags and display.
66-
- [API reference](@ref) β€” the hand-written types and I/O helpers. The full list of
67-
wrapped OpenCV functions lives in
68-
[`gen/funclist.csv`](https://github.com/JuliaImages/OpenCV.jl/blob/master/gen/funclist.csv).
79+
- [API reference](@ref) β€” the hand-written types and I/O helpers.
80+
- [Wrapped functions](@ref) β€” the complete generated list of wrapped OpenCV functions.
6981

7082
If you are new to OpenCV, the upstream
7183
[OpenCV tutorials](https://docs.opencv.org/4.x/d9/df8/tutorial_root.html) are the best
7284
starting point. Function and argument names mirror the C++/Python API, so most
7385
tutorials translate directly β€” the Julia-specific pieces are the `Mat`/`Vec` types and
7486
the array/image interop, all covered in [Core concepts](@ref).
7587

76-
## Versioning
77-
78-
The package version tracks the wrapped OpenCV release (currently `4.13.x` for OpenCV
79-
4.13.0). Within a given OpenCV major/minor line, breaking changes to the *Julia* API
80-
are signalled by bumping the package's minor version and called out in release notes β€”
81-
they do not require bumping the OpenCV major.
82-
8388
## Contributing
8489

8590
Issues and pull requests are welcome at the

0 commit comments

Comments
Β (0)