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:
1import sys
2from pathlib import Path
3
4from hdl_registers.generator.html.constant_table import HtmlConstantTableGenerator
5from hdl_registers.generator.html.page import HtmlPageGenerator
6from hdl_registers.generator.html.register_table import HtmlRegisterTableGenerator
7from hdl_registers.parser.toml import from_toml
8
9THIS_DIR = Path(__file__).parent
10
11
12def main(output_folder: Path) -> None:
13 """
14 Create register HTML artifacts from the TOML example file.
15 """
16 register_list = from_toml(
17 name="example",
18 toml_file=THIS_DIR.parent.parent / "user_guide" / "toml" / "toml_format.toml",
19 )
20
21 HtmlPageGenerator(register_list=register_list, output_folder=output_folder).create()
22 HtmlRegisterTableGenerator(register_list=register_list, output_folder=output_folder).create()
23 HtmlConstantTableGenerator(register_list=register_list, output_folder=output_folder).create()
24
25
26if __name__ == "__main__":
27 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