@@ -678,6 +678,7 @@ def output(
678678 cleanup : bool = True ,
679679 output_dir : Optional [Union [str , Path ]] = None ,
680680 output_name : Optional [str ] = None ,
681+ template_dir : Optional [Union [str , Path ]] = None ,
681682 ) -> None :
682683 """Render the harness in the requested formats.
683684
@@ -686,13 +687,34 @@ def output(
686687 ``filename`` is None, exactly one format must be requested and
687688 its bytes/text are written to stdout — supports piping the CLI
688689 into other tools.
690+
691+ Args:
692+ filename: Output base path (without extension). ``None``
693+ routes a single format to stdout instead of writing files.
694+ fmt: One or more formats from ``html``, ``png``, ``svg``,
695+ ``gv``, ``tsv``, ``csv``, ``pdf``. A bare string is
696+ normalized to a one-tuple.
697+ view: Reserved (unused — kept for API compatibility with the
698+ pre-refactor signature).
699+ cleanup: Reserved (unused — kept for API compatibility).
700+ output_dir: Output directory. Used only to populate the
701+ ``<!-- %filename% -->`` HTML template placeholder and to
702+ resolve a custom ``metadata.template.name`` reference.
703+ output_name: Output base name (without extension). Used only
704+ to populate the ``<!-- %filename_stem% -->`` HTML
705+ template placeholder.
706+ template_dir: Explicit directory to search first when
707+ resolving a ``metadata.template.name`` reference. Falls
708+ through to the YAML source directory, then ``output_dir``,
709+ then the built-in templates shipped with WireViz.
689710 """
690711 if isinstance (fmt , str ):
691712 fmt = (fmt ,)
692713 outputs : Dict [str , Union [str , bytes ]] = self ._render (
693714 fmt ,
694715 output_dir = output_dir ,
695716 output_name = output_name ,
717+ template_dir = template_dir ,
696718 )
697719
698720 if "csv" in fmt :
@@ -728,12 +750,33 @@ def _render(
728750 fmt : Union [str , Tuple [str , ...], List [str ]],
729751 output_dir : Optional [Union [str , Path ]] = None ,
730752 output_name : Optional [str ] = None ,
753+ template_dir : Optional [Union [str , Path ]] = None ,
731754 ) -> Dict [str , Union [str , bytes ]]:
732755 """Produce in-memory representations of each requested format.
733756
734757 Pipes graphviz once per binary output rather than via ``render()``
735758 + temporary files so the caller can write files OR pipe to stdout
736759 without the SVG-file roundtrip the previous implementation used.
760+
761+ Args:
762+ fmt: One or more formats from ``html``, ``png``, ``svg``,
763+ ``gv``, ``tsv``. ``csv`` and ``pdf`` are recognized at
764+ the dispatch layer but not produced here. A bare string
765+ is normalized to a one-tuple.
766+ output_dir: Forwarded to ``generate_html_output`` for
767+ ``<!-- %filename% -->`` and ``<!-- %diagram_png_b64% -->``
768+ template-placeholder resolution, and as the third-priority
769+ directory in the custom-template search path.
770+ output_name: Forwarded to ``generate_html_output`` for
771+ ``<!-- %filename_stem% -->`` resolution.
772+ template_dir: Forwarded to ``generate_html_output`` as the
773+ first-priority directory in the custom-template search
774+ path.
775+
776+ Returns:
777+ ``{format: bytes|str}``. Binary formats (``png``) yield
778+ bytes; text formats (``svg``, ``html``, ``gv``, ``tsv``)
779+ yield str.
737780 """
738781 if isinstance (fmt , str ):
739782 fmt = (fmt ,)
@@ -788,6 +831,7 @@ def _render(
788831 output_name = output_name ,
789832 png_b64 = png_b64 ,
790833 source_path = self .source_path ,
834+ template_dir = template_dir ,
791835 )
792836
793837 return outputs
0 commit comments