D.1 Markup#
[1] API functions#
rivt has six API functions. The name rivt is an acronym taken from the four functions that process content. The remaining three functions are used for document generation and debugging.
Content APIs- [R]un Runs Python scripts and markup.
- [I]nsert Adds static tables, images and equations.
- [V]alues Evaluates equations and functions.
- [T]ools Executes shell scripts and external programs.
Publish APIs
- [D]oc specifies the doc type and style.
- [S]kip, e[X]it can be used for interactive debugging and comments.
API Function |
Name |
Purpose |
|---|---|---|
rv.R (rS) |
Run |
Run scripts and markup |
rv.I (rS) |
Insert |
Insert static sources |
rv.V (rS) |
Values |
Calculate values |
rv.T (rS) |
Tools |
Shell scripts and external programs |
rv.D (rS) |
Doc |
Publish docs |
rv.S,X (rS) |
Skip, Exit |
Skip section, exit (comments and debugging) |
API functions define doc sections. The available rivt markup commands and tags depends on the API funciton. If interactive IDEs are used, API functions can be processed individually using the standard notebook cell percent notation:
# %% optional label
rv.API("""rivt string""")
[2] rivt string#
Each API function takes a triple quoted rivt string argument composed of a header substring line followed by a multiple-line content substring. The header substring defines section processing parameters. The content substring includes rivt markup and is indented four spaces for improved readability and navigation (e.g. section folding).
Header substring
The header substring starts with a section label, used as the section title, followed by a vertical bar and three comma separated section parameters that override default behavior.
rv._("""Section Label | doc;stored, private;public, section;merge
Content substring indented 4 spaces
...
""")
The header parameters include the following comma separated values in any order:
- private/public
Determines whether the API section text is copied to the the Public folder rivt file for sharing.
- doc/stored
Determines whether the rivt string is formatted and printed in the doc, or just annotated in the doc and written to a file in the Stored folder for optional inclusion as an appendix.
- section/merge
Determines whether the API starts a new doc section or is merged into the previous section.
Default settings in the header substring do not need to be specified. The default setting for each API is listed first (in bold) in the table below. The default privacy settings for all sections in a rivt file may be reversed by including the public comment setting immeditely following the rivlib import statement.
import rivtlib.rvapi as rv
# rv setpublic = true
Individual sections may still be set as private in the header substring.
API |
private; public |
doc; stored |
section; merge |
|---|---|---|---|
rv.R |
private; public |
stored; doc |
merge; section |
rv.I |
private; public |
doc; stored |
section; merge |
rv.V |
private; public |
doc; stored |
section; merge |
rv.T |
private; public |
stored; doc |
merge; section |
rv.S |
private; public |
stored |
merge |
rv.D |
public |
stored |
merge |
rv.X |
Examples of header substring settings are shown below.
An example with explicit defaults (they do not have to be declared).
# This
rv.I("""A New Section | private, doc, section
Content text
...
""")
# is equivalent to:
rv.I("""A New Section
Content text
...
""")
An example that merges a section into the previous section.
rv.I("""A Merged Section | merge
Content text
...
""")
Content substring
The content substring is indented four spaces for legibility and code folding. It includes line tags, block tags and commands along with text.
rv._("""Section Label
Content text indented 4 spaces.
...
""")
Content is converted line by line into formatted text and RestructuredText, and then further processed into HTML or PDF. If a line does not contain a command or tag it is passed through as is, which allows for the Insert function (rv.I) including some restructured text directly i.e. surrounding words with * or ** will format a word as italic or bold respectively.
In addition block tags in the Tools function (rv.T) directly supports processing HTML, LaTeX and reStructuredText scripts.
[4] Folders#
<p style=”border-width:2px; border-style:solid; border-color:#49b2c3;padding: 1em;”>
<b>Folder Names</b><br> <br>
A rivt folder can contain any set of files and folders but the following structure is required for <i>doc</i> processing. Files and folders are organized under a root folder with the prefix <i>rivt-</i> e.g. <i>rivt-Report-Label</i>. <br> <br>
<i>rivt folders</i> (root folders) include at least the <i>rivt files</i> and the five required subfolders. Required folders and prefixes are shown in brackets. Folders preceded by an underscore contain rivt outputs. Folders requiring author input are capitalized. <br> <br>
The top level folder structure is shown below. A more detailed description of the folder structure is here.
Top Level Folders
rivt-Report-Label/ Report Folder
├── .vscode/ optional VSCode settings
├── rivt-public_/ rivt-generated public files
├── rvsrc/ source files
├── README.txt public text report or doc
├── rv-101-filename1.py public rivt file
├── rv-102-filename2.py public rivt file
├── rv-201-filename3.py public rivt file
...
└── rivt-report/ rivt files and docs
├── _published/ published docs and reports
├── _rstdocs/ intermediate restructured text files
├── rv_stor/ rivt generated stored files
├── rvsrc/ author source files
├── rivt-report.py report generating script
├── rv101-filename1.py rivt file
├── rv102-filename2.py rivt file
├── rv201-filename3.py rivt file
...
└── README.txt text report or doc