Skip to content
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
3 changes: 2 additions & 1 deletion src/wireviz/Harness.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class Harness:
metadata: Metadata
options: Options
tweak: Tweak
source_path: Path
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
source_path: Path
input_folders: Union[str, Path, List]


def __post_init__(self):
self.connectors = {}
Expand Down Expand Up @@ -697,7 +698,7 @@ def output(
print("CSV output is not yet supported")
# HTML output
if "html" in fmt:
generate_html_output(filename, bomlist, self.metadata, self.options)
generate_html_output(filename, bomlist, self.metadata, self.options, self.source_path)
Copy link
Collaborator

@kvid kvid Jul 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
generate_html_output(filename, bomlist, self.metadata, self.options, self.source_path)
generate_html_output(
filename, bomlist, self.metadata, self.options, self.input_folders
)

The splitting into multiple lines is due to black formatting.

# PDF output
if "pdf" in fmt:
# TODO: implement PDF output
Expand Down
2 changes: 2 additions & 0 deletions src/wireviz/wireviz.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def parse(
output_dir: Union[str, Path] = None,
output_name: Union[None, str] = None,
image_paths: Union[Path, str, List] = [],
source_path = None,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
source_path = None,

) -> Any:
"""
This function takes an input, parses it as a WireViz Harness file,
Expand Down Expand Up @@ -115,6 +116,7 @@ def parse(
metadata=Metadata(**yaml_data.get("metadata", {})),
options=Options(**yaml_data.get("options", {})),
tweak=Tweak(**yaml_data.get("tweak", {})),
source_path=source_path
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest reusing the existing image_paths that already has collected all input folders:

Suggested change
source_path=source_path
input_folders=image_paths,

)
# others
# store mapping of components to their respective template
Expand Down
1 change: 1 addition & 0 deletions src/wireviz/wv_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ def wireviz(file, format, prepend, output_dir, output_name, version):
output_dir=_output_dir,
output_name=_output_name,
image_paths=list(image_paths),
source_path=file
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
source_path=file

)

print()
Expand Down
9 changes: 7 additions & 2 deletions src/wireviz/wv_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,19 @@ def generate_html_output(
bom_list: List[List[str]],
metadata: Metadata,
options: Options,
source: Union[str, Path] = None,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
source: Union[str, Path] = None,
input_folders: Union[str, Path, List] = [],

):
# load HTML template
templatename = metadata.get("template", {}).get("name")
template_search_paths = [ Path(filename).parent, Path(__file__).parent / "templates"]

if source is not None:
template_search_paths.insert(0, Path(source).parent)

Comment on lines +28 to +32
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
template_search_paths = [ Path(filename).parent, Path(__file__).parent / "templates"]
if source is not None:
template_search_paths.insert(0, Path(source).parent)

if templatename:
# if relative path to template was provided, check directory of YAML file first, fall back to built-in template directory
templatefile = smart_file_resolve(
f"{templatename}.html",
[Path(filename).parent, Path(__file__).parent / "templates"],
f"{templatename}.html", template_search_paths
Copy link
Collaborator

@kvid kvid Jul 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remember inserting from wireviz.wv_bom import make_list in the import section above and run isort *.py to format and sort them. (Github don't allow me to directly suggest changes at lines more than a few lines away from existing PR changes.)

Suggested change
f"{templatename}.html", template_search_paths
f"{templatename}.html",
make_list(input_folders) + [Path(__file__).parent / "templates"],

My suggestion here does not add the output folder in the list when different because I don't see any use case where that might be useful, but please argue against my suggestion.

)
else:
# fall back to built-in simple template if no template was provided
Expand Down