Skip to content

Commit e5f0bd3

Browse files
committed
option name is extract-anonymous-namespaces
#refactor
1 parent f6686c0 commit e5f0bd3

File tree

3 files changed

+18
-29
lines changed

3 files changed

+18
-29
lines changed

docs/mrdocs.schema.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,6 @@
77
"title": "Path to the Addons directory",
88
"type": "string"
99
},
10-
"anonymous-namespaces": {
11-
"default": true,
12-
"description": "Determine whether symbols in anonymous namespaces should be extracted. When set to `always`, symbols in anonymous namespaces are always extracted. When set to `dependency`, symbols in anonymous namespaces are extracted only if they are referenced by the source code. When set to `never`, symbols in anonymous namespaces are never extracted.",
13-
"enum": [
14-
true,
15-
false
16-
],
17-
"title": "Extraction policy for anonymous namespaces",
18-
"type": "boolean"
19-
},
2010
"auto-brief": {
2111
"default": true,
2212
"description": "When set to `true`, MrDocs uses the first line (until the first dot, question mark, or exclamation mark) of the comment as the brief of the symbol. When set to `false`, a explicit @brief command is required.",
@@ -101,6 +91,16 @@
10191
"title": "Extract all symbols",
10292
"type": "boolean"
10393
},
94+
"extract-anonymous-namespaces": {
95+
"default": true,
96+
"description": "Determine whether symbols in anonymous namespaces should be extracted. When set to `always`, symbols in anonymous namespaces are always extracted. When set to `dependency`, symbols in anonymous namespaces are extracted only if they are referenced by the source code. When set to `never`, symbols in anonymous namespaces are never extracted.",
97+
"enum": [
98+
true,
99+
false
100+
],
101+
"title": "Extraction policy for anonymous namespaces",
102+
"type": "boolean"
103+
},
104104
"extract-private": {
105105
"default": false,
106106
"description": "Determine whether private class members should be extracted",

src/lib/AST/ASTVisitor.cpp

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2705,34 +2705,23 @@ checkTypeFilters(Decl const* D, AccessSpecifier const access)
27052705
{
27062706
if (!config_->extractPrivate)
27072707
{
2708-
// KRYSTIAN FIXME: this doesn't handle direct
2709-
// dependencies on inaccessible declarations
2708+
MRDOCS_CHECK_OR(access != AccessSpecifier::AS_private, false);
2709+
}
2710+
if (!config_->extractAnonymousNamespaces)
2711+
{
27102712
MRDOCS_CHECK_OR(
2711-
access != AccessSpecifier::AS_private, false);
2713+
!isa<NamespaceDecl>(D) ||
2714+
!dyn_cast<NamespaceDecl>(D)->isAnonymousNamespace(),
2715+
false);
27122716
}
27132717

27142718
// Don't extract anonymous unions
27152719
auto const* RD = dyn_cast<RecordDecl>(D);
27162720
MRDOCS_CHECK_OR(!RD || !RD->isAnonymousStructOrUnion(), false);
27172721

27182722
// Don't extract implicitly generated declarations
2719-
// (except for IndirectFieldDecls)
27202723
MRDOCS_CHECK_OR(!D->isImplicit() || isa<IndirectFieldDecl>(D), false);
27212724

2722-
// Don't extract anonymous namespaces unless configured to do so
2723-
// and the current mode is normal
2724-
if (auto const* ND = dyn_cast<NamespaceDecl>(D);
2725-
ND &&
2726-
ND->isAnonymousNamespace() &&
2727-
config_->anonymousNamespaces)
2728-
{
2729-
// Otherwise, skip extraction if this isn't a dependency
2730-
// KRYSTIAN FIXME: is this correct? a namespace should not
2731-
// be extracted as a dependency (until namespace aliases and
2732-
// using directives are supported)
2733-
MRDOCS_CHECK_OR(mode_ == TraversalMode::Regular, false);
2734-
}
2735-
27362725
return true;
27372726
}
27382727

src/lib/Lib/ConfigOptions.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@
200200
"default": false
201201
},
202202
{
203-
"name": "anonymous-namespaces",
203+
"name": "extract-anonymous-namespaces",
204204
"brief": "Extraction policy for anonymous namespaces",
205205
"details": "Determine whether symbols in anonymous namespaces should be extracted. When set to `always`, symbols in anonymous namespaces are always extracted. When set to `dependency`, symbols in anonymous namespaces are extracted only if they are referenced by the source code. When set to `never`, symbols in anonymous namespaces are never extracted.",
206206
"type": "bool",

0 commit comments

Comments
 (0)