Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to use systemrdl name property in sidebar #42

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/peakrdl_html/exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]]
Expand All @@ -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:
Expand Down Expand Up @@ -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),
}
Expand Down
4 changes: 2 additions & 2 deletions src/peakrdl_html/static/js/sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -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<node.dims.length; i++) {
txt += "[]";
}
link.innerHTML = txt;
} else {
link.innerHTML = node.name;
link.innerHTML = node.display;
}
div.appendChild(link);

Expand Down