Skip to content

Commit c2b8ab8

Browse files
committed
support doxygen-like filters
#feat #fix 761 #fix 751
1 parent 73c2845 commit c2b8ab8

File tree

484 files changed

+26212
-15256
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

484 files changed

+26212
-15256
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,8 @@ jobs:
640640
"html"
641641
)
642642
643+
cp example/external/url/mrdocs.yml boost/libs/url/doc/mrdocs.yml
644+
643645
# Generate the demos for each variant and generator
644646
for variant in single multi; do
645647
for generator in "${generators[@]}"; do

docs/mrdocs.schema.json

Lines changed: 96 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,10 @@
88
"type": "string"
99
},
1010
"anonymous-namespaces": {
11-
"default": "always",
11+
"default": true,
1212
"description": "Determine whether symbols in anonymous namespaces should be extracted. When set to `always`, symbols in anonymous namespaces are always extracted. When set to `dependency`, symbols in anonymous namespaces are extracted only if they are referenced by the source code. When set to `never`, symbols in anonymous namespaces are never extracted.",
13-
"enum": [
14-
"always",
15-
"dependency",
16-
"never"
17-
],
18-
"title": "Extraction policy for anonymous namespaces"
13+
"title": "Extraction policy for anonymous namespaces",
14+
"type": "boolean"
1915
},
2016
"base-url": {
2117
"default": "",
@@ -44,52 +40,62 @@
4440
"title": "Additional defines passed to the compiler",
4541
"type": "array"
4642
},
47-
"detect-sfinae": {
48-
"default": true,
49-
"description": "When set to true, MrDocs detects SFINAE expressions in the source code and extracts them as part of the documentation. Expressions such as `std::enable_if<...>` are detected, removed, and documented as a requirement.",
50-
"title": "Detect SFINAE expressions",
51-
"type": "boolean"
52-
},
5343
"embedded": {
5444
"default": false,
55-
"title": "Output an embeddable document, which excludes the header, the footer, and everything outside the body of the document. This option is useful for producing documents that can be inserted into an external template.",
45+
"description": "Output an embeddable document, which excludes the header, the footer, and everything outside the body of the document. This option is useful for producing documents that can be inserted into an external template.",
46+
"title": "Output an embeddable document",
5647
"type": "boolean"
5748
},
58-
"filters": {
59-
"properties": {
60-
"symbols": {
61-
"description": "Symbol filters. Symbols that match these filters are extracted. The filters are applied to the fully qualified name of the symbol.",
62-
"properties": {
63-
"exclude": {
64-
"default": [],
65-
"description": "Specifies symbol exclusion patterns. Symbols that match these patterns are not extracted. The patterns are applied to the fully qualified name of the symbol.",
66-
"items": {
67-
"type": "string"
68-
},
69-
"title": "Specifies symbol exclusion patterns",
70-
"type": "array"
71-
},
72-
"include": {
73-
"default": [],
74-
"description": "Specifies symbol inclusion patterns. Symbols that match these patterns are extracted. The patterns are applied to the fully qualified name of the symbol.",
75-
"items": {
76-
"type": "string"
77-
},
78-
"title": "Specifies symbol inclusion patterns",
79-
"type": "array"
80-
}
81-
},
82-
"required": [],
83-
"title": "Symbol filters",
84-
"type": "object"
85-
}
49+
"exclude": {
50+
"default": [],
51+
"description": "Symbols defined in files in these directories are not extracted even if they are in the list of include directories. When relative, the paths are relative to the directory of the mrdocs configuration file. For instance, \"include/experimental\" will exclude all files in the directory `<config-dir>/include/experimental`.",
52+
"items": {
53+
"type": "string"
54+
},
55+
"title": "Input directories to exclude",
56+
"type": "array"
57+
},
58+
"exclude-patterns": {
59+
"default": [],
60+
"description": "File patterns to exclude. Files that match these patterns are not extracted even if they are in the list of include directories. The patterns are relative to the configuration file. A single * will match all files in the directory. Double ** will match all files in the directory and its subdirectories.",
61+
"items": {
62+
"type": "string"
63+
},
64+
"title": "File patterns to exclude",
65+
"type": "array"
66+
},
67+
"exclude-symbols": {
68+
"default": [],
69+
"description": "A symbol that matches one of these patterns is not extracted even if whitelisted by \"include-symbols\". See the documentation for \"include-symbols\" for the pattern syntax.",
70+
"items": {
71+
"type": "string"
72+
},
73+
"title": "Symbol patterns to exclude",
74+
"type": "array"
75+
},
76+
"file-patterns": {
77+
"default": [
78+
"*.hpp",
79+
"*.h",
80+
"*.hh",
81+
"*.ipp",
82+
"*.inc",
83+
"*.cpp",
84+
"*.cc",
85+
"*.cxx",
86+
"*.c",
87+
"*.hxx"
88+
],
89+
"description": "File patterns to include. Only the files that match these patterns are extracted. The patterns are relative to the input directories.",
90+
"items": {
91+
"type": "string"
8692
},
87-
"required": [],
88-
"title": "Filters",
89-
"type": "object"
93+
"title": "File patterns to include",
94+
"type": "array"
9095
},
91-
"generate": {
96+
"generator": {
9297
"default": "adoc",
98+
"description": "The generator is responsible for creating the documentation from the extracted symbols. The generator uses the extracted symbols and the templates to create the documentation. The generator can create different types of documentation such as HTML, XML, and AsciiDoc.",
9399
"enum": [
94100
"adoc",
95101
"html",
@@ -111,32 +117,21 @@
111117
},
112118
"implementation-defined": {
113119
"default": [],
114-
"description": "Namespaces for symbols rendered as \"implementation-defined\". Symbols in these are rendered as \"implementation-defined\" in the documentation. This option is used to exclude symbols from the documentation that are considered part of the private API of the project. An \"implementation-defined\" symbol has no documentation page in the output. If any other symbol refers to it, the reference is rendered as \"implementation-defined\".",
120+
"description": "Symbols that match one of these filters are tagged as \"implementation-defined\" in the documentation, and so do symbols in scopes tagged as \"implementation-defined\". This option is used to exclude symbols from the documentation that are considered part of the private API of the project. An \"implementation-defined\" symbol has no documentation page in the output. If any other symbol refers to it, the reference is rendered as \"implementation-defined\". See the documentation for \"include-symbol\" for the pattern syntax.",
115121
"items": {
116122
"type": "string"
117123
},
118-
"title": "Namespaces for symbols rendered as \"implementation-defined\"",
124+
"title": "Symbols rendered as \"implementation-defined\"",
119125
"type": "array"
120126
},
121-
"inaccessible-bases": {
122-
"default": "always",
123-
"description": "Determine whether inaccessible base classes should be extracted. When set to `always`, inaccessible base classes are always extracted. When set to `dependency`, inaccessible base classes are extracted only if they are referenced by the source code. When set to `never`, inaccessible base classes are never extracted.",
124-
"enum": [
125-
"always",
126-
"dependency",
127-
"never"
128-
],
129-
"title": "Extraction policy for inaccessible base classes"
130-
},
131-
"inaccessible-members": {
132-
"default": "always",
133-
"description": "Determine whether inaccessible members, such as private members of records, should be extracted. When set to `always`, inaccessible members are always extracted. When set to `dependency`, inaccessible members are extracted only if they are referenced by the source code. When set to `never`, inaccessible members are never extracted.",
134-
"enum": [
135-
"always",
136-
"dependency",
137-
"never"
138-
],
139-
"title": "Extraction policy for inaccessible members"
127+
"include-symbols": {
128+
"default": [],
129+
"description": "If any patterns are defined here, only symbols that match one of these patterns are extracted. The patterns are applied to the fully qualified name of the symbol without any leading \"::\". A single \"*\" will match all symbols in the namespace. Double \"**\" will match all symbols in the namespace and its subnamespaces. The patterns also support \"?\" for any chars, \"[<chars>]\" for charsets, \"[^<chars>]\" for inverted charsets, and \"{<glob>,...}\" for alternatives.",
130+
"items": {
131+
"type": "string"
132+
},
133+
"title": "Symbol patterns to include",
134+
"type": "array"
140135
},
141136
"includes": {
142137
"default": [],
@@ -148,30 +143,15 @@
148143
"type": "array"
149144
},
150145
"input": {
151-
"description": "Include files to extract. Only the files listed in this option are extracted. The paths are relative to the mrdocs configuration file.",
152-
"properties": {
153-
"file-patterns": {
154-
"default": [],
155-
"description": "File patterns to include. Only the files that match these patterns are extracted. The patterns are relative to the input directories.",
156-
"items": {
157-
"type": "string"
158-
},
159-
"title": "File patterns to include",
160-
"type": "array"
161-
},
162-
"include": {
163-
"default": [],
164-
"description": "Input directories to include. Only the files in these directories are extracted. The paths are relative to the mrdocs configuration file.",
165-
"items": {
166-
"type": "string"
167-
},
168-
"title": "Input directories to include",
169-
"type": "array"
170-
}
146+
"default": [
147+
"<source-root>/."
148+
],
149+
"description": "Input directories to extract. Only symbols defined in files in these directories are extracted. The paths are relative to the mrdocs configuration file.",
150+
"items": {
151+
"type": "string"
171152
},
172-
"required": [],
173-
"title": "Include files to extract",
174-
"type": "object"
153+
"title": "Input directories to extract symbols from",
154+
"type": "array"
175155
},
176156
"legible-names": {
177157
"default": true,
@@ -202,15 +182,23 @@
202182
"title": "Directory or file for generating output",
203183
"type": "string"
204184
},
205-
"referenced-declarations": {
206-
"default": "never",
207-
"description": "Determine whether external declarations should be extracted when they are referenced in the source code. If this option is not `never`, a second pass happens in the extraction process to extract dependencies in the Corpus. When set to `always`, external declarations are always extracted. When set to `dependency`, external declarations are extracted only if they are referenced by the source code. When set to `never`, external declarations are never extracted.",
208-
"enum": [
209-
"always",
210-
"dependency",
211-
"never"
212-
],
213-
"title": "Extraction policy for references to external declarations"
185+
"private-bases": {
186+
"default": true,
187+
"description": "Determine whether private base classes should be extracted",
188+
"title": "Extraction policy for private base classes",
189+
"type": "boolean"
190+
},
191+
"private-members": {
192+
"default": false,
193+
"description": "Determine whether private class members should be extracted",
194+
"title": "Extraction policy for private class members",
195+
"type": "boolean"
196+
},
197+
"recursive": {
198+
"default": true,
199+
"description": "Recursively include files. When set to true, MrDocs includes files in subdirectories of the input directories. When set to false, MrDocs includes only the files in the input directories.",
200+
"title": "Recursively include files from \"input\" paths",
201+
"type": "boolean"
214202
},
215203
"report": {
216204
"default": 1,
@@ -222,15 +210,22 @@
222210
},
223211
"see-below": {
224212
"default": [],
225-
"description": "Namespaces for symbols rendered as \"see-below\". Symbols in these namespaces are rendered as \"see-below\" in the documentation. This option is used to exclude details about symbols from the documentation that are considered part of the private API of the project. In the documentation page for this symbol, the synopsis of the implementation of a \"see-below\" symbol is rendered as \"see-below\". When the symbol is a scope (such as a namespace or record), its members are not listed. The rest of the documentation is rendered as usual.",
213+
"description": "Symbols that match one of these filters are tagged as \"see-below\" in the documentation, and so do symbols in scopes tagged as \"see-below\". This option is used to remove details about symbols that are considered part of the private API of the project. In the documentation page for this symbol, the synopsis of the implementation is rendered as \"see-below\" and members of scopes (such as a namespace or record) are not listed. The rest of the documentation is rendered as usual. See the documentation for \"include-symbol\" for the pattern syntax.",
226214
"items": {
227215
"type": "string"
228216
},
229-
"title": "Namespaces for symbols rendered as \"see-below\"",
217+
"title": "Symbols rendered as \"see-below\"",
230218
"type": "array"
231219
},
220+
"sfinae": {
221+
"default": true,
222+
"description": "When set to true, MrDocs detects SFINAE expressions in the source code and extracts them as part of the documentation. Expressions such as `std::enable_if<...>` are detected, removed, and documented as a requirement.",
223+
"title": "Detect and reduce SFINAE expressions",
224+
"type": "boolean"
225+
},
232226
"source-root": {
233227
"default": "<config-dir>",
228+
"description": "Path to the root directory of the source code. This path is used as a default for input files and a base for relative paths formed from absolute paths.",
234229
"title": "Path to the root directory of the source code",
235230
"type": "string"
236231
},

docs/mrdocs.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,13 @@
33

44
verbose: true
55
source-root: ..
6+
input:
7+
- ../include
8+
file-patterns:
9+
- '*.hpp'
10+
include-symbols:
11+
- 'clang::mrdocs::**'
12+
implementation-defined:
13+
- 'clang::mrdocs::detail'
614
multipage: false
7-
generate: adoc
15+
generator: adoc

docs/website/render.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ target_compile_features(${sourceBasename} PRIVATE cxx_std_23)
7474
mrdocsInput,
7575
`--output=${mrdocsOutput}`,
7676
'--multipage=true',
77-
'--generate=html',
77+
'--generator=html',
7878
'--embedded=true',
7979
];
8080
const command = args.join(' ');

docs/website/snippets/mrdocs.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
source-root: .
22
input:
3-
include:
4-
- .
3+
- .

example/external/url/mrdocs.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Input
2+
source-root: ..
3+
# Directories that contain documented source files
4+
input:
5+
- ../include
6+
# Patterns to filter out the source-files in the directories
7+
file-patterns:
8+
- '*.hpp'
9+
10+
# Filters
11+
include-symbols:
12+
- 'boost::urls::**'
13+
exclude-symbols:
14+
# Exclude implementation details
15+
- 'boost::urls::detail'
16+
- 'boost::urls::*::detail'
17+
# Exclude implementation details defined elsewhere
18+
- 'boost::urls::*_unsafe'
19+
- 'boost::urls::*_t'
20+
- 'boost::urls::make_error_code'
21+
- 'boost::urls::make_void'
22+
implementation-defined:
23+
- 'boost::urls::implementation_defined'
24+
- 'boost::urls::grammar::implementation_defined'
25+
- 'boost::urls::string_token::implementation_defined'
26+
- 'boost::urls::grammar::*_t'
27+
- 'boost::urls::grammar::make_error_*'
28+
- 'boost::urls::grammar::operator_*'
29+
- 'boost::urls::string_token::*_t'
30+
see-below:
31+
- 'boost::urls::see_below'
32+
- 'boost::urls::grammar::see_below'
33+
- 'boost::urls::string_token::see_below'
34+
35+
# Generator
36+
generate: adoc
37+
base-url: https://www.github.com/boostorg/url/blob/develop/include/ # boost/url/url_view.hpp
38+
39+
# Style
40+
verbose: true
41+
multipage: true
42+
43+
# The target for MrDocs simply includes all symbols defined in all
44+
# headers with the appropriate compilation options.
45+
# Nothing else should be included in the MrDocs configuration or
46+
# would be useful to MrDocs.
47+
#
48+
# This single source file not only includes all symbols (the source
49+
# files do not collectively include all headers) but also makes MrDocs
50+
# run much faster than relying on the entire library.
51+
#
52+
# The time to extract the declarations went from ~8m6s to ~3s in our
53+
# experiments: a 162x speedup while including all symbols!
54+
#
55+
# In practice, this special target is simply emulating the
56+
# default behavior of the standardese tool with MrDocs, which
57+
# requires the user to clearly specify the targets via the
58+
# compilation database.
59+
#
60+
# The BOOST_URL_MRDOCS_BUILD=ON is the only option we usually need
61+
# here.
62+
# The other options are set just to ensure other targets are
63+
# ignored even if these options are set as ON in the cache.
64+
#
65+
cmake: '-D BOOST_URL_MRDOCS_BUILD=ON -D CMAKE_CXX_STANDARD=20 -D BOOST_URL_BUILD_FUZZERS=OFF -D BOOST_URL_BUILD_EXAMPLES=OFF -D BOOST_URL_BUILD_TESTS=OFF -D BUILD_TESTING=OFF'

include/mrdocs/Config.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,8 @@ class MRDOCS_DECL
120120
This string will always be native style
121121
and have a trailing directory separator.
122122
*/
123-
std::string configDir;
123+
std::string
124+
configDir() const;
124125

125126
/** Full path to the mrdocs root directory
126127

include/mrdocs/Config/ReferenceDirectories.hpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,15 @@ namespace clang {
1818
namespace mrdocs {
1919

2020
/** Reference directories used to resolve paths
21+
22+
These are the main reference directories used to resolve paths in the
23+
application.
24+
25+
All other reference directories come directly from the
26+
configuration file.
2127
*/
22-
struct ReferenceDirectories {
23-
std::string configDir;
28+
struct ReferenceDirectories
29+
{
2430
std::string cwd;
2531
std::string mrdocsRoot;
2632
};

0 commit comments

Comments
 (0)