Skip to content

Commit 11df305

Browse files
committed
Namespace using directive is name
This allows using directives to dependencies. #improvement
1 parent d448757 commit 11df305

File tree

19 files changed

+144
-59
lines changed

19 files changed

+144
-59
lines changed

include/mrdocs/Metadata/Info.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,12 +273,13 @@ tag_invoke(
273273
DomCorpus const* domCorpus)
274274
{
275275
MRDOCS_ASSERT(domCorpus);
276+
io.map("class", std::string("symbol"));
277+
io.map("kind", I.Kind);
276278
io.map("id", I.id);
277279
if (!I.Name.empty())
278280
{
279281
io.map("name", I.Name);
280282
}
281-
io.map("kind", I.Kind);
282283
io.map("access", I.Access);
283284
io.map("extraction", I.Extraction);
284285
io.map("isRegular", I.Extraction == ExtractionMode::Regular);

include/mrdocs/Metadata/Info/Function.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ tag_invoke(
235235
{
236236
io.map("refQualifier", I.RefQualifier);
237237
}
238-
io.map("class", I.Class);
238+
io.map("functionClass", I.Class);
239239
io.map("params", dom::LazyArray(I.Params, domCorpus));
240240
io.map("return", I.ReturnType);
241241
io.map("template", I.Template);

include/mrdocs/Metadata/Info/Namespace.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#define MRDOCS_API_METADATA_NAMESPACE_HPP
1414

1515
#include <mrdocs/Metadata/Info.hpp>
16+
#include <mrdocs/Metadata/Name.hpp>
1617
#include <mrdocs/Dom/LazyArray.hpp>
1718
#include <vector>
1819
#include <ranges>
@@ -110,7 +111,7 @@ struct NamespaceInfo final
110111

111112
/** Namespaces nominated by using-directives.
112113
*/
113-
std::vector<SymbolID> UsingDirectives;
114+
std::vector<NameInfo> UsingDirectives;
114115

115116
/** The members of this namespace.
116117
*/
@@ -121,7 +122,8 @@ struct NamespaceInfo final
121122
{
122123
}
123124

124-
auto operator<=>(NamespaceInfo const&) const = default;
125+
std::strong_ordering
126+
operator<=>(NamespaceInfo const&) const;
125127
};
126128

127129
MRDOCS_DECL

include/mrdocs/Metadata/Info/Using.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ tag_invoke(
9393
DomCorpus const* domCorpus)
9494
{
9595
tag_invoke(t, io, dynamic_cast<Info const&>(I), domCorpus);
96-
io.map("class", I.Class);
96+
io.map("usingClass", I.Class);
9797
io.map("shadows", dom::LazyArray(I.UsingSymbols, domCorpus));
9898
io.map("qualifier", I.Qualifier);
9999
}

include/mrdocs/Metadata/Name.hpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,9 @@
1313
#define MRDOCS_API_METADATA_NAME_HPP
1414

1515
#include <mrdocs/Platform.hpp>
16-
#include <mrdocs/Metadata/Info.hpp>
1716
#include <mrdocs/Metadata/Type.hpp>
1817
#include <mrdocs/Metadata/Template.hpp>
19-
#include <memory>
18+
#include <mrdocs/Support/Visitor.hpp>
2019

2120
namespace clang::mrdocs {
2221

@@ -100,6 +99,12 @@ struct NameInfo
10099

101100
std::strong_ordering
102101
operator<=>(NameInfo const& other) const;
102+
103+
bool
104+
operator==(NameInfo const& other) const
105+
{
106+
return std::is_eq(*this <=> other);
107+
}
103108
};
104109

105110
/** Represents a (possibly qualified) symbol name with template arguments.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
{{/if}}
6767
{{! Using directives }}
6868
{{#if symbol.usingDirectives}}
69-
{{>symbol/members-table members=symbol.usingDirectives title="Using Directives"}}
69+
{{>symbol/members-table members=symbol.usingDirectives title="Using Namespace Directives"}}
7070

7171
{{/if}}
7272
{{! Related symbols }}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{{#>markup/table cols=(select includeBrief 2 1)}}
2+
{{#>markup/thead}}
3+
{{#>markup/tr~}}
4+
{{#>markup/th}}Name{{/markup/th}}
5+
{{#if includeBrief}}
6+
{{#>markup/th}}Description{{/markup/th}}
7+
{{/if}}
8+
{{/markup/tr}}
9+
{{/markup/thead}}
10+
{{#>markup/tbody}}
11+
{{#if isName}}
12+
{{#each members}}
13+
{{> symbol/detail/members-table-row . includeBrief=false isName=true}}
14+
{{/each}}
15+
{{ else }}
16+
{{#each (filter_by members "isRegular" "isSeeBelow")}}
17+
{{> symbol/detail/members-table-row . includeBrief=../includeBrief isName=false}}
18+
{{/each}}
19+
{{/if}}
20+
{{/markup/tbody}}
21+
{{/markup/table}}
Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
{{! Helper for "info-list": renders a symbol as a row in a table of members }}
2-
{{#>markup/tr~}}
3-
{{#>markup/td}}
4-
{{! Member name, linked to its documentation }}
5-
{{#>markup/a href=url}}{{#>markup/code}}{{>symbol/name . nolink=true}}{{/markup/code}}{{/markup/a}} {{>symbol/special-function-suffix .}}
6-
{{~/markup/td}}
7-
{{#if (eq includeBrief true)}}
2+
{{#>markup/tr}}
83
{{#>markup/td~}}
9-
{{{~doc.brief}}}
10-
{{/markup/td~}}
4+
{{~#if isName~}}
5+
{{~#if symbol.url~}}
6+
{{~#>markup/a href=symbol.url}}{{#>markup/code}}{{> symbol/name-info . nolink=true}}{{/markup/code}}{{/markup/a~}}
7+
{{~else~}}
8+
{{~> symbol/name-info . nolink=true~}}
9+
{{~/if~}}
10+
{{~else~}}
11+
{{~#>markup/a href=url}}{{#>markup/code}}{{>symbol/name . nolink=true}}{{/markup/code}}{{/markup/a}} {{>symbol/special-function-suffix .~}}
12+
{{~/if~}}
13+
{{~/markup/td}}
14+
{{#if includeBrief~}}
15+
{{~#>markup/td~}}
16+
{{{~doc.brief~}}}
17+
{{~/markup/td}}
1118
{{/if}}
12-
{{~/markup/tr}}
19+
20+
{{/markup/tr}}

share/mrdocs/addons/generator/common/partials/symbol/members-table.hbs

Lines changed: 8 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,41 +4,19 @@
44
This partials renders each row with the symbol name and brief for
55
each member.
66
7-
Expected Context: {Symbol Object}
7+
Expected Context: {Symbol|NameInfo}[]
8+
9+
Parameters:
10+
members: An array of symbols or nameinfo to render.
811
912
Example:
1013
{{> symbol/members-table symbol }}
1114
1215
See: https://mrdocs.com/docs/mrdocs/develop/generators.html#dom_reference
1316
--}}
14-
{{#if (any_of_by members "isRegular" "isSeeBelow")}}
17+
{{#if members}}
18+
{{#if (or (eq members[0].class "name") (any_of_by members "isRegular" "isSeeBelow"))}}
1519
{{#>markup/h level=(select @root.config.multipage 1 2)}}{{title}}{{/markup/h}}
16-
{{#if (any_of_by members "doc")}}
17-
{{#>markup/table cols=2}}
18-
{{#>markup/thead}}
19-
{{#>markup/tr~}}
20-
{{#>markup/th}}Name{{/markup/th~}}
21-
{{#>markup/th}}Description{{/markup/th}}
22-
{{/markup/tr}}
23-
{{/markup/thead}}
24-
{{#>markup/tbody}}
25-
{{#each (filter_by members "isRegular" "isSeeBelow")}}
26-
{{> symbol/detail/members-table-row . includeBrief=true}}
27-
{{/each}}
28-
{{/markup/tbody}}
29-
{{/markup/table}}
30-
{{else}}
31-
{{#>markup/table cols=1}}
32-
{{#>markup/thead}}
33-
{{#>markup/tr~}}
34-
{{#>markup/th}}Name{{/markup/th}}
35-
{{/markup/tr}}
36-
{{/markup/thead}}
37-
{{#>markup/tbody}}
38-
{{#each (filter_by members "isRegular" "isSeeBelow")}}
39-
{{> symbol/detail/members-table-row . includeBrief=false}}
40-
{{/each}}
41-
{{/markup/tbody}}
42-
{{/markup/table}}
43-
{{/if}}
20+
{{>symbol/detail/members-table-impl members=members isName=(eq members[0].class "name") includeBrief=(select (any_of_by members "doc") true false) title=title}}
4421
{{/if}}
22+
{{/if}}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
1616
See: https://mrdocs.com/docs/mrdocs/develop/generators.html#dom_reference
1717
--}}
18-
{{#if (and (eq kind "function") (eq class "conversion"))~}}
18+
{{#if (and (eq kind "function") (eq functionClass "conversion"))~}}
1919
{{! Conversion operator: "operator" and the type declarator ~}}
2020
operator {{>type/declarator return nolink=nolink~}}
2121
{{else if (eq kind "guide")~}}

0 commit comments

Comments
 (0)