Skip to content

Commit 8811ecc

Browse files
committed
docs: mrdocs self-reference doc comments
1 parent b5c1635 commit 8811ecc

Some content is hidden

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

50 files changed

+1207
-120
lines changed

docs/config-headers/include/mrdocs/PublicSettings.hpp

Lines changed: 73 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,44 @@ struct PublicSettings {
466466
*/
467467
std::vector<SymbolGlobPattern> implementationDefined;
468468

469+
//--------------------------------------------
470+
// Semantic Parsing
471+
//
472+
// Options to control how the source code is parsed
473+
//--------------------------------------------
474+
475+
/** Include path prefixes allowed to be missing
476+
477+
Specifies path prefixes for include files that, if missing, will not
478+
cause documentation generation to fail.
479+
480+
Missing files with these prefixes are served as empty files from an
481+
in-memory file system, allowing processing to continue.
482+
483+
For example, use "llvm/" to forgive all includes from LLVM.
484+
485+
If any such path is specified, MrDocs will attempt to synthesize
486+
missing included types.
487+
488+
Only simple sets of non-conflicting inferred types can be synthesized.
489+
490+
For more complex types or for better control, provide a shim using the
491+
"missing-include-shims" option.
492+
*/
493+
std::vector<std::string> missingIncludePrefixes;
494+
495+
/** Shims for forgiven missing include files
496+
497+
Specifies a map of include file paths to shim contents.
498+
499+
If a missing include file matches a forgiven prefix, MrDocs will use
500+
the shim content from this map as the file contents.
501+
502+
If no shim is provided for a forgiven file, an empty file is used by
503+
default.
504+
*/
505+
std::map<std::string, std::string> missingIncludeShims;
506+
469507
//--------------------------------------------
470508
// Comment Parsing
471509
//
@@ -1064,17 +1102,18 @@ struct PublicSettings {
10641102
/** Option Type
10651103
*/
10661104
enum class OptionType {
1067-
ListPathGlob,
1068-
Unsigned,
1105+
Enum,
1106+
Path,
1107+
ListSymbolGlob,
10691108
ListPath,
1070-
ListString,
1071-
Bool,
1109+
String,
1110+
Unsigned,
10721111
FilePath,
1112+
ListPathGlob,
10731113
DirPath,
1074-
Path,
1075-
Enum,
1076-
String,
1077-
ListSymbolGlob,
1114+
ListString,
1115+
Bool,
1116+
MapStringString,
10781117
};
10791118

10801119
/** Option validation traits
@@ -1091,16 +1130,17 @@ struct PublicSettings {
10911130
std::optional<std::map<std::string, std::string>> filenameMapping = std::nullopt;
10921131
std::variant<
10931132
std::monostate,
1094-
unsigned,
1133+
LogLevel,
1134+
BaseMemberInheritance,
10951135
std::vector<PathGlobPattern>,
1096-
std::vector<SymbolGlobPattern>,
1136+
unsigned,
1137+
Generator,
1138+
std::map<std::string, std::string>,
10971139
SortSymbolBy,
1140+
std::vector<std::string>,
10981141
bool,
1099-
LogLevel,
1100-
std::string,
1101-
Generator,
1102-
BaseMemberInheritance,
1103-
std::vector<std::string>> defaultValue = std::monostate();
1142+
std::vector<SymbolGlobPattern>,
1143+
std::string> defaultValue = std::monostate();
11041144
std::string relativeTo = {};
11051145
std::optional<std::string> deprecated = std::nullopt;
11061146
};
@@ -1226,6 +1266,16 @@ struct PublicSettings {
12261266
.type = OptionType::ListSymbolGlob,
12271267
.required = false,
12281268
}));
1269+
// Include path prefixes allowed to be missing
1270+
MRDOCS_TRY(std::forward<F>(f)(*this, "missing-include-prefixes", missingIncludePrefixes, dirs, OptionProperties{
1271+
.type = OptionType::ListString,
1272+
.required = false,
1273+
}));
1274+
// Shims for forgiven missing include files
1275+
MRDOCS_TRY(std::forward<F>(f)(*this, "missing-include-shims", missingIncludeShims, dirs, OptionProperties{
1276+
.type = OptionType::MapStringString,
1277+
.required = false,
1278+
}));
12291279
// Use the first line of the comment as the brief
12301280
MRDOCS_TRY(std::forward<F>(f)(*this, "auto-brief", autoBrief, dirs, OptionProperties{
12311281
.type = OptionType::Bool,
@@ -1575,6 +1625,8 @@ struct PublicSettings {
15751625
}
15761626

15771627
/** Visit all options
1628+
1629+
@param f The visitor
15781630
*/
15791631
template <class F>
15801632
void
@@ -1594,6 +1646,8 @@ struct PublicSettings {
15941646
std::forward<F>(f)("exclude-symbols", excludeSymbols);
15951647
std::forward<F>(f)("see-below", seeBelow);
15961648
std::forward<F>(f)("implementation-defined", implementationDefined);
1649+
std::forward<F>(f)("missing-include-prefixes", missingIncludePrefixes);
1650+
std::forward<F>(f)("missing-include-shims", missingIncludeShims);
15971651
std::forward<F>(f)("auto-brief", autoBrief);
15981652
std::forward<F>(f)("auto-relates", autoRelates);
15991653
std::forward<F>(f)("auto-function-metadata", autoFunctionMetadata);
@@ -1652,6 +1706,8 @@ struct PublicSettings {
16521706
}
16531707

16541708
/** Visit all options
1709+
1710+
@param f The visitor
16551711
*/
16561712
template <class F>
16571713
void
@@ -1671,6 +1727,8 @@ struct PublicSettings {
16711727
std::forward<F>(f)("exclude-symbols", excludeSymbols);
16721728
std::forward<F>(f)("see-below", seeBelow);
16731729
std::forward<F>(f)("implementation-defined", implementationDefined);
1730+
std::forward<F>(f)("missing-include-prefixes", missingIncludePrefixes);
1731+
std::forward<F>(f)("missing-include-shims", missingIncludeShims);
16741732
std::forward<F>(f)("auto-brief", autoBrief);
16751733
std::forward<F>(f)("auto-relates", autoRelates);
16761734
std::forward<F>(f)("auto-function-metadata", autoFunctionMetadata);

docs/config-headers/src/tool/PublicToolArgs.hpp

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ struct PublicToolArgs {
4848
*/
4949
llvm::cl::OptionCategory filtersCat;
5050

51+
/** Options to control how the source code is parsed
52+
53+
Mr.Docs uses libclang to parse the source code and extract symbols. The
54+
following options control how the source code is parsed.
55+
*/
56+
llvm::cl::OptionCategory semanticParsingCat;
57+
5158
/** Options to control how comments are parsed
5259
5360
Mr.Docs extracts metadata from the comments in the source code. The
@@ -315,6 +322,44 @@ struct PublicToolArgs {
315322
*/
316323
llvm::cl::list<std::string> implementationDefined;
317324

325+
//--------------------------------------------
326+
// Semantic Parsing
327+
//
328+
// Options to control how the source code is parsed
329+
//--------------------------------------------
330+
331+
/** Include path prefixes allowed to be missing
332+
333+
Specifies path prefixes for include files that, if missing, will not
334+
cause documentation generation to fail.
335+
336+
Missing files with these prefixes are served as empty files from an
337+
in-memory file system, allowing processing to continue.
338+
339+
For example, use "llvm/" to forgive all includes from LLVM.
340+
341+
If any such path is specified, MrDocs will attempt to synthesize
342+
missing included types.
343+
344+
Only simple sets of non-conflicting inferred types can be synthesized.
345+
346+
For more complex types or for better control, provide a shim using the
347+
"missing-include-shims" option.
348+
*/
349+
llvm::cl::list<std::string> missingIncludePrefixes;
350+
351+
/** Shims for forgiven missing include files
352+
353+
Specifies a map of include file paths to shim contents.
354+
355+
If a missing include file matches a forgiven prefix, MrDocs will use
356+
the shim content from this map as the file contents.
357+
358+
If no shim is provided for a forgiven file, an empty file is used by
359+
default.
360+
*/
361+
llvm::cl::list<std::string> missingIncludeShims;
362+
318363
//--------------------------------------------
319364
// Comment Parsing
320365
//
@@ -912,6 +957,8 @@ struct PublicToolArgs {
912957
std::forward<F>(f)("exclude-symbols", excludeSymbols);
913958
std::forward<F>(f)("see-below", seeBelow);
914959
std::forward<F>(f)("implementation-defined", implementationDefined);
960+
std::forward<F>(f)("missing-include-prefixes", missingIncludePrefixes);
961+
std::forward<F>(f)("missing-include-shims", missingIncludeShims);
915962
std::forward<F>(f)("auto-brief", autoBrief);
916963
std::forward<F>(f)("auto-relates", autoRelates);
917964
std::forward<F>(f)("auto-function-metadata", autoFunctionMetadata);

docs/mrdocs.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ include-symbols:
1515
- 'clang::mrdocs::**'
1616
implementation-defined:
1717
- 'clang::mrdocs::detail'
18+
- 'clang::mrdocs::report::detail'
19+
- 'clang::mrdocs::dom::detail'
1820
multipage: true
1921
generator: adoc
2022
cmake: '-D MRDOCS_DOCUMENTATION_BUILD=ON'

include/mrdocs/ADT/Polymorphic.hpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,19 @@ template <class T> class Polymorphic {
7777
/// Default constructs the value type.
7878
explicit constexpr Polymorphic() : Polymorphic(std::in_place_type<T>) {}
7979

80-
/// Forwarding constructor.
80+
/** Forwarding constructor.
81+
* @param u The object to copy.
82+
*/
8183
template <class U>
8284
constexpr explicit Polymorphic(U &&u)
8385
requires(not std::same_as<Polymorphic, std::remove_cvref_t<U>>) &&
8486
std::copy_constructible<std::remove_cvref_t<U>> &&
8587
std::derived_from<std::remove_cvref_t<U>, T>
8688
: WB(new Wrapper<std::remove_cvref_t<U>>(std::forward<U>(u))) {}
8789

88-
/// In place constructor.
90+
/** In place constructor
91+
* @param ts Arguments to forward to the constructor of U.
92+
*/
8993
template <class U, class... Ts>
9094
explicit constexpr Polymorphic(std::in_place_type_t<U>, Ts &&...ts)
9195
requires std::same_as<std::remove_cvref_t<U>, U> &&
@@ -171,7 +175,7 @@ template <class T> inline constexpr bool IsPolymorphic<Polymorphic<T>> = true;
171175

172176
} // namespace detail
173177

174-
/** Compares two polymorphic objects that have visit functions
178+
/** @brief Compares two polymorphic objects that have visit functions
175179
176180
This function compares two Polymorphic objects that
177181
have visit functions for the Base type.
@@ -209,7 +213,7 @@ CompareDerived(
209213
: std::strong_ordering::greater;
210214
}
211215

212-
/// @copydoc CompareDerived
216+
/// @copydoc CompareDerived(Polymorphic<Base> const&, Polymorphic<Base> const&)
213217
template <class Base>
214218
requires(!detail::IsPolymorphic<Base>) && detail::CanVisitCompare<Base>
215219
auto CompareDerived(Base const &lhs, Base const &rhs) {

include/mrdocs/Config.hpp

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#include <mrdocs/Support/Error.hpp>
1717
#include <mrdocs/Dom/Object.hpp>
1818
#include <mrdocs/PublicSettings.hpp>
19-
#include "lib/Support/YamlFwd.hpp"
2019
#include <functional>
2120
#include <memory>
2221
#include <string>
@@ -25,6 +24,13 @@
2524
#include <utility>
2625
#include <vector>
2726

27+
namespace llvm::yaml {
28+
29+
template<class T>
30+
struct MappingTraits;
31+
32+
} // llvm::yaml
33+
2834
namespace clang {
2935
namespace mrdocs {
3036

@@ -62,13 +68,13 @@ class MRDOCS_DECL
6268
*/
6369
struct Settings : public PublicSettings
6470
{
65-
/**
66-
* @brief Loads the public configuration settings from the specified YAML file.
71+
/** @brief Loads the public configuration settings from the specified YAML file.
6772
*
6873
* This function takes a YAML file and a set of reference directories as input.
6974
* It parses the YAML file and loads the configuration settings into a Config::Settings object.
7075
* The reference directories are used to resolve any relative paths in the configuration settings.
7176
*
77+
* @param s A reference to a Config::Settings object where the configuration settings will be loaded.
7278
* @param configYaml A string view representing the YAML file containing the configuration settings.
7379
* @param dirs A constant reference to a PublicSettings::ReferenceDirectories object containing the reference directories.
7480
* @return An Expected object containing a Config::Settings object if the YAML file was successfully parsed and the configuration settings were loaded, or an error otherwise.
@@ -80,17 +86,17 @@ class MRDOCS_DECL
8086
std::string_view configYaml,
8187
ReferenceDirectories const& dirs);
8288

83-
/**
84-
* @brief Loads the public configuration settings from the specified file.
85-
*
86-
* This function takes a file path and a set of reference directories as input.
87-
* It reads the file and loads the configuration settings into a Config::Settings object.
88-
* The reference directories are used to resolve any relative paths in the configuration settings.
89-
*
90-
* @param s A reference to a Config::Settings object where the configuration settings will be loaded.
91-
* @param filePath A string view representing the file path of the configuration settings.
92-
* @param dirs A constant reference to a PublicSettings::ReferenceDirectories object containing the reference directories.
93-
* @return An Expected object containing void if the file was successfully read and the configuration settings were loaded, or an error otherwise.
89+
/** Loads the public configuration settings from the specified file.
90+
91+
This function takes a file path and a set of reference directories as input.
92+
It reads the file and loads the configuration settings into a Config::Settings object.
93+
The reference directories are used to resolve any relative paths in the configuration settings.
94+
95+
@param s A reference to a Config::Settings object where the configuration settings will be loaded.
96+
@param configPath A string view representing the file path of the configuration settings.
97+
@param dirs A constant reference to a PublicSettings::ReferenceDirectories object containing the reference directories.
98+
99+
@return An Expected object containing void if the file was successfully read and the configuration settings were loaded, or an error otherwise.
94100
*/
95101
static Expected<void>
96102
load_file(
@@ -120,6 +126,8 @@ class MRDOCS_DECL
120126
121127
This string will always be native style
122128
and have a trailing directory separator.
129+
130+
@return The full path to the config file directory.
123131
*/
124132
std::string
125133
configDir() const;
@@ -143,6 +151,8 @@ class MRDOCS_DECL
143151
144152
This string will always be native style
145153
and have a trailing directory separator.
154+
155+
@return The full path to the output directory.
146156
*/
147157
std::string
148158
outputDir() const;

0 commit comments

Comments
 (0)