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 Writing a Plugin.
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 pluginplay::printing::document_modules function and the
header declaring your plugin.
#include <filesystem>
// TODO: Replace with the header declaring your plugin
#include "pluginplay_examples.hpp"
Next, set up a pluginplay::ModuleManager and load your plugin.
// Set up module manager
pluginplay::ModuleManager mm;
// TODO: Load your plugin
mm.load_plugin<pluginplay_examples::PluginplayExamples>();
The final step is to generate documentation through
pluginplay::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 PluginPlay. A plugin’s modules are documented in a subdirectory of the output directory, named after the plugin. 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 declaring your plugin
#include "pluginplay_examples.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 plugin
mm.load_plugin<pluginplay_examples::PluginplayExamples>();
// Generate module documentation at the given path
pluginplay::printing::document_modules(mm, docs_path);
return 0;
}
} // namespace pluginplay_examples