-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathapi_reference.jl
More file actions
186 lines (176 loc) · 6.23 KB
/
api_reference.jl
File metadata and controls
186 lines (176 loc) · 6.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
"""
generate_api_reference(src_dir::String)
Generate the API reference documentation for CTBase.
Returns the list of pages.
"""
function generate_api_reference(src_dir::String)
# Helper to build absolute paths
src(files...) = [abspath(joinpath(src_dir, f)) for f in files]
ext_dir = abspath(joinpath(src_dir, "..", "ext"))
ext(files...) = [abspath(joinpath(ext_dir, f)) for f in files]
# Symbols to exclude (must match make.jl if shared, or be defined here)
EXCLUDE_SYMBOLS = Symbol[:include, :eval]
pages = [
CTBase.automatic_reference_documentation(;
subdirectory="api",
primary_modules=[CTBase.Core => src(joinpath("Core", "Core.jl"))],
exclude=EXCLUDE_SYMBOLS,
public=true,
private=true,
title="Core",
title_in_menu="Core",
filename="core",
),
CTBase.automatic_reference_documentation(;
subdirectory="api",
primary_modules=[
CTBase.Descriptions => src(
joinpath("Descriptions", "Descriptions.jl"),
joinpath("Descriptions", "types.jl"),
joinpath("Descriptions", "similarity.jl"),
joinpath("Descriptions", "display.jl"),
joinpath("Descriptions", "catalog.jl"),
joinpath("Descriptions", "complete.jl"),
joinpath("Descriptions", "remove.jl"),
),
],
exclude=EXCLUDE_SYMBOLS,
public=true,
private=true,
title="Descriptions",
title_in_menu="Descriptions",
filename="descriptions",
),
CTBase.automatic_reference_documentation(;
subdirectory="api",
primary_modules=[
CTBase.Exceptions => src(
joinpath("Exceptions", "Exceptions.jl"),
joinpath("Exceptions", "types.jl"),
joinpath("Exceptions", "display.jl"),
),
],
exclude=EXCLUDE_SYMBOLS,
public=true,
private=true,
title="Exceptions",
title_in_menu="Exceptions",
filename="exceptions",
),
CTBase.automatic_reference_documentation(;
subdirectory="api",
primary_modules=[CTBase.Unicode => src(joinpath("Unicode", "Unicode.jl"))],
exclude=EXCLUDE_SYMBOLS,
public=true,
private=false, # there is no private API
title="Unicode",
title_in_menu="Unicode",
filename="unicode",
),
CTBase.automatic_reference_documentation(;
subdirectory="api",
primary_modules=[
CTBase.Extensions => src(joinpath("Extensions", "Extensions.jl"))
],
exclude=EXCLUDE_SYMBOLS,
public=true,
private=true,
title="Extensions",
title_in_menu="Extensions",
filename="extensions",
),
]
DocumenterReference = Base.get_extension(CTBase, :DocumenterReference)
if !isnothing(DocumenterReference)
EXCLUDE_DOCREF = vcat(
EXCLUDE_SYMBOLS,
Symbol[
:DOCTYPE_ABSTRACT_TYPE,
:DOCTYPE_CONSTANT,
:DOCTYPE_FUNCTION,
:DOCTYPE_MACRO,
:DOCTYPE_MODULE,
:DOCTYPE_STRUCT,
],
)
push!(
pages,
CTBase.automatic_reference_documentation(;
subdirectory="api",
primary_modules=[DocumenterReference => ext("DocumenterReference.jl")],
external_modules_to_document=[CTBase],
exclude=EXCLUDE_DOCREF,
public=false, # there is no public API
private=true,
title="DocumenterReference",
title_in_menu="DocumenterReference",
filename="documenter_reference",
),
)
end
CoveragePostprocessing = Base.get_extension(CTBase, :CoveragePostprocessing)
if !isnothing(CoveragePostprocessing)
push!(
pages,
CTBase.automatic_reference_documentation(;
subdirectory="api",
primary_modules=[
CoveragePostprocessing => ext("CoveragePostprocessing.jl")
],
external_modules_to_document=[CTBase],
exclude=EXCLUDE_SYMBOLS,
public=false, # there is no public API
private=true,
title="CoveragePostprocessing",
title_in_menu="CoveragePostprocessing",
filename="coverage_postprocessing",
),
)
end
TestRunner = Base.get_extension(CTBase, :TestRunner)
if !isnothing(TestRunner)
push!(
pages,
CTBase.automatic_reference_documentation(;
subdirectory="api",
primary_modules=[TestRunner => ext("TestRunner.jl")],
external_modules_to_document=[CTBase],
exclude=EXCLUDE_SYMBOLS,
public=false, # there is no public API
private=true,
title="TestRunner",
title_in_menu="TestRunner",
filename="test_runner",
),
)
end
return pages
end
"""
with_api_reference(f::Function, src_dir::String)
Generates the API reference, executes `f(pages)`, and cleans up generated files.
"""
function with_api_reference(f::Function, src_dir::String)
pages = generate_api_reference(src_dir)
try
f(pages)
finally
docs_src = abspath(joinpath(@__DIR__, "src"))
_cleanup_pages(docs_src, pages)
end
end
function _cleanup_pages(docs_src::String, pages)
for p in pages
val = last(p)
if val isa AbstractString
fname = endswith(val, ".md") ? val : val * ".md"
full_path = joinpath(docs_src, fname)
if isfile(full_path)
rm(full_path)
println("Removed temporary API doc: $full_path")
end
elseif val isa AbstractVector
_cleanup_pages(docs_src, val)
end
end
end