Skip to content

Commit 7d8de21

Browse files
committed
Info parent is not always namespace
#refactor
1 parent 266f49c commit 7d8de21

File tree

21 files changed

+344
-178
lines changed

21 files changed

+344
-178
lines changed

docs/modules/ROOT/pages/generators.adoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,13 +161,13 @@ The `Symbol` object represents a symbol extracted from the source code.The symbo
161161
| `string`
162162
| Whether the symbol was implicitly extracted as a dependency.
163163

164-
| `namespace`
164+
| `parents`
165165
| `<<symbol-fields,Symbol Object[]>>`
166-
| The namespaces of the symbol.
166+
| The parent contexts (namespaces or records) of the symbol.
167167

168168
| `parent`
169169
| `<<symbol-fields,Symbol Object>>`
170-
| The parent namespace of the symbol.
170+
| The parent context (namespace or record) of the symbol.
171171

172172
| `doc`
173173
| `Any`

include/mrdocs/Corpus.hpp

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -247,9 +247,9 @@ traverseOverloads(
247247
for(const SymbolID& id : S.Members)
248248
{
249249
const Info& member = get(id);
250-
const auto& lookup = S.Lookups.at(member.Name);
250+
const auto& members = S.Lookups.at(member.Name);
251251
auto first_func = std::ranges::find_if(
252-
lookup, [this](const SymbolID& elem)
252+
members, [this](const SymbolID& elem)
253253
{
254254
#if 0
255255
const Info& I = get(elem);
@@ -258,19 +258,20 @@ traverseOverloads(
258258
return get(elem).isFunction();
259259
#endif
260260
});
261-
bool const nonOverloadedFunction = lookup.size() == 1;
262-
bool const notFunction = first_func == lookup.end();
263-
if(nonOverloadedFunction ||
264-
notFunction)
261+
bool const nonOverloadedFunction = members.size() == 1;
262+
bool const notFunction = first_func == members.end();
263+
if (nonOverloadedFunction ||
264+
notFunction)
265265
{
266266
visit(member, std::forward<F>(f),
267267
std::forward<Args>(args)...);
268268
}
269-
else if(*first_func == id)
269+
else if (*first_func == id)
270270
{
271-
OverloadSet overloads(member.Name,
272-
member.Namespace.front(),
273-
member.Namespace, lookup);
271+
OverloadSet overloads(
272+
member.Name,
273+
member.Parent,
274+
members);
274275
visit(overloads, std::forward<F>(f),
275276
std::forward<Args>(args)...);
276277
}
@@ -344,6 +345,12 @@ class Corpus::iterator
344345
}
345346
};
346347

348+
/** Return a list of the parent symbols of the specified Info.
349+
*/
350+
MRDOCS_DECL
351+
std::vector<SymbolID>
352+
getParents(Corpus const& C, Info const& I);
353+
347354
} // mrdocs
348355
} // clang
349356

include/mrdocs/Metadata/Info.hpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,12 @@ struct MRDOCS_VISIBLE
100100
*/
101101
bool Implicit = false;
102102

103-
/** Ordered list of parent namespaces.
103+
/** The parent symbol, if any.
104+
105+
This is the parent namespace or record
106+
where the symbol is defined.
104107
*/
105-
std::vector<SymbolID> Namespace;
108+
SymbolID Parent;
106109

107110
/** The extracted javadoc for this declaration.
108111
*/
@@ -225,7 +228,6 @@ tag_invoke(
225228
Info const& I,
226229
DomCorpus const* domCorpus);
227230

228-
229231
} // mrdocs
230232
} // clang
231233

include/mrdocs/Metadata/Overloads.hpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,6 @@ struct OverloadSet
4545
/// The parent symbol ID.
4646
SymbolID Parent;
4747

48-
/// The namespace of the overload set.
49-
std::span<const SymbolID> Namespace;
50-
5148
/// The members of the overload set.
5249
std::span<const SymbolID> Members;
5350

@@ -62,11 +59,9 @@ struct OverloadSet
6259
OverloadSet(
6360
std::string_view name,
6461
const SymbolID& parent,
65-
std::span<const SymbolID> ns,
6662
std::span<const SymbolID> members)
6763
: Name(name)
6864
, Parent(parent)
69-
, Namespace(ns)
7065
, Members(members)
7166
{
7267
}

share/mrdocs/addons/generator/common/partials/symbol/qualified-name.hbs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
{{! We remove whitespace between all tag so the result is in a single line ~}}
2121
{{~#if (ne kind "friend")~}}
2222
{{~#if name~}}
23-
{{! General case: linked namespaces followed by the symbol name ~}}
24-
{{#each (reverse namespace)~}}
23+
{{! General case: linked parent symbols followed by the symbol name ~}}
24+
{{#each parents~}}
2525
{{#if name~}}
2626
{{>symbol/name . link=. nolink=../nolink}}::
2727
{{~/if}}

0 commit comments

Comments
 (0)