Truncating namespaces in a Doxygen mainpage

亡梦爱人 提交于 2021-01-28 19:36:23

问题


I am writing a C# library and would like to link to some classes' pages from my mainpage.md file. However, the only way I can get Doxygen to make the links out of the text in the mainpage is by writing the fully-qualified names of the classes (eg. com.mycompany.myproject.MyClass) in the mainpage, which is a little hard to read and a real pain to write repeatedly. I would like to be able to just write MyClass in the mainpage and have it link to com.mycompany.myproject.MyClass.

There is only one namespace in my project anyway: is there any way I can make the mainpage assume all names are implicitly within this namespace? At worst, is there a nice way to truncate the namespace from the class names during generation? Right now my best solution is to run over my HTML files with sed after running Doxygen to edit index.html myself.


回答1:


I finally found my answer in a comment at doxygen: how to create hyperlinks to class definitions from Mainpage.dox?.

Essentially, the answer was to change my mainpage.md file into a mainpage.dox file, and surround my mainpage with a namespace declaration, like so:

namespace com.mycompany.myproject {

/**
 * {mainpage text here}
 */
}

This makes the mainpage within the namespace, and instructed Doxygen to look in the right namespace for any class names mentioned in the mainpage body.




回答2:


Try using HIDE_SCOPE_NAMES:

HIDE_SCOPE_NAMES = YES

http://www.doxygen.nl/manual/config.html#cfg_hide_scope_names

If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen will show members with their full class and namespace scopes in the documentation. If set to YES the scope will be hidden.

So using this should allow:

com.mycompany.myproject.MyClass

to become:

 MyClass


来源:https://stackoverflow.com/questions/27573608/truncating-namespaces-in-a-doxygen-mainpage

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