Skip to content

Commit 01403d6

Browse files
committed
docs: Corpus javadocs
1 parent badb9d9 commit 01403d6

File tree

6 files changed

+303
-130
lines changed

6 files changed

+303
-130
lines changed

include/mrdocs/Corpus.hpp

+90-99
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,26 @@ class MRDOCS_VISIBLE
3131
Corpus
3232
{
3333
protected:
34-
3534
explicit
3635
Corpus(
3736
Config const& config_) noexcept
3837
: config(config_)
3938
{
4039
}
40+
public:
41+
/** The iterator type for the index of all symbols.
4142
43+
The iterator is a forward iterator that
44+
iterates over all symbols in the index.
45+
It dereferences to a reference to a
46+
const @ref Info.
4247
48+
The logic for incrementing the iterator is
49+
provided by the Corpus implementation via
50+
a function that retuns the next Info in the
51+
index, or nullptr if there are no more.
52+
*/
4353
class iterator;
44-
public:
4554

4655
/** Destructor.
4756
*/
@@ -69,12 +78,6 @@ class MRDOCS_VISIBLE
6978
iterator
7079
end() const noexcept = 0;
7180

72-
/** Return the metadata for the global namespace.
73-
*/
74-
MRDOCS_DECL
75-
NamespaceInfo const&
76-
globalNamespace() const noexcept;
77-
7881
/** Return the Info with the matching ID, or nullptr.
7982
*/
8083
MRDOCS_DECL
@@ -83,6 +86,10 @@ class MRDOCS_VISIBLE
8386
find(SymbolID const& id) const noexcept = 0;
8487

8588
/** Return true if an Info with the specified symbol ID exists.
89+
90+
This function uses the @ref find function to locate
91+
the Info with the specified symbol ID and returns
92+
true if it exists, otherwise false.
8693
*/
8794
bool
8895
exists(
@@ -93,49 +100,92 @@ class MRDOCS_VISIBLE
93100

94101
/** Return the Info with the specified symbol ID.
95102
103+
This function uses the @ref find function to locate
104+
the Info with the specified symbol ID. The result
105+
is converted to the specified type T and returned.
106+
107+
The function @ref exists can be used to determine
108+
if an Info with the specified symbol ID exists.
96109
If the id does not exist, the behavior is undefined.
110+
111+
If the Info is not of type T, the behavior is undefined.
97112
*/
98113
template<class T = Info>
114+
requires std::derived_from<T, Info>
99115
T const&
100116
get(
101117
SymbolID const& id) const noexcept;
102118

103-
//--------------------------------------------
119+
/** Return the metadata for the global namespace.
104120
105-
// KRYSTIAN FIXME: this could just be a single
106-
// overload constrained with std::derived_from<ScopeInfo>
107-
template<class F, class... Args>
108-
void traverse(
109-
NamespaceInfo const& I,
110-
F&& f, Args&&... args) const;
111-
112-
template<class F, class... Args>
113-
void traverse(
114-
RecordInfo const& I,
115-
F&& f, Args&&... args) const;
116-
117-
template<class F, class... Args>
118-
void traverse(
119-
EnumInfo const& I,
120-
F&& f, Args&&... args) const;
121-
122-
template<class F, class... Args>
123-
void traverse(
124-
SpecializationInfo const& I,
125-
F&& f, Args&&... args) const;
126-
127-
template<class F, class... Args>
128-
void traverse(
129-
OverloadSet const& OS,
130-
F&& f, Args&&... args) const;
131-
132-
template<class F, class... Args>
121+
This function is equivalent to calling
122+
@ref get with the symbol ID for the
123+
global namespace.
124+
*/
125+
MRDOCS_DECL
126+
NamespaceInfo const&
127+
globalNamespace() const noexcept;
128+
129+
/** Visit the members of specified Info.
130+
131+
This function invokes the specified function `f`
132+
for each member of the specified Info `I`.
133+
134+
For each member of `I`, the function will invoke
135+
the function object `fn` with a type derived from
136+
`Info` as the first argument, followed by `args...`.
137+
138+
The type of the first argument is determined
139+
by the `InfoKind` of the `Info` object.
140+
141+
@param info The Info to visit.
142+
@param f The function to invoke.
143+
@param args The arguments to pass to the function.
144+
*/
145+
template <InfoParent T, class F, class... Args>
146+
void
147+
traverse(
148+
T const& I, F&& f, Args&&... args) const
149+
{
150+
for (auto const& id : I.Members)
151+
{
152+
visit(get(id), std::forward<F>(f),
153+
std::forward<Args>(args)...);
154+
}
155+
}
156+
157+
/** Visit the function members of specified Info.
158+
159+
This function iterates the members of the specified
160+
ScopeInfo `S`. For each member associated with a
161+
function with the same name as the member, the
162+
function object `f` is invoked with the member
163+
as the first argument, followed by `args...`.
164+
165+
When there are more than one member function
166+
with the same name, the function object `f` is
167+
invoked with an @ref OverloadSet as the first
168+
argument, followed by `args...`.
169+
*/
170+
template <class F, class... Args>
133171
void traverseOverloads(
134172
ScopeInfo const& S,
135-
F&& f, Args&&... args) const;
173+
F&& f,
174+
Args&&... args) const;
136175

137176
//--------------------------------------------
138177

178+
/** Return the fully qualified name of the specified Info.
179+
180+
This function returns the fully qualified name
181+
of the specified Info `I` as a string.
182+
183+
The `Info` parents are traversed to construct
184+
the fully qualified name which is stored in
185+
the string `temp`.
186+
187+
@return A reference to the string `temp`.
188+
*/
139189
// KRYSTIAN NOTE: temporary
140190
MRDOCS_DECL
141191
std::string&
@@ -147,6 +197,7 @@ class MRDOCS_VISIBLE
147197
//------------------------------------------------
148198

149199
template<class T>
200+
requires std::derived_from<T, Info>
150201
T const&
151202
Corpus::
152203
get(
@@ -166,67 +217,7 @@ get(
166217
}
167218
}
168219

169-
template<class F, class... Args>
170-
void
171-
Corpus::
172-
traverse(
173-
NamespaceInfo const& I,
174-
F&& f, Args&&... args) const
175-
{
176-
for(auto const& id : I.Members)
177-
visit(get(id), std::forward<F>(f),
178-
std::forward<Args>(args)...);
179-
}
180-
181-
template<class F, class... Args>
182-
void
183-
Corpus::
184-
traverse(
185-
RecordInfo const& I,
186-
F&& f, Args&&... args) const
187-
{
188-
for(auto const& id : I.Members)
189-
visit(get(id), std::forward<F>(f),
190-
std::forward<Args>(args)...);
191-
}
192-
193-
template<class F, class... Args>
194-
void
195-
Corpus::
196-
traverse(
197-
EnumInfo const& I,
198-
F&& f, Args&&... args) const
199-
{
200-
for(auto const& id : I.Members)
201-
visit(get(id), std::forward<F>(f),
202-
std::forward<Args>(args)...);
203-
}
204-
205-
template<class F, class... Args>
206-
void
207-
Corpus::
208-
traverse(
209-
SpecializationInfo const& I,
210-
F&& f, Args&&... args) const
211-
{
212-
for(auto const& id : I.Members)
213-
visit(get(id), std::forward<F>(f),
214-
std::forward<Args>(args)...);
215-
}
216-
217-
template<class F, class... Args>
218-
void
219-
Corpus::
220-
traverse(
221-
OverloadSet const& OS,
222-
F&& f, Args&&... args) const
223-
{
224-
for(auto const& id : OS.Members)
225-
visit(get(id), std::forward<F>(f),
226-
std::forward<Args>(args)...);
227-
}
228-
229-
template<class F, class... Args>
220+
template <class F, class... Args>
230221
void
231222
Corpus::
232223
traverseOverloads(

0 commit comments

Comments
 (0)