Skip to content

Commit b3b6214

Browse files
committed
fix: preserve extraction mode when copying members from derived classes
Fixes #1119
1 parent 2463633 commit b3b6214

File tree

8 files changed

+60
-1
lines changed

8 files changed

+60
-1
lines changed

include/mrdocs/Metadata/Symbol/SymbolBase.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ struct MRDOCS_VISIBLE Symbol {
7171
*/
7272
ExtractionMode Extraction = ExtractionMode::Dependency;
7373

74+
/** Whether this a copy of an inherited method, as produced when
75+
`inherit-base-members` is not `never`.
76+
*/
77+
bool IsCopyFromInherited = false;
78+
7479
/** The parent symbol, if any.
7580
7681
This is the parent namespace or record

src/lib/Metadata/Finalizers/BaseMembersFinalizer.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ inheritBaseMembers(
172172
otherCopy->id = SymbolID::createFromString(
173173
std::format("{}-{}", toBase16Str(otherCopy->Parent),
174174
toBase16Str(otherInfo.id)));
175+
otherCopy->IsCopyFromInherited = true;
175176
derived.push_back(otherCopy->id);
176177
// Get the extraction mode from the derived class
177178
if (otherCopy->Extraction == ExtractionMode::Dependency ||

src/lib/Metadata/Finalizers/DocCommentFinalizer.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1731,7 +1731,8 @@ DocCommentFinalizer::warnUndocumented()
17311731
if (Symbol const* I = corpus_.find(undocI.id))
17321732
{
17331733
MRDOCS_CHECK_OR(
1734-
!I->doc || I->Extraction == ExtractionMode::Regular);
1734+
!I->doc || I->Extraction == ExtractionMode::Regular
1735+
|| I->IsCopyFromInherited == false);
17351736
}
17361737
bool const prefer_definition = is_one_of(
17371738
undocI.kind, {SymbolKind::Record, SymbolKind::Enum});
@@ -1752,6 +1753,7 @@ warnDocErrors()
17521753
for (auto const& I : corpus_.info_)
17531754
{
17541755
MRDOCS_CHECK_OR_CONTINUE(I->Extraction == ExtractionMode::Regular);
1756+
MRDOCS_CHECK_OR_CONTINUE(I->IsCopyFromInherited == false);
17551757
MRDOCS_CHECK_OR_CONTINUE(I->isFunction());
17561758
warnParamErrors(dynamic_cast<FunctionSymbol const&>(*I));
17571759
}
@@ -1807,6 +1809,7 @@ warnNoParamDocs()
18071809
for (auto const& I : corpus_.info_)
18081810
{
18091811
MRDOCS_CHECK_OR_CONTINUE(I->Extraction == ExtractionMode::Regular);
1812+
MRDOCS_CHECK_OR_CONTINUE(I->IsCopyFromInherited == false);
18101813
MRDOCS_CHECK_OR_CONTINUE(I->isFunction());
18111814
MRDOCS_CHECK_OR_CONTINUE(I->doc);
18121815
warnNoParamDocs(dynamic_cast<FunctionSymbol const&>(*I));
@@ -1869,6 +1872,7 @@ warnUndocEnumValues()
18691872
{
18701873
MRDOCS_CHECK_OR_CONTINUE(I->isEnumConstant());
18711874
MRDOCS_CHECK_OR_CONTINUE(I->Extraction == ExtractionMode::Regular);
1875+
MRDOCS_CHECK_OR_CONTINUE(I->IsCopyFromInherited == false);
18721876
MRDOCS_CHECK_OR_CONTINUE(!I->doc);
18731877
this->warn(
18741878
*getPrimaryLocation(*I),
@@ -1886,6 +1890,7 @@ warnUnnamedParams()
18861890
{
18871891
MRDOCS_CHECK_OR_CONTINUE(I->isFunction());
18881892
MRDOCS_CHECK_OR_CONTINUE(I->Extraction == ExtractionMode::Regular);
1893+
MRDOCS_CHECK_OR_CONTINUE(I->IsCopyFromInherited == false);
18891894
MRDOCS_CHECK_OR_CONTINUE(I->doc);
18901895
warnUnnamedParams(dynamic_cast<FunctionSymbol const&>(*I));
18911896
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
= Reference
2+
:mrdocs:
3+
4+
[#index]
5+
== Global namespace
6+
7+
8+
[.small]#Created with https://www.mrdocs.com[MrDocs]#
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
namespace ns {
2+
struct Foo {
3+
/// bar
4+
int
5+
bar();
6+
};
7+
} // namespace ns
8+
9+
/// project namespace
10+
namespace mrdocs {
11+
/// Baz
12+
struct Baz : ns::Foo {};
13+
} // namespace mrdocs
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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"></h2>
11+
</div>
12+
</div>
13+
14+
</div>
15+
<div>
16+
<h4>Created with <a href="https://www.mrdocs.com">MrDocs</a></h4>
17+
</div>
18+
</body>
19+
</html>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
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+
</namespace>
6+
</mrdocs>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
include-symbols:
2+
- 'foobar::**'

0 commit comments

Comments
 (0)