mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-12 12:57:13 +02:00
Api (#48)
* WIP * WIP * WIP * cleaned up multi * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * split up python module * WIP * WIP * WIP * WIP * WIP * ok * fixed bugs from rebase * WIP * fixed broken test * WIP * fixed python * WIP * sphinx help * including new commands * docs * WIP * WIP * more tests * added missing public header * WIP
This commit is contained in:
56
docs/src/gendoc.cpp
Normal file
56
docs/src/gendoc.cpp
Normal file
@ -0,0 +1,56 @@
|
||||
/**
|
||||
* Utility program to generate input files for the command line
|
||||
* documentation. Uses the string returned from sls_detector_help cmd
|
||||
*
|
||||
*/
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
||||
#include "CmdProxy.h"
|
||||
#include "Detector.h"
|
||||
#include "sls_detector_defs.h"
|
||||
|
||||
std::string replace_all(const std::string &src, const std::string &from,
|
||||
const std::string &to) {
|
||||
|
||||
std::string results;
|
||||
std::string::const_iterator end = src.end();
|
||||
std::string::const_iterator current = src.begin();
|
||||
std::string::const_iterator next =
|
||||
std::search(current, end, from.begin(), from.end());
|
||||
while (next != end) {
|
||||
results.append(current, next);
|
||||
results.append(to);
|
||||
current = next + from.size();
|
||||
next = std::search(current, end, from.begin(), from.end());
|
||||
}
|
||||
results.append(current, next);
|
||||
return results;
|
||||
}
|
||||
|
||||
int main() {
|
||||
|
||||
std::cout << "Generating command line documentation!\n";
|
||||
|
||||
sls::CmdProxy<sls::Detector> proxy(nullptr);
|
||||
auto commands = proxy.GetProxyCommands();
|
||||
|
||||
std::ofstream fs("commands.rst");
|
||||
fs << ".. glossary::\n";
|
||||
|
||||
for (const auto &cmd : commands) {
|
||||
std::ostringstream os;
|
||||
proxy.Call(cmd, {}, -1, slsDetectorDefs::HELP_ACTION, os);
|
||||
|
||||
auto tmp = os.str().erase(0, cmd.size());
|
||||
auto usage = tmp.substr(0, tmp.find_first_of('\n'));
|
||||
tmp.erase(0, usage.size());
|
||||
auto help = replace_all(tmp, "\n\t", "\n\t\t");
|
||||
fs << '\t' << cmd << usage << help << "\n";
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user