Skip to content

Commit c72c117

Browse files
committed
Add docs
1 parent c3807f0 commit c72c117

18 files changed

+11633
-29
lines changed

docs/make.jl

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ makedocs(;
1111
prettyurls=get(ENV, "CI", "false") == "true",
1212
canonical="https://github.com/JuliaServices/LibAwsCommon.jl",
1313
assets=String[],
14+
size_threshold=2_000_000, # 2 MB, we generate about 1 MB page
15+
size_threshold_warn=2_000_000,
1416
),
1517
pages=["Home" => "index.md"],
1618
)

gen/Manifest.toml

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
julia_version = "1.10.2"
44
manifest_format = "2.0"
5-
project_hash = "17529965341e648e57dcbc863dd11933859fd679"
5+
project_hash = "31f1f96877f58f98ee3e7f6c9d85e9a0481cef80"
66

77
[[deps.ArgTools]]
88
uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f"
@@ -21,9 +21,9 @@ version = "0.5.0"
2121

2222
[[deps.Clang]]
2323
deps = ["CEnum", "Clang_jll", "Downloads", "Pkg", "TOML"]
24-
git-tree-sha1 = "846054622cb22aa63b5d51b5d84ec04b42d4d587"
24+
git-tree-sha1 = "cc5bcd0b7a373e59a0c4d754276c074733471c98"
2525
uuid = "40e3b903-d033-50b4-a0cc-940c62c95e31"
26-
version = "0.17.8"
26+
version = "0.18.2"
2727

2828
[[deps.Clang_jll]]
2929
deps = ["Artifacts", "JLLWrappers", "Libdl", "TOML", "Zlib_jll", "libLLVM_jll"]
@@ -57,9 +57,9 @@ version = "1.3.1"
5757

5858
[[deps.Git_jll]]
5959
deps = ["Artifacts", "Expat_jll", "JLLWrappers", "LibCURL_jll", "Libdl", "Libiconv_jll", "OpenSSL_jll", "PCRE2_jll", "Zlib_jll"]
60-
git-tree-sha1 = "12945451c5d0e2d0dca0724c3a8d6448b46bbdf9"
60+
git-tree-sha1 = "d18fb8a1f3609361ebda9bf029b60fd0f120c809"
6161
uuid = "f8c6e375-362e-5223-8a59-34ff63f689eb"
62-
version = "2.44.0+1"
62+
version = "2.44.0+2"
6363

6464
[[deps.HistoricalStdlibVersions]]
6565
git-tree-sha1 = "c8b04a26eaa706b4da6968dfc27ae2d030547cba"

gen/Project.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ JLLPrefixes = "afc68a34-7891-4c5a-9da1-1c62935e7b0d"
44
aws_c_common_jll = "73048d1d-b8c4-5092-a58d-866c5e8d1e50"
55

66
[compat]
7-
Clang = "0.17"
7+
Clang = "0.18.2"
88
JLLPrefixes = "0.3"
99
aws_c_common_jll = "=0.9.14"

gen/generator.jl

+59-20
Original file line numberDiff line numberDiff line change
@@ -5,44 +5,83 @@ import aws_c_common_jll
55

66
cd(@__DIR__)
77

8-
function remove_itt_symbols!(dag::ExprDAG)
9-
for i in eachindex(dag.nodes)
10-
node = dag.nodes[i]
11-
for expr in get_exprs(node)
12-
node_name = if expr.head == :function
13-
if expr.args[1].args[1] isa Expr # function is Module.name instead of just name
14-
expr.args[1].args[1].args[2]
15-
else
16-
expr.args[1].args[1]
17-
end
18-
elseif expr.head == :struct
19-
if expr.args[2] isa Expr # struct has type parameter
20-
expr.args[2].args[1]
21-
else
22-
expr.args[2]
23-
end
24-
elseif expr.head == :const
8+
function node_is_ignored(node)
9+
for expr in get_exprs(node)
10+
node_name = if expr.head == :function
11+
if expr.args[1].args[1] isa Expr # function is Module.name instead of just name
12+
expr.args[1].args[1].args[2]
13+
else
2514
expr.args[1].args[1]
2615
end
27-
# remove the node by renaming it to IGNORED, which we include in the generator's ignorelist
28-
if contains(lowercase(string(node_name)), "itt")
29-
dag.nodes[i] = ExprNode(:IGNORED, node.type, node.cursor, node.exprs, node.premature_exprs, node.adj)
16+
elseif expr.head == :struct
17+
if expr.args[2] isa Expr # struct has type parameter
18+
expr.args[2].args[1]
19+
else
20+
expr.args[2]
3021
end
22+
elseif expr.head == :const
23+
expr.args[1].args[1]
24+
end
25+
return contains(lowercase(string(node_name)), "itt")
26+
end
27+
return false
28+
end
29+
30+
function remove_itt_symbols!(dag::ExprDAG)
31+
for i in eachindex(dag.nodes)
32+
# remove the node by renaming it to IGNORED, which we include in the generator's ignorelist
33+
node = dag.nodes[i]
34+
if node_is_ignored(node)
35+
dag.nodes[i] = ExprNode(:IGNORED, node.type, node.cursor, node.exprs, node.premature_exprs, node.adj)
3136
end
3237
end
3338
return nothing
3439
end
3540

41+
const refs_to_remove = ("AWS_CONTAINER_OF", "AWS_STATIC_STRING_FROM_LITERAL",)
42+
43+
# This is called if the docs generated from the extract_c_comment_style method did not generate any lines.
44+
# We need to generate at least some docs so that cross-references work with Documenter.jl.
45+
function get_docs(node, docs)
46+
# The macro node types (except for MacroDefault) seem to not generate code, but they will still emit docs and then
47+
# you end up with docs stacked on top of each other, which is a Julia LoadError.
48+
if node.type isa Generators.AbstractMacroNodeType && !(node.type isa Generators.MacroDefault)
49+
return String[]
50+
end
51+
52+
# don't generate empty docs because it makes Documenter.jl mad
53+
if isempty(docs)
54+
return ["Documentation not found."]
55+
end
56+
57+
# remove references to things which don't exist because it causes Documenter.jl's cross_references check to fail
58+
for ref in refs_to_remove
59+
for doci in eachindex(docs)
60+
docs[doci] = replace(docs[doci], "[`$ref`](@ref)" => "`$ref`")
61+
end
62+
end
63+
64+
# fix other random stuff
65+
for doci in eachindex(docs)
66+
# fix some code that gets bogus references inserted
67+
docs[doci] = replace(docs[doci], "for (struct [`aws_hash_iter`](@ref) iter = [`aws_hash_iter_begin`](@ref)(&map); ![`aws_hash_iter_done`](@ref)(&iter); [`aws_hash_iter_next`](@ref)(&iter)) { const key\\_type key = *(const key\\_type *)iter.element.key; value\\_type value = *(value\\_type *)iter.element.value; // etc. }" => "`for (struct aws_hash_iter iter = aws_hash_iter_begin(&map); !aws_hash_iter_done(&iter); aws_hash_iter_next(&iter)) { const key\\_type key = *(const key\\_type *)iter.element.key; value\\_type value = *(value\\_type *)iter.element.value; // etc. }`")
68+
end
69+
70+
return docs
71+
end
72+
3673
for target in JLLEnvs.JLL_ENV_TRIPLES
3774
if target == "i686-w64-mingw32"
3875
# aws_c_common_jll does not support i686 windows https://github.com/JuliaPackaging/Yggdrasil/blob/bbab3a916ae5543902b025a4a873cf9ee4a7de68/A/aws_c_common/build_tarballs.jl#L48-L49
3976
continue
4077
end
4178
options = load_options(joinpath(@__DIR__, "generator.toml"))
4279
options["general"]["output_file_path"] = joinpath(@__DIR__, "..", "lib", "$target.jl")
80+
options["general"]["callback_documentation"] = get_docs
4381

4482
header_dirs = []
4583
args = get_default_args(target)
84+
push!(args, "-fparse-all-comments")
4685
inc = JLLEnvs.get_pkg_include_dir(aws_c_common_jll, target)
4786
push!(args, "-I$inc")
4887
push!(header_dirs, inc)

0 commit comments

Comments
 (0)