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

Added Jinja2 blocks for navigation module, submodule and and index. #521

Merged
merged 5 commits into from
Mar 15, 2023
Merged
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

<!-- ✨ You do not need to add a pull request reference or an author, this will be added automatically by CI. ✨ -->

- Add additional Jinja2 blocks to allow a more fine-grained customization of the menu.
([#521](https://github.com/mitmproxy/pdoc/pull/521), @mikkelakromann)

## 2023-02-19: pdoc 13.0.0

Expand Down
40 changes: 23 additions & 17 deletions pdoc/templates/default/module.html.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -34,25 +34,31 @@
{% endif %}
{% endblock %}

{% set index = module.docstring | to_markdown | to_html | attr("toc_html") %}
{% if index %}
<h2>Contents</h2>
{{ index | safe }}
{% endif %}
{% block nav_index %}
{% set index = module.docstring | to_markdown | to_html | attr("toc_html") %}
{% if index %}
<h2>Contents</h2>
{{ index | safe }}
{% endif %}
{% endblock %}

{% if module.submodules %}
<h2>Submodules</h2>
<ul>
{% for submodule in module.submodules if is_public(submodule) | trim %}
<li>{{ submodule.taken_from | link(text=submodule.name) }}</li>
{% endfor %}
</ul>
{% endif %}
{% block nav_submodules %}
{% if module.submodules %}
<h2>Submodules</h2>
<ul>
{% for submodule in module.submodules if is_public(submodule) | trim %}
<li>{{ submodule.taken_from | link(text=submodule.name) }}</li>
{% endfor %}
</ul>
{% endif %}
{% endblock %}

{% if module.members %}
<h2>API Documentation</h2>
{{ nav_members(module.members.values()) }}
{% endif %}
{% block nav_members %}
{% if module.members %}
<h2>API Documentation</h2>
{{ nav_members(module.members.values()) }}
{% endif %}
{% endblock %}

{% block nav_footer %}
{% if footer_text %}
Expand Down
4 changes: 2 additions & 2 deletions test/testdata/demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@



<h2>API Documentation</h2>
<ul class="memberlist">
<h2>API Documentation</h2>
<ul class="memberlist">
<li>
<a class="class" href="#Dog">Dog</a>
<ul class="memberlist">
Expand Down
4 changes: 2 additions & 2 deletions test/testdata/demo_eager.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@



<h2>API Documentation</h2>
<ul class="memberlist">
<h2>API Documentation</h2>
<ul class="memberlist">
<li>
<a class="function" href="#foo">foo</a>
</li>
Expand Down
8 changes: 4 additions & 4 deletions test/testdata/demo_long.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@
<div>


<h2>Contents</h2>
<ul>
<h2>Contents</h2>
<ul>
<li><a href="#test-module">Test Module</a></li>
<li><a href="#a-second-section">A Second Section</a></li>
</ul>



<h2>API Documentation</h2>
<ul class="memberlist">
<h2>API Documentation</h2>
<ul class="memberlist">
<li>
<a class="variable" href="#FOO_CONSTANT">FOO_CONSTANT</a>
</li>
Expand Down
18 changes: 9 additions & 9 deletions test/testdata/demopackage.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@
pattern=".+" required>


<h2>Submodules</h2>
<ul>
<li><a href="demopackage/child_b.html">child_b</a></li>
<li><a href="demopackage/child_c.html">child_c</a></li>
<li><a href="demopackage/_child_e.html">_child_e</a></li>
</ul>

<h2>API Documentation</h2>
<ul class="memberlist">
<h2>Submodules</h2>
<ul>
<li><a href="demopackage/child_b.html">child_b</a></li>
<li><a href="demopackage/child_c.html">child_c</a></li>
<li><a href="demopackage/_child_e.html">_child_e</a></li>
</ul>

<h2>API Documentation</h2>
<ul class="memberlist">
<li>
<a class="class" href="#Test">Test</a>
<ul class="memberlist">
Expand Down
28 changes: 14 additions & 14 deletions test/testdata/demopackage_dir.html
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,8 @@ <h3>demopackage2.html</h3>



<h2>API Documentation</h2>
<ul class=&quot;memberlist&quot;>
<h2>API Documentation</h2>
<ul class=&quot;memberlist&quot;>
</ul>


Expand Down Expand Up @@ -556,15 +556,15 @@ <h3>demopackage.html</h3>
pattern=&quot;.+&quot; required>


<h2>Submodules</h2>
<ul>
<li><a href=&quot;demopackage/child_b.html&quot;>child_b</a></li>
<li><a href=&quot;demopackage/child_c.html&quot;>child_c</a></li>
<li><a href=&quot;demopackage/_child_e.html&quot;>_child_e</a></li>
</ul>
<h2>Submodules</h2>
<ul>
<li><a href=&quot;demopackage/child_b.html&quot;>child_b</a></li>
<li><a href=&quot;demopackage/child_c.html&quot;>child_c</a></li>
<li><a href=&quot;demopackage/_child_e.html&quot;>_child_e</a></li>
</ul>

<h2>API Documentation</h2>
<ul class=&quot;memberlist&quot;>
<h2>API Documentation</h2>
<ul class=&quot;memberlist&quot;>
<li>
<a class=&quot;class&quot; href=&quot;#Test&quot;>Test</a>
<ul class=&quot;memberlist&quot;>
Expand Down Expand Up @@ -1020,8 +1020,8 @@ <h3>demopackage/child_c.html</h3>



<h2>API Documentation</h2>
<ul class=&quot;memberlist&quot;>
<h2>API Documentation</h2>
<ul class=&quot;memberlist&quot;>
<li>
<a class=&quot;class&quot; href=&quot;#C&quot;>C</a>
<ul class=&quot;memberlist&quot;>
Expand Down Expand Up @@ -1339,8 +1339,8 @@ <h3>demopackage/child_b.html</h3>



<h2>API Documentation</h2>
<ul class=&quot;memberlist&quot;>
<h2>API Documentation</h2>
<ul class=&quot;memberlist&quot;>
<li>
<a class=&quot;class&quot; href=&quot;#B&quot;>B</a>
<ul class=&quot;memberlist&quot;>
Expand Down
4 changes: 2 additions & 2 deletions test/testdata/example_customtemplate.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@



<h2>API Documentation</h2>
<ul class="memberlist">
<h2>API Documentation</h2>
<ul class="memberlist">
<li>
<a class="class" href="#Dog">Dog</a>
<ul class="memberlist">
Expand Down
4 changes: 2 additions & 2 deletions test/testdata/example_darkmode.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@



<h2>API Documentation</h2>
<ul class="memberlist">
<h2>API Documentation</h2>
<ul class="memberlist">
<li>
<a class="class" href="#Dog">Dog</a>
<ul class="memberlist">
Expand Down
4 changes: 2 additions & 2 deletions test/testdata/flavors_google.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@



<h2>API Documentation</h2>
<ul class="memberlist">
<h2>API Documentation</h2>
<ul class="memberlist">
<li>
<a class="variable" href="#module_level_variable2">module_level_variable2</a>
</li>
Expand Down
4 changes: 2 additions & 2 deletions test/testdata/flavors_numpy.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@



<h2>API Documentation</h2>
<ul class="memberlist">
<h2>API Documentation</h2>
<ul class="memberlist">
<li>
<a class="variable" href="#module_level_variable2">module_level_variable2</a>
</li>
Expand Down
4 changes: 2 additions & 2 deletions test/testdata/flavors_rst.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@



<h2>API Documentation</h2>
<ul class="memberlist">
<h2>API Documentation</h2>
<ul class="memberlist">
<li>
<a class="function" href="#links">links</a>
</li>
Expand Down
8 changes: 4 additions & 4 deletions test/testdata/math_demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,17 @@
<div>


<h2>Contents</h2>
<ul>
<h2>Contents</h2>
<ul>
<li><a href="#using-math-in-docstrings">Using Math in Docstrings</a></li>
<li><a href="#advanced-usage">Advanced Usage</a></li>
<li><a href="#example">Example</a></li>
</ul>



<h2>API Documentation</h2>
<ul class="memberlist">
<h2>API Documentation</h2>
<ul class="memberlist">
<li>
<a class="function" href="#binom_coef">binom_coef</a>
</li>
Expand Down
4 changes: 2 additions & 2 deletions test/testdata/misc.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@



<h2>API Documentation</h2>
<ul class="memberlist">
<h2>API Documentation</h2>
<ul class="memberlist">
<li>
<a class="class" href="#Issue226">Issue226</a>
<ul class="memberlist">
Expand Down
4 changes: 2 additions & 2 deletions test/testdata/misc_py310.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@



<h2>API Documentation</h2>
<ul class="memberlist">
<h2>API Documentation</h2>
<ul class="memberlist">
<li>
<a class="function" href="#new_union">new_union</a>
</li>
Expand Down
4 changes: 2 additions & 2 deletions test/testdata/misc_py311.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@



<h2>API Documentation</h2>
<ul class="memberlist">
<h2>API Documentation</h2>
<ul class="memberlist">
<li>
<a class="class" href="#CustomException">CustomException</a>
<ul class="memberlist">
Expand Down
4 changes: 2 additions & 2 deletions test/testdata/misc_py39.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@



<h2>API Documentation</h2>
<ul class="memberlist">
<h2>API Documentation</h2>
<ul class="memberlist">
<li>
<a class="class" href="#NamedTupleExample">NamedTupleExample</a>
<ul class="memberlist">
Expand Down
8 changes: 4 additions & 4 deletions test/testdata/render_options.html
Original file line number Diff line number Diff line change
Expand Up @@ -92,17 +92,17 @@ <h3>math_demo.html</h3>
<a href=&quot;https://example.com/&quot;> <img src=&quot;https://placedog.net/500?random&quot; class=&quot;logo&quot; alt=&quot;project logo&quot;/>
</a>

<h2>Contents</h2>
<ul>
<h2>Contents</h2>
<ul>
<li><a href=&quot;#using-math-in-docstrings&quot;>Using Math in Docstrings</a></li>
<li><a href=&quot;#advanced-usage&quot;>Advanced Usage</a></li>
<li><a href=&quot;#example&quot;>Example</a></li>
</ul>



<h2>API Documentation</h2>
<ul class=&quot;memberlist&quot;>
<h2>API Documentation</h2>
<ul class=&quot;memberlist&quot;>
<li>
<a class=&quot;function&quot; href=&quot;#binom_coef&quot;>binom_coef</a>
</li>
Expand Down
4 changes: 2 additions & 2 deletions test/testdata/top_level_reimports.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@



<h2>API Documentation</h2>
<ul class="memberlist">
<h2>API Documentation</h2>
<ul class="memberlist">
<li>
<a class="class" href="#Foo">Foo</a>
<ul class="memberlist">
Expand Down
4 changes: 2 additions & 2 deletions test/testdata/type_checking_imports.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@



<h2>API Documentation</h2>
<ul class="memberlist">
<h2>API Documentation</h2>
<ul class="memberlist">
<li>
<a class="function" href="#foo">foo</a>
</li>
Expand Down
4 changes: 2 additions & 2 deletions test/testdata/type_stub.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@



<h2>API Documentation</h2>
<ul class="memberlist">
<h2>API Documentation</h2>
<ul class="memberlist">
<li>
<a class="function" href="#func">func</a>
</li>
Expand Down