“using namespace” for Doxygen comments

我只是一个虾纸丫 提交于 2019-12-23 06:58:35

问题


All classes of my library are defined within a namespace. When I create a mainpage for Doxygen I have to explicitly use this namespace within comments to make Doxygen generate links. I would like to use something like "using namespace" for the whole comment block.

An example:

/**
* \mainpage My Library
*
* Use MyLibraryNamespace::MyClass to ...
*/

Here Doxygen automatically generates a link to the documentation of MyLibraryNamespace::MyClass.

/**
* \mainpage My Library
*
* Use MyClass to ...
*/

Here Doxygen does not generate a link to the documentation of MyLibraryNamespace::MyClass (as there might be multiple MyClass definitions in different namespaces I suppose). To ease the reading I would like to omit the namespace prefix in the comment. Is that possible without having to type \ref MyLibraryNamespace::MyClass "MyClass" every time?


回答1:


You can make this work for one namespace by putting your comment inside the namespace. This bugs me considerably as we have multiple nested namespaces and I hate having to use them in Doxygen comments.

namespace MyLibraryNamespace {
/**
* \mainpage My Library
*
* Use MyClass to ...
*/
};

2016 Update from Markdown Perspective

I'm using Doxygen for the C# docs for Realm (yes Doxygen handles the typical C# XML comment format too!). The Markdown main page uses the @ref to refer to namespaced classes:

The main classes you will use are:

- [Realm](@ref Realms.Realm)
- [RealmObject](@ref Realms.RealmObject)
- [RealmList](@ref Realms.RealmList)
- [Transaction](@ref Realms.Transaction)

You can see a rendered version online here




回答2:


You can use alias like this:

ALIASES += refmylib{1}="@ref MyLibraryNamespace::\1 \"\1\""

This is an usage example:

/** * \mainpage My Library * * Use @refmylib{MyClass} to ... */

And above will be processed by doxygen like this:

/** * \mainpage My Library * * Use @ref MyLibraryNamespace::MyClass "MyClass" to ... */



来源:https://stackoverflow.com/questions/2499128/using-namespace-for-doxygen-comments

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!