From 7a55c86b141a57f848941d601c1569c120446d82 Mon Sep 17 00:00:00 2001 From: Hugh Jackson Date: Wed, 2 Aug 2023 12:24:02 +0100 Subject: [PATCH] Add option to use systemrdl name property in sidebar --- src/peakrdl_html/exporter.py | 10 ++++++++++ src/peakrdl_html/static/js/sidebar.js | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/peakrdl_html/exporter.py b/src/peakrdl_html/exporter.py index dc545b7..2c5cdb7 100755 --- a/src/peakrdl_html/exporter.py +++ b/src/peakrdl_html/exporter.py @@ -51,6 +51,8 @@ def __init__(self, **kwargs: 'Any') -> None: table in the node's description. Use this to bring forward user-defined properties, or other built-in properties in your documentation. + rdl_name_in_sidebar: bool + Use systemRDL name property in sidebar instead of instance name (if available). Default is False """ self.output_dir = "" # type: str self.RALData = [] # type: List[Dict[str, Any]] @@ -70,6 +72,7 @@ def __init__(self, **kwargs: 'Any') -> None: self.generate_source_links = kwargs.pop("generate_source_links", True) gmtu_translators = kwargs.pop("gitmetheurl_translators", None) user_template_dir = kwargs.pop("user_template_dir", None) + self.rdl_name_in_sidebar = kwargs.pop("rdl_name_in_sidebar", False) # Check for stray kwargs if kwargs: @@ -196,10 +199,17 @@ def visit_addressable_node(self, node: Node, parent_id: 'Optional[int]'=None) -> self.indexer.add_node(node, this_id) + # Set display name based on user input and presence of name property + if self.rdl_name_in_sidebar: + display_name = node.get_property('name', default=node.inst.inst_name) + else: + display_name = node.inst.inst_name + ral_entry = { 'parent' : parent_id, 'children' : child_ids, 'name' : node.inst.inst_name, + 'display' : display_name, 'offset' : BigInt(node.inst.addr_offset), 'size' : BigInt(node.size), } diff --git a/src/peakrdl_html/static/js/sidebar.js b/src/peakrdl_html/static/js/sidebar.js index 166d760..43596b0 100644 --- a/src/peakrdl_html/static/js/sidebar.js +++ b/src/peakrdl_html/static/js/sidebar.js @@ -145,13 +145,13 @@ class Sidebar { link.className = "node-link"; link.onclick = onClickTreeLink; if(RAL.is_array(id)){ - var txt = node.name; + var txt = node.display; for(var i=0; i