Skip to content

Commit

Permalink
feat: add HIDE_INLINE_NAMESPACES config option
Browse files Browse the repository at this point in the history
  • Loading branch information
zchrissirhcz committed May 22, 2023
1 parent c57b8f1 commit fea7b7f
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 8 deletions.
3 changes: 2 additions & 1 deletion src/classdef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2379,6 +2379,7 @@ void ClassDefImpl::writeDeclarationLink(OutputList &ol,bool &found,const QCStrin
//bool fortranOpt = Config_getBool(OPTIMIZE_FOR_FORTRAN);
//bool vhdlOpt = Config_getBool(OPTIMIZE_OUTPUT_VHDL);
bool sliceOpt = Config_getBool(OPTIMIZE_OUTPUT_SLICE);
bool hideInlineNamespaces = Config_getBool(HIDE_INLINE_NAMESPACES);
SrcLangExt lang = getLanguage();
if (visibleInParentsDeclList())
{
Expand Down Expand Up @@ -2431,7 +2432,7 @@ void ClassDefImpl::writeDeclarationLink(OutputList &ol,bool &found,const QCStrin
QCString cname = displayName(!localNames);

Definition* outDef = getOuterScope();
if (outDef->definitionType() == Definition::DefType::TypeNamespace)
if (hideInlineNamespaces && outDef && outDef->definitionType() == Definition::DefType::TypeNamespace)
{
NamespaceDef* outDefReal = reinterpret_cast<NamespaceDef*>(outDef);
if (outDefReal->isInline())
Expand Down
9 changes: 9 additions & 0 deletions src/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1258,6 +1258,15 @@ Go to the <a href="commands.html">next</a> section or return to the
Set the \c SHOW_NAMESPACES tag to \c NO to disable the generation of the
Namespaces page. This will remove the Namespaces entry from the Quick Index
and from the Folder Tree View (if specified).
]]>
</docs>
</option>
<option type='bool' id='HIDE_INLINE_NAMESPACES' defval='1'>
<docs>
<![CDATA[
Set the \c HIDE_INLINE_NAMESPACES tag to \c NO to show inline namespaces and
classes inside inline namespaces in Class, Namespace, File page, search index,
and from the Folder Tree View (if specified).
]]>
</docs>
</option>
Expand Down
9 changes: 6 additions & 3 deletions src/definition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1302,7 +1302,8 @@ QCString DefinitionImpl::qualifiedName() const
std::lock_guard<std::recursive_mutex> lock(g_qualifiedNameMutex);
if (!m_impl->qualifiedName.isEmpty())
{
if (m_impl->def->definitionType() == Definition::DefType::TypeNamespace)
bool hideInlineNamespaces = Config_getBool(HIDE_INLINE_NAMESPACES);
if (hideInlineNamespaces && m_impl->def->definitionType() == Definition::DefType::TypeNamespace)
{
DefinitionMutable* x = m_impl->def->toDefinitionMutable_();
Definition* y = toDefinition(x);
Expand Down Expand Up @@ -1473,7 +1474,8 @@ QCString DefinitionImpl::navigationPathAsString() const
{
result+=(toFileDef(m_impl->def))->getDirDef()->navigationPathAsString();
}
if (m_impl->def->definitionType() == Definition::DefType::TypeNamespace)
bool hideInlineNamespaces = Config_getBool(HIDE_INLINE_NAMESPACES);
if (hideInlineNamespaces && m_impl->def->definitionType() == Definition::DefType::TypeNamespace)
{
DefinitionMutable* x = m_impl->def->toDefinitionMutable_();
Definition* y = toDefinition(x);
Expand Down Expand Up @@ -1886,7 +1888,8 @@ QCString DefinitionImpl::externalReference(const QCString &relPath) const
const QCString &DefinitionImpl::name() const
{
Definition* outerDef = getOuterScope();
if (outerDef && outerDef->definitionType() == Definition::DefType::TypeNamespace)
bool hideInlineNamespaces = Config_getBool(HIDE_INLINE_NAMESPACES);
if (hideInlineNamespaces && outerDef && outerDef->definitionType() == Definition::DefType::TypeNamespace)
{
NamespaceDef* outerDefReal = reinterpret_cast<NamespaceDef*>(outerDef);
if (outerDefReal->isInline())
Expand Down
4 changes: 2 additions & 2 deletions src/index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1756,8 +1756,8 @@ static void writeNamespaceTreeElement(const NamespaceDef *nd,FTVHelp *ftv,
bool isDir = hasChildren || visibleMembers>0;
if ((isLinkable) || isDir)
{
// feature: skip inline namespace
if (nd->isModule() && nd->isInline()) return;
bool hideInlineNamespaces = Config_getBool(HIDE_INLINE_NAMESPACES);
if (hideInlineNamespaces && nd->isModule() && nd->isInline()) return;
ftv->addContentsItem(hasChildren,nd->localName(),ref,file,QCString(),FALSE,nd->partOfGroups().empty(),nd);

if (addToIndex)
Expand Down
8 changes: 7 additions & 1 deletion src/namespacedef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1360,10 +1360,16 @@ void NamespaceLinkedRefMap::writeDeclaration(OutputList &ol,const QCString &titl
ol.parseText(title);
ol.endMemberHeader();
ol.startMemberList();
bool hideInlineNamespaces = Config_getBool(HIDE_INLINE_NAMESPACES);
for (const auto &nd : *this)
{
if (nd->isLinkable() && nd->hasDocumentation() && !nd->isInline())
if (nd->isLinkable() && nd->hasDocumentation())
{
if (hideInlineNamespaces && nd->isInline())
{
continue;
}

SrcLangExt lang = nd->getLanguage();
if (lang==SrcLangExt_IDL && (isConstantGroup != nd->isConstantGroup()))
continue; // will be output in another pass, see layout_default.xml
Expand Down
3 changes: 2 additions & 1 deletion src/searchindex_js.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,14 +242,15 @@ static void addMemberToSearchIndex(const MemberDef *md)

void createJavaScriptSearchIndex()
{
bool hideInlineNamespaces = Config_getBool(HIDE_INLINE_NAMESPACES);
// index classes
for (const auto &cd : *Doxygen::classLinkedMap)
{
std::string letter = convertUTF8ToLower(getUTF8CharAt(cd->localName().str(),0));
if (cd->isLinkable())
{
Definition* outerDef = cd->getOuterScope();
if (outerDef && outerDef->definitionType() == Definition::DefType::TypeNamespace)
if (hideInlineNamespaces && outerDef && outerDef->definitionType() == Definition::DefType::TypeNamespace)
{
NamespaceDef* outerDefReal = reinterpret_cast<NamespaceDef*>(outerDef);
if (outerDefReal->isInline())
Expand Down

0 comments on commit fea7b7f

Please sign in to comment.