Skip to content

Commit

Permalink
Merge pull request #672 from d7919/experimental/allow_user_specified_…
Browse files Browse the repository at this point in the history
…html_template_directory

Experimental/allow user specified html template directory
  • Loading branch information
ZedThree authored Dec 18, 2024
2 parents 68afe6e + 85dfd44 commit 96933e5
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
12 changes: 12 additions & 0 deletions docs/user_guide/project_file_options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,18 @@ directory that starts with ``test`` anywhere in the source directory tree.
exclude_dir: **/test*
src/internal
.. _option-html_template_dir:

html_template_dir
^^^^^^^^^^^^^^^^^

A list of directories to search for HTML templates.

.. caution:: This is an experimental feature!

You will most likely want to copy-paste the existing templates and
modify them. They are not well documented, so use at your own risk!

.. _option-include:

include
Expand Down
5 changes: 4 additions & 1 deletion ford/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@

loc = pathlib.Path(__file__).parent
env = jinja2.Environment(
loader=jinja2.FileSystemLoader(loc / "templates"),
trim_blocks=True,
lstrip_blocks=True,
)
Expand Down Expand Up @@ -120,6 +119,10 @@ def __init__(self, settings: ProjectSettings, proj_docs: str, project, pagetree)
# Also, in future for other template, we may not need to
# pass the data obj.
env.globals["projectData"] = asdict(settings)
env.loader=jinja2.FileSystemLoader(
settings.html_template_dir + [loc / "templates"]
)

self.project = project
self.settings = settings
# Jinja2's `if` statement counts `None` as truthy, so to avoid
Expand Down
1 change: 1 addition & 0 deletions ford/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ class ProjectSettings:
graph_maxdepth: int = 10000
graph_maxnodes: int = 1000000000
hide_undoc: bool = False
html_template_dir: List[Path] = field(default_factory=list)
incl_src: bool = True
include: List[Path] = field(default_factory=list)
license: str = ""
Expand Down

0 comments on commit 96933e5

Please sign in to comment.