Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide inline namespace in html output #10070

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
42a387d
feat: hide inline namespace in treeview of Namespace and Classes pages
zchrissirhcz May 18, 2023
dfbb5b3
feat: hide inline namespace in each Class page's title
zchrissirhcz May 18, 2023
ac5c88f
feat: hide inline namespace in navigation part in htmlpage of each Class
zchrissirhcz May 18, 2023
1ff8d02
feat: hide inline namespace in each namespace's page
zchrissirhcz May 22, 2023
61dc6ad
feat: hide inline namespace in File Reference page
zchrissirhcz May 22, 2023
94640ea
feat: hide inline namespace for namespace and class that inside of in…
zchrissirhcz May 22, 2023
3795d9b
feat: hide inline namespace in JavaScript search index
zchrissirhcz Mar 11, 2024
47d09cd
feat: add HIDE_INLINE_NAMESPACES config option
zchrissirhcz May 22, 2023
3a88740
change HIDE_INLINE_NAMESPACES default value for compatibility
zchrissirhcz May 25, 2023
9185632
[style] Adjust code style
zchrissirhcz Mar 11, 2024
b0a3bf0
[style] Keep minimal change, adjust variable naming
zchrissirhcz Mar 11, 2024
dac1c15
[docs] Adjust doc for config option HIDE_INLINE_NAMESPACES
zchrissirhcz Mar 11, 2024
8edff32
[test] Add test file(WIP)
zchrissirhcz Mar 11, 2024
69551d4
[style] Use shorter name: HIDE_INLINE_NAMESPACE
zchrissirhcz Mar 11, 2024
0d997f7
[test] Specify config in test input file
zchrissirhcz Mar 11, 2024
37a9599
[feat] Support config HIDE_INLINE_NAMESPACE in wizard
zchrissirhcz Mar 11, 2024
2da0229
[debug] Add doxygen generated xml as reference output
zchrissirhcz Mar 11, 2024
b8676ae
[test] Rewrite test input 102_hide_line_namespace.cpp
zchrissirhcz Mar 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions addon/doxywizard/wizard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
#define STR_HTML_COLORSTYLE_HUE QString::fromLatin1("HTML_COLORSTYLE_HUE")
#define STR_HTML_COLORSTYLE_SAT QString::fromLatin1("HTML_COLORSTYLE_SAT")
#define STR_HTML_COLORSTYLE_GAMMA QString::fromLatin1("HTML_COLORSTYLE_GAMMA")
#define STR_HIDE_INLINE_NAMESPACE QString::fromLatin1("HIDE_INLINE_NAMESPACE")

static bool g_optimizeMapping[7][7] =
{
Expand Down
11 changes: 11 additions & 0 deletions src/classdef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2423,6 +2423,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_NAMESPACE);
SrcLangExt lang = getLanguage();
if (visibleInParentsDeclList())
{
Expand Down Expand Up @@ -2474,6 +2475,16 @@ void ClassDefImpl::writeDeclarationLink(OutputList &ol,bool &found,const QCStrin
QCString ctype = compoundTypeString();
QCString cname = displayName(!localNames);

Definition* outDef = getOuterScope();
if (hideInlineNamespaces && outDef && outDef->definitionType() == Definition::DefType::TypeNamespace)
{
NamespaceDef* outDefReal = reinterpret_cast<NamespaceDef*>(outDef);
if (outDefReal->isInline())
{
return;
}
}

if (lang!=SrcLangExt::VHDL) // for VHDL we swap the name and the type
{
if (isSliceLocal())
Expand Down
9 changes: 9 additions & 0 deletions src/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1265,6 +1265,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_NAMESPACE' defval='0'>
<docs>
<![CDATA[
Set the \c HIDE_INLINE_NAMESPACE tag to \c YES to hide 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
46 changes: 46 additions & 0 deletions src/definition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1298,11 +1298,35 @@ void DefinitionImpl::addInnerCompound(Definition *)

static std::recursive_mutex g_qualifiedNameMutex;

// foo::_v1 => foo
// suitable for namespace
static QCString rStripInlineNamespaceScope(const QCString& name)
{
QCString newName = name;
int pos = name.find("::");
if (pos != -1)
{
newName = name.str().substr(0, pos);
}
return newName;
}

QCString DefinitionImpl::qualifiedName() const
{
std::lock_guard<std::recursive_mutex> lock(g_qualifiedNameMutex);
if (!m_impl->qualifiedName.isEmpty())
{
bool hideInlineNamespaces = Config_getBool(HIDE_INLINE_NAMESPACE);
if (hideInlineNamespaces && m_impl->def->definitionType() == Definition::DefType::TypeNamespace)
{
DefinitionMutable* defMut = m_impl->def->toDefinitionMutable_();
Definition* def = toDefinition(defMut);
NamespaceDef* nsDef = reinterpret_cast<NamespaceDef*>(def);
if (nsDef->isInline())
{
return rStripInlineNamespaceScope(m_impl->qualifiedName);
}
}
return m_impl->qualifiedName;
}

Expand Down Expand Up @@ -1464,6 +1488,18 @@ QCString DefinitionImpl::navigationPathAsString() const
{
result+=(toFileDef(m_impl->def))->getDirDef()->navigationPathAsString();
}
bool hideInlineNamespaces = Config_getBool(HIDE_INLINE_NAMESPACE);
if (hideInlineNamespaces && m_impl->def->definitionType() == Definition::DefType::TypeNamespace)
{
DefinitionMutable* defMut = m_impl->def->toDefinitionMutable_();
Definition* def = toDefinition(defMut);
NamespaceDef* nsDef = reinterpret_cast<NamespaceDef*>(def);
if (nsDef->isInline())
{
return result;
}
}

result+="<li class=\"navelem\">";
if (m_impl->def->isLinkableInProject())
{
Expand Down Expand Up @@ -1875,6 +1911,16 @@ QCString DefinitionImpl::externalReference(const QCString &relPath) const

const QCString &DefinitionImpl::name() const
{
Definition* outerDef = getOuterScope();
bool hideInlineNamespaces = Config_getBool(HIDE_INLINE_NAMESPACE);
if (hideInlineNamespaces && outerDef && outerDef->definitionType() == Definition::DefType::TypeNamespace)
{
NamespaceDef* outerDefReal = reinterpret_cast<NamespaceDef*>(outerDef);
if (outerDefReal->isInline())
{
return outerDefReal->getOuterScope()->name();
}
}
return m_impl->name;
}

Expand Down
8 changes: 8 additions & 0 deletions src/index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1821,6 +1821,9 @@ static void writeNamespaceTreeElement(const NamespaceDef *nd,FTVHelp *ftv,
bool isDir = hasChildren || visibleMembers>0;
if (isLinkable || isDir)
{
bool hideInlineNamespaces = Config_getBool(HIDE_INLINE_NAMESPACE);
if (hideInlineNamespaces && nd->isModule() && nd->isInline())
return;
ftv->addContentsItem(hasChildren,nd->localName(),ref,file,QCString(),FALSE,nd->partOfGroups().empty(),nd);

if (addToIndex)
Expand Down Expand Up @@ -1903,6 +1906,11 @@ static void writeClassTreeInsideNamespaceElement(const NamespaceDef *nd,FTVHelp

if (isDir)
{
// feature: skip inline namespace
if (nd->isModule() && nd->isInline())
{
return;
}
ftv->addContentsItem(isDir,nd->localName(),ref,file,QCString(),FALSE,TRUE,nd);

if (addToIndex)
Expand Down
4 changes: 4 additions & 0 deletions src/namespacedef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1391,10 +1391,14 @@ void NamespaceLinkedRefMap::writeDeclaration(OutputList &ol,const QCString &titl
ol.parseText(title);
ol.endMemberHeader();
ol.startMemberList();
bool hideInlineNamespaces = Config_getBool(HIDE_INLINE_NAMESPACE);
for (const auto &nd : *this)
{
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
8 changes: 8 additions & 0 deletions src/searchindex_js.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,11 +306,19 @@ static void addMemberToSearchIndex(const MemberDef *md)

void createJavaScriptSearchIndex()
{
bool hideInlineNamespaces = Config_getBool(HIDE_INLINE_NAMESPACE);
// index classes
for (const auto &cd : *Doxygen::classLinkedMap)
{
if (cd->isLinkable())
{
Definition* outerDef = cd->getOuterScope();
if (hideInlineNamespaces && outerDef && outerDef->definitionType() == Definition::DefType::TypeNamespace)
{
NamespaceDef* outerDefReal = reinterpret_cast<NamespaceDef*>(outerDef);
if (outerDefReal->isInline())
continue;
}
QCString n = cd->localName();
g_searchIndexInfo[SEARCH_INDEX_ALL].add(SearchTerm(n,cd.get()));
if (Config_getBool(OPTIMIZE_OUTPUT_SLICE))
Expand Down
20 changes: 20 additions & 0 deletions testing/102/102__hide__inline__namespace_8cpp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<doxygen xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="compound.xsd" version="" xml:lang="en-US">
<compounddef id="102__hide__inline__namespace_8cpp" kind="file" language="C++">
<compoundname>102_hide_inline_namespace.cpp</compoundname>
<innerclass refid="structfoo_1_1v1_1_1_size" prot="public">foo</innerclass>
<innerclass refid="structfoo_1_1v1_1_1cv_1_1_image" prot="public">foo::v1::cv::Image</innerclass>
<innerclass refid="structfoo_1_1v1_1_1nn_1_1_tensor" prot="public">foo::v1::nn::Tensor</innerclass>
<innerclass refid="structfoo_1_1v1_1_1nn_1_1v1_1_1_conv_param" prot="public">foo</innerclass>
<innernamespace refid="namespacefoo">foo</innernamespace>
<innernamespace refid="namespacefoo_1_1v1" inline="yes">foo::v1</innernamespace>
<innernamespace refid="namespacefoo_1_1v1_1_1cv">foo</innernamespace>
<innernamespace refid="namespacefoo_1_1v1_1_1nn">foo</innernamespace>
<innernamespace refid="namespacefoo_1_1v1_1_1nn_1_1v1" inline="yes">foo::v1::nn::v1</innernamespace>
<briefdescription>
</briefdescription>
<detaileddescription>
</detaileddescription>
<location file="102_hide_inline_namespace.cpp"/>
</compounddef>
</doxygen>
53 changes: 53 additions & 0 deletions testing/102_hide_inline_namespace.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// objective: test collapse of inline namespace
// check: 102__hide__inline__namespace_8cpp.xml
// config: HIDE_INLINE_NAMESPACE = YES
// config: EXTRACT_ALL = YES

namespace foo {

inline namespace v1 {

struct Size
{
int width;
int height;
};

namespace cv {

struct Image
{
int height;
int width;
unsigned char* data;
};

} // namespace cv

namespace nn {

struct Tensor
{
int width;
int height;
int channel;
float* data;
};

inline namespace v1 {

struct ConvParam
{
int pad;
int stride;
int kernel_len;
};

} // namespace v1

} // namespace nn

} // namespace v1

} // namespace foo