Skip to content

Commit 1ab842d

Browse files
committed
preprocess javadoc metadata
#perf
1 parent af93d8d commit 1ab842d

File tree

92 files changed

+5016
-1072
lines changed

Some content is hidden

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

92 files changed

+5016
-1072
lines changed

include/mrdocs/Metadata/Javadoc.hpp

+53-39
Original file line numberDiff line numberDiff line change
@@ -731,13 +731,13 @@ struct Param final : Paragraph
731731

732732
auto operator<=>(Param const&) const = default;
733733

734-
bool operator==(const Param&)
734+
bool operator==(Param const&)
735735
const noexcept = default;
736736

737-
bool equals(const Node& other) const noexcept override
737+
bool equals(Node const& other) const noexcept override
738738
{
739739
return Kind == other.Kind &&
740-
*this == dynamic_cast<const Param&>(other);
740+
*this == dynamic_cast<Param const&>(other);
741741
}
742742
};
743743

@@ -1008,19 +1008,6 @@ void traverse(
10081008
std::forward<Args>(args)...);
10091009
}
10101010

1011-
struct Overview
1012-
{
1013-
std::shared_ptr<Paragraph> brief = nullptr;
1014-
std::vector<Block const*> blocks;
1015-
Returns const* returns = nullptr;
1016-
std::vector<Param const*> params;
1017-
std::vector<TParam const*> tparams;
1018-
std::vector<Throws const*> exceptions;
1019-
std::vector<See const*> sees;
1020-
std::vector<Precondition const*> preconditions;
1021-
std::vector<Postcondition const*> postconditions;
1022-
};
1023-
10241011
MRDOCS_DECL
10251012
dom::String
10261013
toString(Style style) noexcept;
@@ -1036,7 +1023,41 @@ class Corpus;
10361023
struct MRDOCS_DECL
10371024
Javadoc
10381025
{
1039-
std::vector<Polymorphic<doc::Block>> blocks_;
1026+
/// The list of text blocks.
1027+
std::vector<Polymorphic<doc::Block>> blocks;
1028+
1029+
// ----------------------
1030+
// Symbol Metadata
1031+
1032+
/// A brief description of the symbol.
1033+
std::optional<doc::Brief> brief;
1034+
1035+
/** The list of return type descriptions.
1036+
1037+
Multiple return descriptions are allowed.
1038+
1039+
The results are concatenated in the order
1040+
they appear in the source code.
1041+
*/
1042+
std::vector<doc::Returns> returns;
1043+
1044+
/// The list of parameters.
1045+
std::vector<doc::Param> params;
1046+
1047+
/// The list of template parameters.
1048+
std::vector<doc::TParam> tparams;
1049+
1050+
/// The list of exceptions.
1051+
std::vector<doc::Throws> exceptions;
1052+
1053+
/// The list of "see also" references.
1054+
std::vector<doc::See> sees;
1055+
1056+
/// The list of preconditions.
1057+
std::vector<doc::Precondition> preconditions;
1058+
1059+
/// The list of postconditions.
1060+
std::vector<doc::Postcondition> postconditions;
10401061

10411062
/** Constructor.
10421063
*/
@@ -1054,7 +1075,16 @@ struct MRDOCS_DECL
10541075
bool
10551076
empty() const noexcept
10561077
{
1057-
return blocks_.empty();
1078+
return
1079+
blocks.empty() &&
1080+
!brief &&
1081+
returns.empty() &&
1082+
params.empty() &&
1083+
tparams.empty() &&
1084+
exceptions.empty() &&
1085+
sees.empty() &&
1086+
preconditions.empty() &&
1087+
postconditions.empty();
10581088
}
10591089

10601090
/** Return the brief, or nullptr if there is none.
@@ -1070,15 +1100,15 @@ struct MRDOCS_DECL
10701100
std::vector<Polymorphic<doc::Block>> const&
10711101
getBlocks() const noexcept
10721102
{
1073-
return blocks_;
1103+
return blocks;
10741104
}
10751105

10761106
// VFALCO This is unfortunately necessary for
10771107
// the deserialization from bitcode...
10781108
std::vector<Polymorphic<doc::Block>>&
10791109
getBlocks() noexcept
10801110
{
1081-
return blocks_;
1111+
return blocks;
10821112
}
10831113

10841114
//--------------------------------------------
@@ -1091,14 +1121,14 @@ struct MRDOCS_DECL
10911121
*/
10921122
/** @{ */
10931123
auto operator<=>(Javadoc const& other) const noexcept {
1094-
if (auto const cmp = blocks_.size() <=> other.blocks_.size();
1124+
if (auto const cmp = blocks.size() <=> other.blocks.size();
10951125
!std::is_eq(cmp))
10961126
{
10971127
return cmp;
10981128
}
1099-
for (std::size_t i = 0; i < blocks_.size(); ++i)
1129+
for (std::size_t i = 0; i < blocks.size(); ++i)
11001130
{
1101-
if (auto cmp = CompareDerived(blocks_[i], other.blocks_[i]);
1131+
if (auto cmp = CompareDerived(blocks[i], other.blocks[i]);
11021132
!std::is_eq(cmp))
11031133
{
11041134
return cmp;
@@ -1110,22 +1140,6 @@ struct MRDOCS_DECL
11101140
bool operator!=(Javadoc const&) const noexcept;
11111141
/* @} */
11121142

1113-
/** Return an overview of the javadoc.
1114-
1115-
The Javadoc is stored as a list of blocks,
1116-
in the order of appearance in the corresponding
1117-
source code. This function separates elements
1118-
according to their semantic content and returns
1119-
the result as a set of collated lists and
1120-
individual elements.
1121-
1122-
Ownership of the nodes is not transferred;
1123-
the returend overview is invalidated if the
1124-
javadoc object is destroyed.
1125-
*/
1126-
doc::Overview
1127-
makeOverview(const Corpus& corpus) const;
1128-
11291143
//--------------------------------------------
11301144

11311145
/** Attempt to append a block.

include/mrdocs/Support/Concepts.hpp

+7
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ concept polymorphic_storage_for = requires(T const& t)
3838
{ t.operator->() } -> std::convertible_to<Base const*>;
3939
};
4040

41+
template <class T>
42+
concept dereferenceable = requires(T const& t)
43+
{
44+
{ static_cast<bool>(t) };
45+
{ *t };
46+
};
47+
4148
} // namespace clang::mrdocs
4249

4350

include/mrdocs/Support/ScopeExit.hpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,9 @@ class ScopeExitRestore {
4949
: prev_(ref), ref_(ref)
5050
{}
5151

52+
template <std::convertible_to<T> T2>
5253
explicit
53-
ScopeExitRestore(T& ref, T next)
54+
ScopeExitRestore(T& ref, T2 next)
5455
: prev_(ref), ref_(ref)
5556
{
5657
ref_ = next;
@@ -72,8 +73,8 @@ class ScopeExitRestore {
7273
template <class T>
7374
ScopeExitRestore(T&) -> ScopeExitRestore<T>;
7475

75-
template <class T>
76-
ScopeExitRestore(T&, T) -> ScopeExitRestore<T>;
76+
template <class T, std::convertible_to<T> T2>
77+
ScopeExitRestore(T&, T2) -> ScopeExitRestore<T>;
7778

7879
}
7980

share/mrdocs/addons/generator/adoc/partials/symbol.adoc.hbs

+13-1
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@
9999
{{#each symbol.doc.exceptions}}
100100
| `{{exception}}`
101101
| {{{description}}}
102+
102103
{{/each}}
103104
|===
104105

@@ -114,6 +115,7 @@
114115
{{#each allExceptions as |exception|}}
115116
| `{{exception.exception}}`
116117
| {{{exception.description}}}
118+
117119
{{/each}}
118120
|===
119121

@@ -124,7 +126,13 @@
124126
{{#if symbol.doc.returns}}
125127
{{#> markup/dynamic-level-h }}Return Value{{/markup/dynamic-level-h}}
126128

127-
{{{symbol.doc.returns}}}
129+
{{#if (eq (size symbol.doc.returns) 1)}}
130+
{{{symbol.doc.returns.[0]}}}
131+
{{else}}
132+
{{#each symbol.doc.returns}}
133+
* {{{.}}}
134+
{{/each}}
135+
{{/if}}
128136

129137
{{/if}}
130138
{{! Template Parameters }}
@@ -138,6 +146,7 @@
138146
{{#each symbol.doc.tparams}}
139147
| *{{name}}*
140148
| {{{description}}}
149+
141150
{{/each}}
142151
|===
143152

@@ -153,6 +162,7 @@
153162
{{#each allTParams as |param|}}
154163
| *{{param.name}}*
155164
| {{{param.description}}}
165+
156166
{{/each}}
157167
|===
158168

@@ -170,6 +180,7 @@
170180
{{#each symbol.doc.params}}
171181
| *{{name}}*{{#if direction}} [{{direction}}]{{/if}}
172182
| {{{description}}}
183+
173184
{{/each}}
174185
|===
175186

@@ -185,6 +196,7 @@
185196
{{#each allParams as |param|}}
186197
| *{{param.name}}*
187198
| {{{param.description}}}
199+
188200
{{/each}}
189201
|===
190202

share/mrdocs/addons/generator/html/partials/symbol.html.hbs

+9-1
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,15 @@
167167
{{#if symbol.doc.returns}}
168168
<div>
169169
{{#> markup/dynamic-level-h level=2 }}Return Value{{/markup/dynamic-level-h}}
170-
{{{symbol.doc.returns}}}
170+
{{#if (eq (size symbol.doc.returns) 1)}}
171+
{{{symbol.doc.returns.[0]}}}
172+
{{else}}
173+
<ul>
174+
{{#each symbol.doc.returns}}
175+
<li>{{{.}}}</li>
176+
{{/each}}
177+
</ul>
178+
{{/if}}
171179
</div>
172180
{{/if}}
173181
{{! Template Parameters }}

0 commit comments

Comments
 (0)