Skip to content

Commit 7e99c39

Browse files
committed
extract-private-virtual option
#feat
1 parent e5f0bd3 commit 7e99c39

13 files changed

+398
-2
lines changed

docs/mrdocs.schema.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,16 @@
121121
"title": "Extraction policy for private base classes",
122122
"type": "boolean"
123123
},
124+
"extract-private-virtual": {
125+
"default": false,
126+
"description": "Determine whether private virtual methods of a class should be extracted",
127+
"enum": [
128+
true,
129+
false
130+
],
131+
"title": "Extraction policy for private virtual methods of a class",
132+
"type": "boolean"
133+
},
124134
"file-patterns": {
125135
"default": [
126136
"*.hpp",

src/lib/AST/ASTVisitor.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2703,12 +2703,20 @@ bool
27032703
ASTVisitor::
27042704
checkTypeFilters(Decl const* D, AccessSpecifier const access)
27052705
{
2706-
if (!config_->extractPrivate)
2706+
if (access == AS_private)
27072707
{
2708-
MRDOCS_CHECK_OR(access != AccessSpecifier::AS_private, false);
2708+
// Don't extract private members
2709+
if (isa<CXXMethodDecl>(D) &&
2710+
dyn_cast<CXXMethodDecl>(D)->isVirtual())
2711+
{
2712+
// Don't extract private virtual members
2713+
return config_->extractPrivateVirtual || config_->extractPrivate;
2714+
}
2715+
return config_->extractPrivate;
27092716
}
27102717
if (!config_->extractAnonymousNamespaces)
27112718
{
2719+
// Don't extract anonymous namespaces
27122720
MRDOCS_CHECK_OR(
27132721
!isa<NamespaceDecl>(D) ||
27142722
!dyn_cast<NamespaceDecl>(D)->isAnonymousNamespace(),

src/lib/Lib/ConfigOptions.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,13 @@
192192
"type": "bool",
193193
"default": false
194194
},
195+
{
196+
"name": "extract-private-virtual",
197+
"brief": "Extraction policy for private virtual methods of a class",
198+
"details": "Determine whether private virtual methods of a class should be extracted",
199+
"type": "bool",
200+
"default": false
201+
},
195202
{
196203
"name": "extract-private-bases",
197204
"brief": "Extraction policy for private base classes",
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
= Reference
2+
:mrdocs:
3+
4+
[#index]
5+
== Global namespace
6+
7+
8+
=== Types
9+
10+
[cols=1]
11+
|===
12+
| Name
13+
14+
| <<A,`A`>>
15+
|===
16+
17+
[#A]
18+
== A
19+
20+
21+
=== Synopsis
22+
23+
24+
Declared in `&lt;extract&hyphen;private&hyphen;virtual&period;cpp&gt;`
25+
26+
[source,cpp,subs="verbatim,replacements,macros,-callouts"]
27+
----
28+
class A;
29+
----
30+
31+
=== Member Functions
32+
33+
[cols=1]
34+
|===
35+
| Name
36+
37+
| <<A-f,`f`>> [.small]#[virtual]#
38+
|===
39+
40+
41+
=== Private Member Functions
42+
43+
[cols=1]
44+
|===
45+
| Name
46+
47+
| <<A-g,`g`>> [.small]#[virtual]#
48+
|===
49+
50+
[#A-f]
51+
== <<A,A>>::f
52+
53+
54+
=== Synopsis
55+
56+
57+
Declared in `&lt;extract&hyphen;private&hyphen;virtual&period;cpp&gt;`
58+
59+
[source,cpp,subs="verbatim,replacements,macros,-callouts"]
60+
----
61+
virtual
62+
void
63+
f();
64+
----
65+
66+
[#A-g]
67+
== <<A,A>>::g
68+
69+
70+
=== Synopsis
71+
72+
73+
Declared in `&lt;extract&hyphen;private&hyphen;virtual&period;cpp&gt;`
74+
75+
[source,cpp,subs="verbatim,replacements,macros,-callouts"]
76+
----
77+
virtual
78+
void
79+
g();
80+
----
81+
82+
83+
84+
[.small]#Created with https://www.mrdocs.com[MrDocs]#
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
class A {
2+
public:
3+
virtual void f() {}
4+
private:
5+
virtual void g() {}
6+
};
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
<html lang="en">
2+
<head>
3+
<title>Reference</title>
4+
</head>
5+
<body>
6+
<div>
7+
<h1>Reference</h1>
8+
<div>
9+
<div>
10+
<h2 id="index">Global namespace</h2>
11+
</div>
12+
<h2>Types</h2>
13+
<table style="table-layout: fixed; width: 100%;">
14+
<thead>
15+
<tr>
16+
<th>Name</th>
17+
</tr>
18+
</thead>
19+
<tbody>
20+
<tr>
21+
<td><a href="#A"><code>A</code></a> </td></tr>
22+
</tbody>
23+
</table>
24+
</div>
25+
<div>
26+
<div>
27+
<h2 id="A">A</h2>
28+
</div>
29+
<div>
30+
<h3>Synopsis</h3>
31+
<div>
32+
Declared in <code>&lt;extract-private-virtual.cpp&gt;</code></div>
33+
<pre>
34+
<code class="source-code cpp">
35+
class A;
36+
</code>
37+
</pre>
38+
</div>
39+
<h2>Member Functions</h2>
40+
<table style="table-layout: fixed; width: 100%;">
41+
<thead>
42+
<tr>
43+
<th>Name</th>
44+
</tr>
45+
</thead>
46+
<tbody>
47+
<tr>
48+
<td><a href="#A-f"><code>f</code></a> <span class="small">[virtual]</span></td></tr>
49+
</tbody>
50+
</table>
51+
52+
53+
<h2>Private Member Functions</h2>
54+
<table style="table-layout: fixed; width: 100%;">
55+
<thead>
56+
<tr>
57+
<th>Name</th>
58+
</tr>
59+
</thead>
60+
<tbody>
61+
<tr>
62+
<td><a href="#A-g"><code>g</code></a> <span class="small">[virtual]</span></td></tr>
63+
</tbody>
64+
</table>
65+
</div>
66+
<div>
67+
<div>
68+
<h2 id="A-f"><a href="#A">A</a>::f</h2>
69+
</div>
70+
<div>
71+
<h3>Synopsis</h3>
72+
<div>
73+
Declared in <code>&lt;extract-private-virtual.cpp&gt;</code></div>
74+
<pre>
75+
<code class="source-code cpp">
76+
virtual
77+
void
78+
f();
79+
</code>
80+
</pre>
81+
</div>
82+
</div>
83+
<div>
84+
<div>
85+
<h2 id="A-g"><a href="#A">A</a>::g</h2>
86+
</div>
87+
<div>
88+
<h3>Synopsis</h3>
89+
<div>
90+
Declared in <code>&lt;extract-private-virtual.cpp&gt;</code></div>
91+
<pre>
92+
<code class="source-code cpp">
93+
virtual
94+
void
95+
g();
96+
</code>
97+
</pre>
98+
</div>
99+
</div>
100+
101+
</div>
102+
<div>
103+
<h4>Created with <a href="https://www.mrdocs.com">MrDocs</a></h4>
104+
</div>
105+
</body>
106+
</html>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<mrdocs xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="https://github.com/cppalliance/mrdocs/raw/develop/mrdocs.rnc">
4+
<namespace id="//////////////////////////8=">
5+
<class name="A" id="YrPSaKAbmXgzCAX5WByx4eVoqBM=">
6+
<file short-path="extract-private-virtual.cpp" source-path="extract-private-virtual.cpp" line="1" class="def"/>
7+
<function name="f" id="hLXvGC+nOrLQRH9lODKkgi/oUas=">
8+
<file short-path="extract-private-virtual.cpp" source-path="extract-private-virtual.cpp" line="3" class="def"/>
9+
<attr id="is-virtual-as-written"/>
10+
</function>
11+
<function name="g" access="private" id="IWP5ktgJAZgjufMQ6EE1eb6mm9g=">
12+
<file short-path="extract-private-virtual.cpp" source-path="extract-private-virtual.cpp" line="5" class="def"/>
13+
<attr id="is-virtual-as-written"/>
14+
</function>
15+
</class>
16+
</namespace>
17+
</mrdocs>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
extract-private-virtual: true
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
= Reference
2+
:mrdocs:
3+
4+
[#index]
5+
== Global namespace
6+
7+
8+
=== Types
9+
10+
[cols=1]
11+
|===
12+
| Name
13+
14+
| <<A,`A`>>
15+
|===
16+
17+
[#A]
18+
== A
19+
20+
21+
=== Synopsis
22+
23+
24+
Declared in `&lt;no&hyphen;extract&hyphen;private&hyphen;virtual&period;cpp&gt;`
25+
26+
[source,cpp,subs="verbatim,replacements,macros,-callouts"]
27+
----
28+
class A;
29+
----
30+
31+
=== Member Functions
32+
33+
[cols=1]
34+
|===
35+
| Name
36+
37+
| <<A-f,`f`>> [.small]#[virtual]#
38+
|===
39+
40+
41+
42+
[#A-f]
43+
== <<A,A>>::f
44+
45+
46+
=== Synopsis
47+
48+
49+
Declared in `&lt;no&hyphen;extract&hyphen;private&hyphen;virtual&period;cpp&gt;`
50+
51+
[source,cpp,subs="verbatim,replacements,macros,-callouts"]
52+
----
53+
virtual
54+
void
55+
f();
56+
----
57+
58+
59+
60+
[.small]#Created with https://www.mrdocs.com[MrDocs]#
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
class A {
2+
public:
3+
virtual void f() {}
4+
private:
5+
virtual void g() {}
6+
};

0 commit comments

Comments
 (0)