HTML code generator

A complete HTML page can be generated, with register details as well as textual description of the different register modes. This is done by using the HtmlPageGenerator class e.g. like this:

Python code that parses the example TOML file and generates the HTML code we need.
 1# Standard libraries
 2import sys
 3from pathlib import Path
 4
 5# First party libraries
 6from hdl_registers.generator.html.constant_table import HtmlConstantTableGenerator
 7from hdl_registers.generator.html.page import HtmlPageGenerator
 8from hdl_registers.generator.html.register_table import HtmlRegisterTableGenerator
 9from hdl_registers.parser.toml import from_toml
10
11THIS_DIR = Path(__file__).parent
12
13
14def main(output_folder: Path):
15    """
16    Create register HTML artifacts from the TOML example file.
17    """
18    register_list = from_toml(
19        name="example",
20        toml_file=THIS_DIR.parent.parent / "user_guide" / "toml" / "toml_format.toml",
21    )
22
23    HtmlPageGenerator(register_list=register_list, output_folder=output_folder).create()
24    HtmlRegisterTableGenerator(register_list=register_list, output_folder=output_folder).create()
25    HtmlConstantTableGenerator(register_list=register_list, output_folder=output_folder).create()
26
27
28if __name__ == "__main__":
29    main(output_folder=Path(sys.argv[1]))

A HTML page generated from the TOML format example can be viewed here: example_regs.html

Note

Markdown/reStructuredText syntax can be used in register and bit descriptions, which will be converted to appropriate HTML tags. Text can be set bold with double asterisks, and italicised with a single asterisk. A paragraph break can be inserted with consecutive newlines.

Tables only

Optionally, only the tables with register and constant descriptions can be generated to HTML, using the HtmlRegisterTableGenerator and HtmlConstantTableGenerator classes. These can be included in a separate documentation flow.

Generated HTML file here: example_register_table.html

Generated HTML file here: example_constant_table.html