A common idiom in modern C++, pioneered by the developers of the Boost libraries, is to separate symbols that form part of the implementation of your module (that is, don’t form part of the public API) but that have to be publicly available into a separate sub-namespace, by convention named detail
. This is especially common in header-only libraries, where any symbol you define will leak into the translation unit that includes your header. While the results of the Modules ISO C++ study group may provide a better solution to this eventually, the current solution is to hide these symbols in a detail
namespace; even though these are still public symbols, the user can ignore all symbols in detail
.
This can be made to work with Doxygen, the JavaDoc-style documentation generator for C++, very easily. Because the symbols in any of the detail
sub-namespaces are not part of the public API, we don’t generally want them in the API documentation generated by Doxygen. Luckily, though, Doxygen provides a configuration flag to ignore certain symbol patterns in generating documentation. To get Doxygen to ignore any detail
namespaces and any symbols within them, just add
EXCLUDE_SYMBOLS = detail
to your Doxyfile
. Of course, if you have a different Doxyfile
for internal documentation builds where you want your detail
namespaces, you can leave this line out and generate documentation with those private symbols included.
This is the approach I’m taking with the Humm and Strumm Project’s API Documentation, on one of my branches to clean up our documentation. Until the next release, the above link will point to the 0.7 documentation, not the cleaned up 0.8 documentation. I may, along with our nightly builds, build the documentation every night and publicly host it if I have time before the next release.