Difference between revisions of "VPP/Documentation"
(add build/preview details) |
(add conventions) |
||
Line 1: | Line 1: | ||
− | == Documentation | + | == Documentation generation == |
The VPP project currently uses Doxygen as the mechanism to generate documentation. This is predominantly focused on providing developer-focused information but it can also be used to generate user-focused details. | The VPP project currently uses Doxygen as the mechanism to generate documentation. This is predominantly focused on providing developer-focused information but it can also be used to generate user-focused details. | ||
Line 60: | Line 60: | ||
$ make doxygen DOXY_INPUT=vppinfra/vppinfra/pool.h | $ make doxygen DOXY_INPUT=vppinfra/vppinfra/pool.h | ||
</pre> | </pre> | ||
+ | |||
=== Cleaning up after Doxygen === | === Cleaning up after Doxygen === | ||
− | It is also possible to clean up the Doxygen output directory. This can become useful since Doxygen does not itself remove files from the build directory on subsequent runs | + | It is also possible to clean up the Doxygen output directory. This can become useful since Doxygen does not itself remove files from the build directory on subsequent runs should they become redundant. |
<pre> | <pre> | ||
$ make wipe-doxygen | $ make wipe-doxygen | ||
</pre> | </pre> | ||
+ | |||
+ | This is especially worth noting should you have previously built the documentation for the whole source tree and then want to build it for only one directory or file (using <code>DOXY_INPUT</code>); whilst unlikely, the remnants of previous documentation may interfere with Doxygen runs with a narrower scope. | ||
+ | |||
== Documenting the code == | == Documenting the code == | ||
+ | |||
+ | Whereupon Chris will provide examples of how to document code. | ||
== Documentation conventions == | == Documentation conventions == | ||
+ | |||
+ | === Doxygen comments/commands === | ||
+ | |||
+ | Doxygen requires the use of specially marked comment blocks to identify documentation and recognizes several special commands inside those blocks. It provides several ways to indicate both of these things. Whilst any will work, VPP as a project has adopted the following as conventions: | ||
+ | |||
+ | * Pre-identifier comment blocks are signified with <code>/** ... */</code>. | ||
+ | * Post-identifier comment blocks are given with <code>/**< ... */</code>. | ||
+ | * Special commands are prefixed with the at-sign, for example <code>@param</code> or <code>@code</code>. | ||
+ | ** Though you may often find the use of a back-slash in the existing code (especially <code>\brief</code>) these are being migrated to using at-sign. | ||
+ | |||
== Documentation templates == | == Documentation templates == | ||
+ | |||
+ | And lo, verily, he did produce some morsels of scripture upon which the philistines may feast. |
Revision as of 19:29, 26 July 2016
Contents
Documentation generation
The VPP project currently uses Doxygen as the mechanism to generate documentation. This is predominantly focused on providing developer-focused information but it can also be used to generate user-focused details.
Doxygen works by parsing source files and identifying special comment blocks that are adjacent to identifiers in the code. We have Doxygen configured to generate output for items that are not yet documented so that at the very least the names of function parameters or structure members are visible.
This wiki page aims to cover how developers can go about producing documentation. Whilst it will cover a number of Doxygen features, readers are encouraged to review the Doxygen documentation and in particular special commands page.
Build tools
All documentation generation related dependencies are installed with the install-dep
target of the top level Makefile.
Building the documentation
The top level Makefile of the VPP build tree also includes a doxygen
build target that will run Doxygen over the complete VPP source tree. Invoking that target will produce a significant amount of output and would look something like this:
$ make doxygen Adding custom extension mapping: .def will be treated as language c Adding custom extension mapping: .api will be treated as language c Parsing layout file /home/chrisy/dev/fdio/vpp/doxygen/layout.xml... Searching for include files... Searching for files in directory /home/chrisy/dev/fdio/vpp/vppinfra Searching for files in directory /home/chrisy/dev/fdio/vpp/vppinfra/autom4te.cache Searching for files in directory /home/chrisy/dev/fdio/vpp/vppinfra/config ... Patching output file 10218/10219 Patching output file 10219/10219 lookup cache used 25684/65536 hits=502842 misses=26575 finished...
Previewing the generated documentation
By default only HTML documentation is produced and it is built in build-root/docs/html
. If you build the documentation on a workstation then you can simply open index.html</code in that directory with a web browser to view it, for example:
$ make doxygen ... $ sensible-browser build-root/docs/html/index.html
Alternatively if you run this on a remote machine then an approach might be to add an HTTP server (such as Nginx or Apache HTTPD) to that host and configure it to expose the <code>build-root/docs/html directory; one mechanism is to symbolically link to this directory from inside some other directory already visible from the HTTP server, assuming the use of symbolic links is allowed. Details on this are beyond the scope of this page.
Building documentation for a specific directory
Producing the documentation for the entire build tree can take some time which can become an issue if a developer is working on documentation for a specific module or directory tree. As a convenience it is possible to override the set of directories into which Doxygen will descend when searching for files to parse. For example:
$ make doxygen DOXY_INPUT=vppinfra
or, if you wanted just one file:
$ make doxygen DOXY_INPUT=vppinfra/vppinfra/pool.h
Cleaning up after Doxygen
It is also possible to clean up the Doxygen output directory. This can become useful since Doxygen does not itself remove files from the build directory on subsequent runs should they become redundant.
$ make wipe-doxygen
This is especially worth noting should you have previously built the documentation for the whole source tree and then want to build it for only one directory or file (using DOXY_INPUT
); whilst unlikely, the remnants of previous documentation may interfere with Doxygen runs with a narrower scope.
Documenting the code
Whereupon Chris will provide examples of how to document code.
Documentation conventions
Doxygen comments/commands
Doxygen requires the use of specially marked comment blocks to identify documentation and recognizes several special commands inside those blocks. It provides several ways to indicate both of these things. Whilst any will work, VPP as a project has adopted the following as conventions:
- Pre-identifier comment blocks are signified with
/** ... */
. - Post-identifier comment blocks are given with
/**< ... */
. - Special commands are prefixed with the at-sign, for example
@param
or@code
.- Though you may often find the use of a back-slash in the existing code (especially
\brief
) these are being migrated to using at-sign.
- Though you may often find the use of a back-slash in the existing code (especially
Documentation templates
And lo, verily, he did produce some morsels of scripture upon which the philistines may feast.