Skip to content

Commit

Permalink
Add support for Doxygen's @deprecated command (#460)
Browse files Browse the repository at this point in the history
Also add a simple test for the documentation parser.
  • Loading branch information
JamesWrigley committed Dec 29, 2023
1 parent c42c221 commit bdb93d8
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/generator/documentation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ function format_block(x::Clang.BlockCommand, options)
name in ["li", "arg"] && return ["* $content"]
name in ["brief", "details"] && return [content]
name in ["note", "warning"] && return ["!!! $name", "", " $content"]
name in ["deprecated"] && return ["!!! compat \"Deprecated\"", "", " $content"]
["\\$name$args $content"]
end

Expand Down
26 changes: 26 additions & 0 deletions test/generators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -210,3 +210,29 @@ end
ctx = create_context([joinpath(@__DIR__, "include/static.h")], get_default_args(), options)
@test_logs (:info, "Done!") match_mode = :any build!(ctx)
end

# Test the documentation parser
@testset "Documentation" begin
mktemp() do path, io
# Generate the bindings
options = Dict("general" => Dict{String, Any}("output_file_path" => path,
"extract_c_comment_style" => "doxygen"))
ctx = create_context([joinpath(@__DIR__, "include/documentation.h")], get_default_args(), options)
build!(ctx)

# Load into a temporary module to avoid polluting the global namespace
m = Module()
Base.include(m, path)

# Do some sanity checks on the docstring
docstring = string(@doc m.doxygen_func)
docstring_has = occursin(docstring)
@test docstring_has("!!! compat \"Deprecated\"")
@test docstring_has("### Parameters")
@test docstring_has(" * `foo`: A parameter")
@test docstring_has("### Returns")
@test docstring_has("Whatever I want")
@test docstring_has("### See also")
@test docstring_has("quux()")
end
end
14 changes: 14 additions & 0 deletions test/include/documentation.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* @brief Dummy function.
*
* @param foo A parameter.
*
* @return Whatever I want.
*
* @see quux()
*
* @deprecated This function is evil.
*/
void doxygen_func(int foo) {
return 0;
}

0 comments on commit bdb93d8

Please sign in to comment.