Skip to content

Commit 8172a20

Browse files
committed
issue doxygen#11322 C++ 20 Modules: Links to global functions, links to modules
1 parent 791bcf8 commit 8172a20

File tree

7 files changed

+85
-23
lines changed

7 files changed

+85
-23
lines changed

src/classdef.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3057,7 +3057,7 @@ void ClassDefImpl::writeDocumentationForInnerClasses(OutputList &ol) const
30573057
!innerCd->isEmbeddedInOuterScope()
30583058
)
30593059
{
3060-
msg("Generating docs for nested compound %s...\n",qPrint(innerCd->name()));
3060+
msg("Generating docs for nested compound %s...\n",qPrint(innerCd->displayName()));
30613061
innerCd->writeDocumentation(ol);
30623062
innerCd->writeMemberList(ol);
30633063
}

src/memberdef.cpp

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1811,7 +1811,6 @@ void MemberDefImpl::_computeLinkableInProject()
18111811
return;
18121812
}
18131813
const GroupDef *groupDef = getGroupDef();
1814-
const ModuleDef *moduleDef = getModuleDef();
18151814
const ClassDef *classDef = getClassDef();
18161815
if (groupDef && !groupDef->isLinkableInProject())
18171816
{
@@ -1825,12 +1824,6 @@ void MemberDefImpl::_computeLinkableInProject()
18251824
m_isLinkableCached = 1; // in class but class not linkable
18261825
return;
18271826
}
1828-
if (!groupDef && moduleDef && !moduleDef->isLinkableInProject())
1829-
{
1830-
AUTO_TRACE_ADD("in not linkable module");
1831-
m_isLinkableCached = 1; // in module but module not linkable
1832-
return;
1833-
}
18341827
const NamespaceDef *nspace = getNamespaceDef();
18351828
const FileDef *fileDef = getFileDef();
18361829
if (!groupDef && nspace /*&& m_related==Relationship::Member*/ && !nspace->isLinkableInProject()
@@ -2232,10 +2225,9 @@ void MemberDefImpl::writeDeclaration(OutputList &ol,
22322225
ASSERT (cd!=nullptr || nd!=nullptr || fd!=nullptr || gd!=nullptr || mod!=nullptr); // member should belong to something
22332226
if (cd) d=cd;
22342227
else if (nd) d=nd;
2235-
else if (mod) d=mod;
22362228
else if (fd) d=fd;
22372229
else d=gd;
2238-
if (d==gd) // see bug 753608
2230+
if (d==gd || d==mod) // see bug 753608
22392231
{
22402232
if (getClassDef()) d = getClassDef();
22412233
else if (getNamespaceDef()) d = getNamespaceDef();
@@ -2267,11 +2259,13 @@ void MemberDefImpl::writeDeclaration(OutputList &ol,
22672259
OutputGenerator::MemberItemType::Normal;
22682260
ol.startMemberItem(anchor(), anonType, inheritId);
22692261

2262+
22702263
// If there is no detailed description we need to write the anchor here.
22712264
bool detailsVisible = hasDetailedDescription();
22722265
bool writeAnchor = (inGroup || getGroupDef()==nullptr) && // only write anchors for member that have no details and are
2273-
!detailsVisible && !m_annMemb && // rendered inside the group page or are not grouped at all
2266+
!detailsVisible && !m_annMemb && // rendered inside the group page or are not grouped at all
22742267
inheritId.isEmpty();
2268+
22752269
if (writeAnchor)
22762270
{
22772271
QCString doxyArgs=argsString();
@@ -2746,6 +2740,10 @@ bool MemberDefImpl::hasDetailedDescription() const
27462740
// this is not a global static or global statics should be extracted
27472741
bool staticFilter = getClassDef()!=nullptr || !isStatic() || extractStatic;
27482742

2743+
// a module does not contain details for members, so either the namespace or file should be linkable
2744+
bool moduleFilter = getModuleDef()==nullptr || (getFileDef() && getFileDef()->isLinkable()) ||
2745+
(getNamespaceDef() && getNamespaceDef()->isLinkable());
2746+
27492747
// only include members that are non-private unless EXTRACT_PRIVATE is
27502748
// set to YES or the member is part of a group
27512749
bool privateFilter = protectionLevelVisible(protection()) || m_mtype==MemberType::Friend ||
@@ -2756,7 +2754,7 @@ bool MemberDefImpl::hasDetailedDescription() const
27562754
bool friendCompoundFilter = !(Config_getBool(HIDE_FRIEND_COMPOUNDS) && isFriend());
27572755

27582756
m_detailedDescriptionCachedValue =
2759-
(docFilter && staticFilter && privateFilter && friendCompoundFilter && !isHidden());
2757+
(docFilter && staticFilter && moduleFilter && privateFilter && friendCompoundFilter && !isHidden());
27602758
//printf("docFilter=%d docInfo=%d staticFilter=%d privateFilter=%d friendCompoundFilter=%d !isHidden()=%d",
27612759
// docFilter,docInfo,staticFilter,privateFilter,friendCompoundFilter,!isHidden());
27622760
m_hasDetailedDescriptionCached = true;

src/moduledef.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1512,6 +1512,11 @@ const ModuleLinkedMap &ModuleManager::modules() const
15121512
return p->moduleFileMap;
15131513
}
15141514

1515+
ModuleLinkedMap &ModuleManager::modules()
1516+
{
1517+
return p->moduleFileMap;
1518+
}
1519+
15151520
void ModuleManager::addDocs(const Entry *root)
15161521
{
15171522
AUTO_TRACE("file={} module={}",root->fileName,root->name);

src/moduledef.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ class ModuleManager
133133
void countMembers();
134134
void writeDocumentation(OutputList &ol);
135135
int numDocumentedModules() const;
136+
ModuleLinkedMap &modules();
136137
const ModuleLinkedMap &modules() const;
137138
ModuleDef *getPrimaryInterface(const QCString &moduleName) const;
138139

src/symbolresolver.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -855,7 +855,8 @@ void SymbolResolver::Private::getResolvedSymbol(
855855
}
856856
}
857857
else if ((d->definitionType()==Definition::TypeNamespace ||
858-
d->definitionType()==Definition::TypeFile))
858+
d->definitionType()==Definition::TypeFile ||
859+
d->definitionType()==Definition::TypeModule))
859860
{
860861
if (distance<minDistance) // found a definition that is "closer"
861862
{

src/util.cpp

Lines changed: 65 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,7 +1056,7 @@ void linkifyText(const TextGeneratorIntf &out, const Definition *scope,
10561056
{
10571057
GetDefInput input(scopeName,matchWord,QCString());
10581058
GetDefResult result = getDefs(input);
1059-
if (result.found &&
1059+
if (result.found && result.md &&
10601060
(external ? result.md->isLinkable() : result.md->isLinkableInProject())
10611061
)
10621062
{
@@ -2240,6 +2240,26 @@ GetDefResult getDefsNew(const GetDefInput &input)
22402240
result.gd = result.md->getGroupDef();
22412241
result.found = true;
22422242
}
2243+
else if (symbol && symbol->definitionType()==Definition::TypeClass)
2244+
{
2245+
result.cd = toClassDef(symbol);
2246+
result.found = true;
2247+
}
2248+
else if (symbol && symbol->definitionType()==Definition::TypeNamespace)
2249+
{
2250+
result.nd = toNamespaceDef(symbol);
2251+
result.found = true;
2252+
}
2253+
else if (symbol && symbol->definitionType()==Definition::TypeConcept)
2254+
{
2255+
result.cnd = toConceptDef(symbol);
2256+
result.found = true;
2257+
}
2258+
else if (symbol && symbol->definitionType()==Definition::TypeModule)
2259+
{
2260+
result.modd = toModuleDef(symbol);
2261+
result.found = true;
2262+
}
22432263
return result;
22442264
}
22452265

@@ -2808,9 +2828,12 @@ GetDefResult getDefs(const GetDefInput &input)
28082828
* - if `nd` is non zero, the scope was a namespace pointed to by nd.
28092829
*/
28102830
static bool getScopeDefs(const QCString &docScope,const QCString &scope,
2811-
ClassDef *&cd, ConceptDef *&cnd, NamespaceDef *&nd)
2831+
ClassDef *&cd, ConceptDef *&cnd, NamespaceDef *&nd,ModuleDef *&modd)
28122832
{
2813-
cd=nullptr;nd=nullptr;
2833+
cd=nullptr;
2834+
cnd=nullptr;
2835+
nd=nullptr;
2836+
modd=nullptr;
28142837

28152838
QCString scopeName=scope;
28162839
//printf("getScopeDefs: docScope='%s' scope='%s'\n",qPrint(docScope),qPrint(scope));
@@ -2849,6 +2872,10 @@ static bool getScopeDefs(const QCString &docScope,const QCString &scope,
28492872
{
28502873
return TRUE; // concept link written => quit
28512874
}
2875+
else if ((modd=ModuleManager::instance().modules().find(fullName)) && modd->isLinkable())
2876+
{
2877+
return TRUE; // module link written => quit
2878+
}
28522879
if (scopeOffset==0)
28532880
{
28542881
scopeOffset=-1;
@@ -2937,11 +2964,12 @@ bool resolveRef(/* in */ const QCString &scName,
29372964
ClassDef *cd=nullptr;
29382965
NamespaceDef *nd=nullptr;
29392966
ConceptDef *cnd=nullptr;
2967+
ModuleDef *modd=nullptr;
29402968

29412969
//printf("scName=%s fullName=%s\n",qPrint(scName),qPrint(fullName));
29422970

29432971
// check if this is a class or namespace reference
2944-
if (scName!=fullName && getScopeDefs(scName,fullName,cd,cnd,nd))
2972+
if (scName!=fullName && getScopeDefs(scName,fullName,cd,cnd,nd,modd))
29452973
{
29462974
//printf("found scopeDef\n");
29472975
if (cd) // scope matches that of a class
@@ -2952,6 +2980,10 @@ bool resolveRef(/* in */ const QCString &scName,
29522980
{
29532981
*resContext = cnd;
29542982
}
2983+
else if (modd)
2984+
{
2985+
*resContext = modd;
2986+
}
29552987
else // scope matches that of a namespace
29562988
{
29572989
ASSERT(nd!=nullptr);
@@ -3014,6 +3046,7 @@ bool resolveRef(/* in */ const QCString &scName,
30143046

30153047
const GroupDef *gd = nullptr;
30163048
const ConceptDef *cnd = nullptr;
3049+
const ModuleDef *modd = nullptr;
30173050

30183051
// check if nameStr is a member or global.
30193052
//printf("getDefs(scope=%s,name=%s,args=%s checkScope=%d)\n",
@@ -3040,7 +3073,8 @@ bool resolveRef(/* in */ const QCString &scName,
30403073
return FALSE;
30413074
}
30423075
//printf("after getDefs md=%p cd=%p fd=%p nd=%p gd=%p\n",md,cd,fd,nd,gd);
3043-
if (result.md) {
3076+
if (result.md)
3077+
{
30443078
if (!allowTypeOnly || result.md->isTypedef() || result.md->isEnumerate())
30453079
{
30463080
*resMember=result.md;
@@ -3054,11 +3088,18 @@ bool resolveRef(/* in */ const QCString &scName,
30543088
return FALSE;
30553089
}
30563090
}
3057-
else if (result.cd) *resContext=result.cd;
3058-
else if (result.nd) *resContext=result.nd;
3059-
else if (result.fd) *resContext=result.fd;
3060-
else if (result.gd) *resContext=result.gd;
3061-
else { *resContext=nullptr; *resMember=nullptr; return FALSE; }
3091+
else if (result.cd) *resContext=result.cd;
3092+
else if (result.nd) *resContext=result.nd;
3093+
else if (result.fd) *resContext=result.fd;
3094+
else if (result.gd) *resContext=result.gd;
3095+
else if (result.cnd) *resContext=result.cnd;
3096+
else if (result.modd) *resContext=result.modd;
3097+
else
3098+
{
3099+
*resContext=nullptr; *resMember=nullptr;
3100+
AUTO_TRACE_ADD("false");
3101+
return FALSE;
3102+
}
30623103
//printf("member=%s (md=%p) anchor=%s linkable()=%d context=%s\n",
30633104
// qPrint(md->name()), md, qPrint(md->anchor()), md->isLinkable(), qPrint((*resContext)->name()));
30643105
AUTO_TRACE_ADD("true");
@@ -3076,6 +3117,12 @@ bool resolveRef(/* in */ const QCString &scName,
30763117
AUTO_TRACE_ADD("true");
30773118
return TRUE;
30783119
}
3120+
else if ((modd=ModuleManager::instance().modules().find(nameStr)))
3121+
{
3122+
*resContext=modd;
3123+
AUTO_TRACE_ADD("true");
3124+
return TRUE;
3125+
}
30793126
else if (tsName.find('.')!=-1) // maybe a link to a file
30803127
{
30813128
bool ambig = false;
@@ -3159,6 +3206,7 @@ bool resolveLink(/* in */ const QCString &scName,
31593206
const ClassDef *cd = nullptr;
31603207
const DirDef *dir = nullptr;
31613208
const ConceptDef *cnd = nullptr;
3209+
const ModuleDef *modd = nullptr;
31623210
const NamespaceDef *nd = nullptr;
31633211
const SectionInfo *si = nullptr;
31643212
bool ambig = false;
@@ -3238,6 +3286,13 @@ bool resolveLink(/* in */ const QCString &scName,
32383286
AUTO_TRACE_EXIT("concept");
32393287
return TRUE;
32403288
}
3289+
else if ((modd=ModuleManager::instance().modules().find(linkRef)))
3290+
{
3291+
*resContext=modd;
3292+
resAnchor=modd->anchor();
3293+
AUTO_TRACE_EXIT("module");
3294+
return TRUE;
3295+
}
32413296
else if ((nd=Doxygen::namespaceLinkedMap->find(linkRef)))
32423297
{
32433298
*resContext=nd;

src/util.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ struct GetDefResult
127127
const FileDef *fd=nullptr;
128128
const NamespaceDef *nd=nullptr;
129129
const GroupDef *gd=nullptr;
130+
const ConceptDef *cnd=nullptr;
131+
const ModuleDef *modd=nullptr;
130132
};
131133

132134
GetDefResult getDefs(const GetDefInput &input);

0 commit comments

Comments
 (0)