-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathapi_reference.jl
More file actions
164 lines (152 loc) · 7.36 KB
/
Copy pathapi_reference.jl
File metadata and controls
164 lines (152 loc) · 7.36 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
"""
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)
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]
EXCLUDE_SYMBOLS = Symbol[:include, :eval]
EXCLUDE_INTERNALS = vcat(EXCLUDE_SYMBOLS, Symbol[
:DOCTYPE_ABSTRACT_TYPE, :DOCTYPE_CONSTANT, :DOCTYPE_FUNCTION,
:DOCTYPE_MACRO, :DOCTYPE_MODULE, :DOCTYPE_STRUCT,
])
# ── Public API: one flat page per module ──────────────────────────────────
modules_config = [
(mod=CTBase.Core, title="Core", filename="core", files=src(
joinpath("Core", "Core.jl"), joinpath("Core", "default.jl"),
joinpath("Core", "types.jl"), joinpath("Core", "matrix_utils.jl"),
joinpath("Core", "function_utils.jl"), joinpath("Core", "macros.jl"),
)),
(mod=CTBase.Descriptions, title="Descriptions", filename="descriptions", files=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"),
)),
(mod=CTBase.DevTools, title="DevTools", filename="devtools", files=src(
joinpath("DevTools", "DevTools.jl"), joinpath("DevTools", "coverage_postprocessing.jl"),
joinpath("DevTools", "documenter_reference.jl"), joinpath("DevTools", "test_runner.jl"),
)),
(mod=CTBase.Exceptions, title="Exceptions", filename="exceptions", files=src(
joinpath("Exceptions", "Exceptions.jl"), joinpath("Exceptions", "types.jl"),
joinpath("Exceptions", "display.jl"),
)),
(mod=CTBase.Interpolation, title="Interpolation", filename="interpolation", files=src(
joinpath("Interpolation", "Interpolation.jl"), joinpath("Interpolation", "types.jl"),
joinpath("Interpolation", "ctinterpolate.jl"), joinpath("Interpolation", "display.jl"),
)),
(mod=CTBase.Options, title="Options", filename="options", files=src(
joinpath("Options", "Options.jl"), joinpath("Options", "not_provided.jl"),
joinpath("Options", "option_value.jl"), joinpath("Options", "option_definition.jl"),
joinpath("Options", "extraction.jl"),
)),
(mod=CTBase.Orchestration, title="Orchestration", filename="orchestration", files=src(
joinpath("Orchestration", "Orchestration.jl"),
joinpath("Orchestration", "disambiguation.jl"),
joinpath("Orchestration", "builders.jl"),
joinpath("Orchestration", "routing.jl"),
)),
(mod=CTBase.Strategies, title="Strategies", filename="strategies", files=src(
joinpath("Strategies", "Strategies.jl"),
joinpath("Strategies", "display_formatting.jl"),
joinpath("Strategies", "contract", "abstract_strategy.jl"),
joinpath("Strategies", "contract", "metadata.jl"),
joinpath("Strategies", "contract", "strategy_options.jl"),
joinpath("Strategies", "contract", "parameters.jl"),
joinpath("Strategies", "api", "registry.jl"),
joinpath("Strategies", "api", "describe_registry.jl"),
joinpath("Strategies", "api", "introspection.jl"),
joinpath("Strategies", "api", "bypass.jl"),
joinpath("Strategies", "api", "builders.jl"),
joinpath("Strategies", "api", "configuration.jl"),
joinpath("Strategies", "api", "utilities.jl"),
joinpath("Strategies", "api", "validation_helpers.jl"),
joinpath("Strategies", "api", "disambiguation.jl"),
)),
(mod=CTBase.Unicode, title="Unicode", filename="unicode", files=src(
joinpath("Unicode", "Unicode.jl"), joinpath("Unicode", "subscripts.jl"),
joinpath("Unicode", "superscripts.jl"),
)),
]
pages = [
CTBase.automatic_reference_documentation(;
subdirectory="api",
primary_modules=[cfg.mod => cfg.files],
exclude=EXCLUDE_SYMBOLS,
public=true, private=false,
title=cfg.title, title_in_menu=cfg.title, filename=cfg.filename,
)
for cfg in modules_config
]
# ── Internals: all private symbols in one page, sections by module ────────
internals_modules = Any[cfg.mod => cfg.files for cfg in modules_config]
for (sym, files) in [
(:DocumenterReference, ext(
joinpath("DocumenterReference", "DocumenterReference.jl"),
joinpath("DocumenterReference", "config_helpers.jl"),
joinpath("DocumenterReference", "entry_point.jl"),
joinpath("DocumenterReference", "page_building.jl"),
joinpath("DocumenterReference", "source_file_detection.jl"),
joinpath("DocumenterReference", "symbol_classification.jl"),
joinpath("DocumenterReference", "symbol_iteration.jl"),
joinpath("DocumenterReference", "type_formatting.jl"),
joinpath("DocumenterReference", "types.jl"),
)),
(:CoveragePostprocessing, ext(
joinpath("CoveragePostprocessing", "CoveragePostprocessing.jl"),
joinpath("CoveragePostprocessing", "entry_point.jl"),
joinpath("CoveragePostprocessing", "helpers.jl"),
)),
(:TestRunner, ext(
joinpath("TestRunner", "TestRunner.jl"),
joinpath("TestRunner", "arg_parsing.jl"),
joinpath("TestRunner", "entry_point.jl"),
joinpath("TestRunner", "progress.jl"),
joinpath("TestRunner", "test_execution.jl"),
joinpath("TestRunner", "test_selection.jl"),
joinpath("TestRunner", "types.jl"),
)),
]
extmod = Base.get_extension(CTBase, sym)
isnothing(extmod) || push!(internals_modules, extmod => files)
end
push!(pages, CTBase.automatic_reference_documentation(;
subdirectory="api",
primary_modules=internals_modules,
external_modules_to_document=[CTBase],
exclude=EXCLUDE_INTERNALS,
public=false, private=true,
title="Internals", title_in_menu="Internals", filename="internals",
))
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