![]() |
ModelSpace
|
Class to document from code. More...
#include <AutoDoc.h>
Public Member Functions | |
AutoDoc (unsigned int string_alloc=4096) | |
Default constructor for the AutoDoc class. | |
~AutoDoc () | |
Destructor – just closes our file. | |
int | file (const std::string &filename) |
Function to set the file for write and redirect output to that file. | |
std::string | file () |
int | title (const std::string &str) |
Function to write a title to the document. | |
int | author (const std::string &name, const std::string &email="") |
Function to write author name and email to document. | |
int | addPrimaryHeader (const std::string &str) |
Function to add a primary header to document. | |
int | addSecondaryHeader (const std::string &str) |
Function to add a secondary header to document. | |
int | addText (const std::string &str) |
Function to add an exact string to a document. | |
int | addImage (const std::string &file, const std::string &alias="") |
Function to add an image to the document. | |
int | addTable (const std::vector< std::vector< std::string > > &data, const std::vector< std::string > &col_headers={}, const std::vector< std::string > &row_headers={}, bool write_method=true) |
Function to write a table to our document. | |
int | addTable (const std::vector< std::vector< long int > > &data, const std::vector< std::string > &col_headers={}, const std::vector< std::string > &row_headers={}, bool write_method=true) |
Function to write a table to our document. | |
int | addTable (const std::vector< std::vector< double > > &data, const std::vector< std::string > &col_headers={}, const std::vector< std::string > &row_headers={}, bool write_method=true) |
Function to write a table to our document. | |
int | addCodeBlock (const std::string &str) |
Function to add a code block to a document. | |
int | addLink (const std::string &link, const std::string &alias="") |
Function to add an external link to the document. | |
int | addDocReference (const std::string &name, const std::string &alias="") |
Function to add a link to another asciidoc document. | |
void | closeFile () |
Function to close the file held internally by AutoDoc. | |
Class to document from code.
This class writes output from code, including strings, tables, images, and links, to an asciidoc document. It can write to a file specified by call to the file function, or to an internal string which can later be written to file.
The autodoc class is one of the most useful features of ModelSpace and allows users to generate an automated document from their analysis products easily and painlessly. It is extended into other languages, notably Python, via extensions implemented in those languages e.g. to integrate with matplotlib.
The generated document is in plaintext format, and needs to be rendered via asciidoctor or another document generation tool into HTML. Documents generated by autodoc (and, indeed, any .adoc file generated in the ModelSpace framework) can be previewed by pressing ctrl + shift + p with the .adoc file open, so long as appropriate extensions are installed.
modelspace::AutoDoc::AutoDoc | ( | unsigned int | string_alloc = 4096 | ) |
Default constructor for the AutoDoc class.
(Optional) | The number of bytes to allocate for our buffering string. By default allocated 4 kB |
int modelspace::AutoDoc::addCodeBlock | ( | const std::string & | str | ) |
Function to add a code block to a document.
str | The string to add to the code block |
int modelspace::AutoDoc::addDocReference | ( | const std::string & | name, |
const std::string & | alias = "" |
||
) |
Function to add a link to another asciidoc document.
name | The name of the document to add |
alias | Name the link will appear under – not used by default |
int modelspace::AutoDoc::addImage | ( | const std::string & | file, |
const std::string & | alias = "" |
||
) |
Function to add an image to the document.
file | The image file to add |
alias | The name the image will be added as – defaults to image |
int modelspace::AutoDoc::addLink | ( | const std::string & | link, |
const std::string & | alias = "" |
||
) |
Function to add an external link to the document.
link | The link to add to the document |
alias | Name the link will appear under – not used by default |
int modelspace::AutoDoc::addPrimaryHeader | ( | const std::string & | str | ) |
Function to add a primary header to document.
str | The header text |
int modelspace::AutoDoc::addSecondaryHeader | ( | const std::string & | str | ) |
Function to add a secondary header to document.
str | The header text |
int modelspace::AutoDoc::addTable | ( | const std::vector< std::vector< double > > & | data, |
const std::vector< std::string > & | col_headers = {} , |
||
const std::vector< std::string > & | row_headers = {} , |
||
bool | write_method = true |
||
) |
Function to write a table to our document.
data | The data to write to the table |
col_headers | The headers for each column. Default is empty (unused) |
row_headers | The headers for each row. Default is empty (unused) |
write_method | Flag to set whether data is organized by column (default) or row If column, then each vector element in data represents a column. If row, then each vector element represents a row. |
int modelspace::AutoDoc::addTable | ( | const std::vector< std::vector< long int > > & | data, |
const std::vector< std::string > & | col_headers = {} , |
||
const std::vector< std::string > & | row_headers = {} , |
||
bool | write_method = true |
||
) |
Function to write a table to our document.
data | The data to write to the table |
col_headers | The headers for each column. Default is empty (unused) |
row_headers | The headers for each row. Default is empty (unused) |
write_method | Flag to set whether data is organized by column (default) or row If column, then each vector element in data represents a column. If row, then each vector element represents a row. |
int modelspace::AutoDoc::addTable | ( | const std::vector< std::vector< std::string > > & | data, |
const std::vector< std::string > & | col_headers = {} , |
||
const std::vector< std::string > & | row_headers = {} , |
||
bool | write_method = true |
||
) |
Function to write a table to our document.
data | The data to write to the table |
col_headers | The headers for each column. Default is empty (unused) |
row_headers | The headers for each row. Default is empty (unused) |
write_method | Flag to set whether data is organized by column (default) or row If column, then each vector element in data represents a column. If row, then each vector element represents a row. |
int modelspace::AutoDoc::addText | ( | const std::string & | str | ) |
Function to add an exact string to a document.
str | The string to add |
int modelspace::AutoDoc::author | ( | const std::string & | name, |
const std::string & | email = "" |
||
) |
Function to write author name and email to document.
name | The author's name |
The author's email. Defaults to nothing |
int modelspace::AutoDoc::file | ( | const std::string & | filename | ) |
Function to set the file for write and redirect output to that file.
filename | The filename to write to |
int modelspace::AutoDoc::title | ( | const std::string & | str | ) |
Function to write a title to the document.
str | The document title |