From bce0c4714e686717b8bd197c58f5b9868954abd9 Mon Sep 17 00:00:00 2001 From: Krystian Stasiowski Date: Wed, 9 Oct 2024 14:53:20 -0400 Subject: [PATCH] fix: rendering of symbols in 'special' namespaces --- include/mrdocs/Metadata/Info.hpp | 4 ++++ .../asciidoc/partials/name-info.adoc.hbs | 6 ++++-- .../partials/nested-name-specifier.adoc.hbs | 6 ++++-- src/lib/AST/ASTVisitor.cpp | 16 ++++++++++++++++ src/lib/Metadata/DomMetadata.cpp | 2 ++ src/lib/Metadata/Reduce.cpp | 2 ++ 6 files changed, 32 insertions(+), 4 deletions(-) diff --git a/include/mrdocs/Metadata/Info.hpp b/include/mrdocs/Metadata/Info.hpp index a66388572..1a45bf1d0 100644 --- a/include/mrdocs/Metadata/Info.hpp +++ b/include/mrdocs/Metadata/Info.hpp @@ -88,6 +88,10 @@ struct MRDOCS_VISIBLE */ bool Implicit = false; + bool ImplementationDefined = false; + + bool SeeBelow = false; + /** Ordered list of parent namespaces. */ std::vector Namespace; diff --git a/share/mrdocs/addons/generator/asciidoc/partials/name-info.adoc.hbs b/share/mrdocs/addons/generator/asciidoc/partials/name-info.adoc.hbs index d53ea191f..ecbdc2f12 100644 --- a/share/mrdocs/addons/generator/asciidoc/partials/name-info.adoc.hbs +++ b/share/mrdocs/addons/generator/asciidoc/partials/name-info.adoc.hbs @@ -1,6 +1,8 @@ {{#if prefix~}} -{{>name-info prefix nolink=nolink~}}:: +{{#if symbol.implementationDefined}}pass:q[_implementation-defined_]:: +{{~else if symbol.seeBelow}}pass:q[_see-below_]:: +{{~else}}{{>name-info prefix nolink=nolink~}}:: {{~/if~}} -{{#if (or (eq name "see-below") (eq name "implementation-defined"))~}}pass:q[_{{name}}_]{{else~}} +{{/if~}} {{#if (and symbol.ref (not nolink))}}xref:{{symbol.ref}}[{{name}}]{{else~}} {{name}}{{/if}}{{#if args}}{{>template-args args=args nolink=nolink}}{{/if~}}{{/if~}}{{/if~}} \ No newline at end of file diff --git a/share/mrdocs/addons/generator/asciidoc/partials/nested-name-specifier.adoc.hbs b/share/mrdocs/addons/generator/asciidoc/partials/nested-name-specifier.adoc.hbs index 907388c77..3ed5ab637 100644 --- a/share/mrdocs/addons/generator/asciidoc/partials/nested-name-specifier.adoc.hbs +++ b/share/mrdocs/addons/generator/asciidoc/partials/nested-name-specifier.adoc.hbs @@ -1,9 +1,11 @@ {{#if (and symbol (or includeNamespace (ne symbol.kind "namespace")))~}} +{{#if symbol.implementationDefined}}pass:q[_implementation-defined_]:: +{{~else if symbol.seeBelow}}pass:q[_see-below_]:: +{{~else~}} {{#if symbol.parent~}} {{>nested-name-specifier symbol=symbol.parent~}} {{else~}} {{/if~}} -{{!-- {{#if symbol.name}}xref:{{symbol.ref}}[{{symbol.name}}]::{{/if~}} --}} -{{!-- {{#if symbol.name}}{{symbol.name}}::{{/if~}} --}} {{#if symbol.name}}{{>declarator-id symbol link=symbol}}::{{/if~}} +{{/if~}} {{/if}} \ No newline at end of file diff --git a/src/lib/AST/ASTVisitor.cpp b/src/lib/AST/ASTVisitor.cpp index 8fdd8196b..809c0eb4e 100644 --- a/src/lib/AST/ASTVisitor.cpp +++ b/src/lib/AST/ASTVisitor.cpp @@ -2009,6 +2009,8 @@ class ASTVisitor NamespaceInfo>(ParentID); buildNamespace(P, created, cast(PD)); emplaceChild(P, I); + I.ImplementationDefined |= P.ImplementationDefined; + I.SeeBelow |= P.SeeBelow; break; } // special case for an explicit specializations of @@ -2145,6 +2147,11 @@ class ASTVisitor I.Name = extractName(D); I.specs.isInline = D->isInline(); + I.ImplementationDefined = + isInSpecialNamespace(D, config_->implementationDefinedFilter); + I.SeeBelow = + isInSpecialNamespace(D, config_->seeBelowFilter); + getParentNamespaces(I, D); } @@ -2704,6 +2711,7 @@ class ASTVisitor auto [I, created] = getOrCreateInfo>(id); I.Access = convertToAccessKind(access); + return std::make_pair(std::ref(I), created); } @@ -2930,6 +2938,12 @@ class ASTVisitor { if(! D || Patterns.empty()) return false; + if(const auto* ND = dyn_cast(D)) + { + for(const auto& Pattern : Patterns) + if(Pattern.matches(ND->getQualifiedNameAsString())) + return true; + } const DeclContext* DC = isa(D) ? dyn_cast(D) : D->getDeclContext(); for(; DC; DC = DC->getParent()) @@ -2967,6 +2981,7 @@ class ASTVisitor const NestedNameSpecifier* NNS, const Decl* D) { + #if 0 if(isInSpecialNamespace(NNS, config_->seeBelowFilter) || isInSpecialNamespace(D, config_->seeBelowFilter)) { @@ -2982,6 +2997,7 @@ class ASTVisitor I->Name = "implementation-defined"; return true; } + #endif return false; } diff --git a/src/lib/Metadata/DomMetadata.cpp b/src/lib/Metadata/DomMetadata.cpp index 5a00d2599..acbb2af18 100644 --- a/src/lib/Metadata/DomMetadata.cpp +++ b/src/lib/Metadata/DomMetadata.cpp @@ -717,6 +717,8 @@ DomInfo::construct() const { "kind", toString(I_.Kind) }, { "access", toString(I_.Access) }, { "implicit", I_.Implicit }, + { "implementationDefined", I_.ImplementationDefined }, + { "seeBelow", I_.SeeBelow }, { "namespace", dom::newArray( I_.Namespace, domCorpus_) }, { "doc", domCreate(I_.javadoc, domCorpus_) } diff --git a/src/lib/Metadata/Reduce.cpp b/src/lib/Metadata/Reduce.cpp index 846b137a4..71568157c 100644 --- a/src/lib/Metadata/Reduce.cpp +++ b/src/lib/Metadata/Reduce.cpp @@ -110,6 +110,8 @@ void mergeInfo(Info& I, Info&& Other) if(I.Access == AccessKind::None) I.Access = Other.Access; I.Implicit &= Other.Implicit; + I.ImplementationDefined |= Other.ImplementationDefined; + I.SeeBelow |= Other.SeeBelow; // append javadocs if(! I.javadoc) I.javadoc = std::move(Other.javadoc);