@@ -21,7 +21,14 @@ using MarkdownAST: MarkdownAST
2121
2222Enumeration of documentation element types recognized by the API reference generator.
2323
24- Types include: abstract types, constants, functions, macros, modules, and structs.
24+ # Values
25+
26+ - `DOCTYPE_ABSTRACT_TYPE`: An abstract type declaration
27+ - `DOCTYPE_CONSTANT`: A constant binding (including non-function, non-type values)
28+ - `DOCTYPE_FUNCTION`: A function or callable
29+ - `DOCTYPE_MACRO`: A macro (name starts with `@`)
30+ - `DOCTYPE_MODULE`: A submodule
31+ - `DOCTYPE_STRUCT`: A concrete struct type
2532"""
2633@enum (
2734 DocType,
@@ -39,16 +46,20 @@ Types include: abstract types, constants, functions, macros, modules, and struct
3946Internal configuration for API reference generation.
4047
4148# Fields
42- - `current_module::Module`: The module being documented
43- - `subdirectory::String`: Output directory for generated API pages
44- - `modules::Dict{Module,<:Vector}`: Mapping of modules to document
45- - `sort_by::Function`: Custom sort function for symbols
46- - `exclude::Set{Symbol}`: Symbol names to exclude from documentation
47- - `public::Bool`: Flag to generate public API page
48- - `private::Bool`: Flag to generate private API page
49- - `title::String`: Top-level title for API reference
50- - `source_files::Vector{String}`: Absolute source file paths used to filter documented symbols (empty means no filtering)
51- - `filename::String`: Base filename (without extension) used for the underlying markdown file in single-page cases
49+
50+ - `current_module::Module`: The module being documented.
51+ - `subdirectory::String`: Output directory for generated API pages.
52+ - `modules::Dict{Module,<:Vector}`: Mapping of modules to extras (reserved for future use).
53+ - `sort_by::Function`: Custom sort function for symbols.
54+ - `exclude::Set{Symbol}`: Symbol names to exclude from documentation.
55+ - `public::Bool`: Flag to generate public API page.
56+ - `private::Bool`: Flag to generate private API page.
57+ - `title::String`: Title displayed at the top of the generated page.
58+ - `title_in_menu::String`: Title displayed in the navigation menu.
59+ - `source_files::Vector{String}`: Absolute source file paths used to filter documented symbols (empty means no filtering).
60+ - `filename::String`: Base filename (without extension) for the markdown file.
61+ - `include_without_source::Bool`: If `true`, include symbols whose source file cannot be determined.
62+ - `doc_modules::Vector{Module}`: Additional modules to search for docstrings (e.g., `Base`).
5263"""
5364struct _Config
5465 current_module:: Module
@@ -66,6 +77,14 @@ struct _Config
6677 doc_modules:: Vector{Module} # Additional modules to search for docstrings (e.g., Base)
6778end
6879
80+ """
81+ CONFIG::Vector{_Config}
82+
83+ Global configuration storage for API reference generation.
84+
85+ Each call to [`automatic_reference_documentation`](@ref) appends a new `_Config`
86+ entry to this vector. Use [`reset_config!`](@ref) to clear it between builds.
87+ """
6988const CONFIG = _Config[]
7089
7190"""
@@ -78,8 +97,26 @@ function reset_config!()
7897 return nothing
7998end
8099
100+ """
101+ APIBuilder <: Documenter.Builder.DocumentPipeline
102+
103+ Custom Documenter pipeline stage for automatic API reference generation.
104+
105+ This builder is inserted into the Documenter pipeline at order `0.0` (before
106+ most other stages) to generate API reference pages from the configurations
107+ stored in [`CONFIG`](@ref).
108+ """
81109abstract type APIBuilder <: Documenter.Builder.DocumentPipeline end
82110
111+ """
112+ Documenter.Selectors.order(::Type{APIBuilder}) -> Float64
113+
114+ Return the pipeline order for [`APIBuilder`](@ref).
115+
116+ # Returns
117+
118+ - `Float64`: Always `0.0`, placing this stage early in the Documenter pipeline.
119+ """
83120Documenter. Selectors. order (:: Type{APIBuilder} ) = 0.0
84121
85122"""
116153"""
117154 _build_page_path(subdirectory::String, filename::String) -> String
118155
119- Build the page path, handling the case where subdirectory is "." or empty.
156+ Build the page path by joining subdirectory and filename.
157+
158+ Handles special cases where `subdirectory` is `"."` or empty, returning just
159+ the filename in those cases.
160+
161+ # Arguments
162+
163+ - `subdirectory::String`: Directory path (may be `"."` or empty).
164+ - `filename::String`: The filename to append.
165+
166+ # Returns
167+
168+ - `String`: The combined path, or just `filename` if subdirectory is `"."` or empty.
120169"""
121170function _build_page_path (subdirectory:: String , filename:: String )
122171 if subdirectory == " ." || subdirectory == " "
137186 title::String = "API Reference",
138187 filename::String = "",
139188 source_files::Vector{String} = String[],
189+ include_without_source::Bool = false,
190+ doc_modules::Vector{Module} = Module[],
140191 )
141192
142193Automatically creates the API reference documentation for one or more modules and
@@ -469,15 +520,22 @@ end
469520"""
470521 _iterate_over_symbols(f, config, symbol_list)
471522
472- Iterate over symbols, apply a function to each documented symbol.
523+ Iterate over symbols, applying a function to each documented symbol.
473524
474- Filters symbols based on exclusion list, checks for documentation, and applies the
475- provided function to each valid symbol. Issues warnings for undocumented symbols.
525+ Filters symbols based on:
526+ 1. Exclusion list (`config.exclude`)
527+ 2. Presence of documentation (warns and skips undocumented symbols)
528+ 3. Source file filtering (`config.source_files`)
476529
477530# Arguments
478- - `f::Function`: Function to apply to each (symbol, type) pair
479- - `config::_Config`: Configuration containing exclusion rules and module info
480- - `symbol_list::Vector`: List of (Symbol, DocType) pairs to process
531+
532+ - `f::Function`: Callback function `f(key::Symbol, type::DocType)` applied to each valid symbol.
533+ - `config::_Config`: Configuration containing exclusion rules, module info, and source file filters.
534+ - `symbol_list::Vector{Pair{Symbol,DocType}}`: List of symbol-type pairs to process.
535+
536+ # Returns
537+
538+ - `nothing`
481539"""
482540function _iterate_over_symbols (f, config, symbol_list)
483541 current_module = config. current_module
@@ -487,9 +545,14 @@ function _iterate_over_symbols(f, config, symbol_list)
487545 continue
488546 end
489547 binding = Base. Docs. Binding (current_module, key)
490- doc = Base. Docs. doc (binding)
491- missing_doc =
492- doc === nothing || occursin (" No documentation found." , string (doc))
548+ missing_doc = false
549+ if isdefined (Base. Docs, :hasdoc )
550+ missing_doc = ! Base. Docs. hasdoc (binding)
551+ else
552+ doc = Base. Docs. doc (binding)
553+ missing_doc =
554+ doc === nothing || occursin (" No documentation found." , string (doc))
555+ end
493556 if missing_doc
494557 if type == DOCTYPE_MODULE
495558 mod = getfield (current_module, key)
@@ -552,16 +615,23 @@ function _to_string(x::DocType)
552615end
553616
554617"""
555- _build_api_page(document, config)
618+ _build_api_page(document::Documenter.Document , config::_Config )
556619
557- Generate public and private API reference pages for a module.
620+ Generate public and/or private API reference pages for a module.
558621
559- Creates two markdown pages: one listing exported symbols and one for internal symbols.
560- Each page includes an overview and docstring references for all documented symbols.
622+ Creates markdown pages listing symbols with their docstrings. When both
623+ `config.public` and `config.private` are `true`, two separate pages are
624+ generated (`public.md` and `private.md`). Otherwise, a single page is created
625+ using `config.filename`.
561626
562627# Arguments
563- - `document::Documenter.Document`: Documenter document object
564- - `config::_Config`: Configuration for the module being documented
628+
629+ - `document::Documenter.Document`: The Documenter document object to add pages to.
630+ - `config::_Config`: Configuration specifying the module, output paths, and filtering options.
631+
632+ # Returns
633+
634+ - `nothing`
565635"""
566636function _build_api_page (document:: Documenter.Document , config:: _Config )
567637 subdir = config. subdirectory
0 commit comments