Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: rendering of symbols in 'special' namespaces #695

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions include/mrdocs/Metadata/Info.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ struct MRDOCS_VISIBLE
*/
bool Implicit = false;

bool ImplementationDefined = false;

bool SeeBelow = false;

/** Ordered list of parent namespaces.
*/
std::vector<SymbolID> Namespace;
Expand Down
Original file line number Diff line number Diff line change
@@ -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~}}
Original file line number Diff line number Diff line change
@@ -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}}
16 changes: 16 additions & 0 deletions src/lib/AST/ASTVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2009,6 +2009,8 @@ class ASTVisitor
NamespaceInfo>(ParentID);
buildNamespace(P, created, cast<NamespaceDecl>(PD));
emplaceChild(P, I);
I.ImplementationDefined |= P.ImplementationDefined;
I.SeeBelow |= P.SeeBelow;
break;
}
// special case for an explicit specializations of
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -2704,6 +2711,7 @@ class ASTVisitor

auto [I, created] = getOrCreateInfo<MrDocsType_t<DeclType>>(id);
I.Access = convertToAccessKind(access);

return std::make_pair(std::ref(I), created);
}

Expand Down Expand Up @@ -2930,6 +2938,12 @@ class ASTVisitor
{
if(! D || Patterns.empty())
return false;
if(const auto* ND = dyn_cast<NamespaceDecl>(D))
{
for(const auto& Pattern : Patterns)
if(Pattern.matches(ND->getQualifiedNameAsString()))
return true;
}
const DeclContext* DC = isa<DeclContext>(D) ?
dyn_cast<DeclContext>(D) : D->getDeclContext();
for(; DC; DC = DC->getParent())
Expand Down Expand Up @@ -2967,6 +2981,7 @@ class ASTVisitor
const NestedNameSpecifier* NNS,
const Decl* D)
{
#if 0
if(isInSpecialNamespace(NNS, config_->seeBelowFilter) ||
isInSpecialNamespace(D, config_->seeBelowFilter))
{
Expand All @@ -2982,6 +2997,7 @@ class ASTVisitor
I->Name = "implementation-defined";
return true;
}
#endif
return false;
}

Expand Down
2 changes: 2 additions & 0 deletions src/lib/Metadata/DomMetadata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,8 @@ DomInfo<T>::construct() const
{ "kind", toString(I_.Kind) },
{ "access", toString(I_.Access) },
{ "implicit", I_.Implicit },
{ "implementationDefined", I_.ImplementationDefined },
{ "seeBelow", I_.SeeBelow },
{ "namespace", dom::newArray<DomSymbolArray>(
I_.Namespace, domCorpus_) },
{ "doc", domCreate(I_.javadoc, domCorpus_) }
Expand Down
2 changes: 2 additions & 0 deletions src/lib/Metadata/Reduce.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading