Documenting Modules in a Collection
This page shows how to document the modules in your module collection using the
document_modules
function in the SDE. This page assumes that you can create
a module collection according to About Module Collections and Loading a Module Collection.
Generate the Documentation
This section explains the steps necessary to generate documentation for modules in a given module collection. To cut straight to the point, see the full documentation program code below in Example Program.
Currently, documentation generation is expected to be performed in its own
binary, which we will refer to as build_docs
here. This program must
include both the sde::printing::document_modules
function and the
load_modules
function defined for your modules.
#include <filesystem>
// TODO: Replace with the header containing your ``load_modules`` definition
#include "load_modules.hpp"
Next, set up a sde::ModuleManager
and load your modules with the
load_modules
you wrote.
// Set up module manager
pluginplay::ModuleManager mm;
// TODO: Load your modules
pluginplay_examples::load_modules(mm);
The final step is to generate documentation through
sde::printing::document_modules
, by providing your ModuleManager
instance (mm
here) and the std::filesystem::path
to an existing
directory where the documentation should be output (doc_path
here). How this
path is generated is a detail left to the developer’s discretion. For simplicity
in the example below, the first command line argument is assumed to be a valid
path, although more validation may be necessary.
// Generate module documentation at the given path
pluginplay::printing::document_modules(mm, docs_path);
Example Program
The following code is a minimal example program generating documentation for the test modules in SDE. Modify the code according to the TODO comments to generate documentation for your modules.
#include <filesystem>
#include <pluginplay/printing/document_modules.hpp>
// TODO: Replace with the header containing your ``load_modules`` definition
#include "load_modules.hpp"
namespace fs = std::filesystem;
namespace pluginplay_examples {
int main(int argc, char** argv) {
// Need docs_path
// This example assumes it is the first command line argument, but this
// should be validated in actual code.
fs::path docs_path(argv[1]);
// Set up module manager
pluginplay::ModuleManager mm;
// TODO: Load your modules
pluginplay_examples::load_modules(mm);
// Generate module documentation at the given path
pluginplay::printing::document_modules(mm, docs_path);
return 0;
}
} // namespace pluginplay_examples