Skip to content

Commit a6bd221

Browse files
committed
docs: issue2551317 add support for jinja2 customization examples
Added sphinx-tabs to doc build. This allows adding code-tabs one for "TAL" examples and one for "Jinja2" examples in the doc. Converted partly the "Editing multiple items in an index view" example. Sombody who knows jinja2 better than I, and can test the example will need to finish it. Documented requirement and method for building docs in developers.txt. Added requirements.pip files for pip install -r ... modules needed for processing docs. Fixed missing block in layout.txt that stopped tabs.css from being loaded.
1 parent b4dbc33 commit a6bd221

File tree

8 files changed

+96
-22
lines changed

8 files changed

+96
-22
lines changed

CHANGES.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ Features:
110110
- issue2551274: add configurable logging for REST API when something
111111
fails, we now log status code and error message.
112112
(Ralf Schlatterbeck)
113+
- issue2551317 - add some Jinja2 examples to customizing.txt
114+
document. (John Rouillard)
113115

114116
2023-07-13 2.3.0
115117

doc/conf.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@
5151
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
5252
# ones.
5353
#extensions = ['toctree']
54+
extensions = ['sphinx_tabs.tabs']
55+
56+
sphinx_tabs_valid_builders = ['linkcheck']
57+
sphinx_tabs_disable_tab_closing = True
5458

5559
# Add any paths that contain templates here, relative to this directory.
5660
templates_path = ['_templates']

doc/customizing.txt

Lines changed: 59 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1864,43 +1864,82 @@ To edit the status of all items in the item index view, edit the
18641864
``issue.index.html``:
18651865

18661866
1. add a form around the listing table (separate from the existing
1867-
index-page form), so at the top it reads::
1867+
index-page form), so at the top it reads:
18681868

1869-
<form method="POST" tal:attributes="action request/classname">
1870-
<table class="list">
1869+
.. tabs::
18711870

1872-
and at the bottom of that table::
1871+
.. code-tab:: html TAL
1872+
1873+
<form method="POST" tal:attributes="action request/classname">
1874+
<table class="list">
1875+
1876+
.. code-tab:: html Jinja2
1877+
1878+
<form method="POST" action='issue{{ context.id }}' class='form-inline'>
1879+
<table class="list">
1880+
1881+
1882+
and at the bottom of that table add::
18731883

18741884
</table>
18751885
</form
18761886

18771887
making sure you match the ``</table>`` from the list table, not the
18781888
navigation table or the subsequent form table.
18791889

1880-
2. in the display for the issue property, change::
1890+
2. in the display for the issue property, change:
18811891

1882-
<td tal:condition="request/show/status"
1883-
tal:content="python:i.status.plain() or default">&nbsp;</td>
1892+
.. tabs::
18841893

1885-
to::
1894+
.. code-tab:: html TAL
1895+
1896+
<td tal:condition="request/show/status"
1897+
tal:content="python:i.status.plain() or default">&nbsp;</td>
1898+
1899+
.. code-tab:: html Jinja2
1900+
1901+
{% if request.show.status %}
1902+
<td>{{ issue.status.plain()|u }}</td>
1903+
{% endif %}
1904+
1905+
to:
1906+
1907+
.. tabs::
18861908

1887-
<td tal:condition="request/show/status"
1888-
tal:content="structure i/status/field">&nbsp;</td>
1909+
.. code-tab:: html TAL
18891910

1911+
<td tal:condition="request/show/status"
1912+
tal:content="structure i/status/field">&nbsp;</td>
1913+
1914+
.. code-tab:: html Jinja2
1915+
1916+
{% if request.show.status %}
1917+
<td>{{ issue.status.menu()|u|safe }}</td>
1918+
{% endif %}
1919+
<!-- untested -->
1920+
18901921
this will result in an edit field for the status property.
18911922

18921923
3. after the ``tal:block`` which lists the index items (marked by
1893-
``tal:repeat="i batch"``) add a new table row::
1924+
``tal:repeat="i batch"``) add a new table row:
18941925

1895-
<tr>
1896-
<td tal:attributes="colspan python:len(request.columns)">
1897-
<input name="@csrf" type="hidden"
1898-
tal:attributes="value python:utils.anti_csrf_nonce()">
1899-
<input type="submit" value=" Save Changes ">
1900-
<input type="hidden" name="@action" value="edit">
1901-
<tal:block replace="structure request/indexargs_form" />
1902-
</td>
1903-
</tr>
1926+
.. tabs::
1927+
1928+
.. code-tab:: html TAL
1929+
1930+
<tr>
1931+
<td tal:attributes="colspan python:len(request.columns)">
1932+
<input name="@csrf" type="hidden"
1933+
tal:attributes="value python:utils.anti_csrf_nonce()">
1934+
<input type="submit" value=" Save Changes ">
1935+
<input type="hidden" name="@action" value="edit">
1936+
<tal:block replace="structure request/indexargs_form" />
1937+
</td>
1938+
</tr>
1939+
1940+
.. code-tab:: html Jinja2
1941+
1942+
To Be Written
19041943

19051944
which gives us a submit button, indicates that we are performing an
19061945
edit on any changed statuses, and provides a defense against cross

doc/developers.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,26 @@ roundup will write each email message that it sends to that file
182182
instead to the internet. This environment variable is independent of
183183
the python -O flag.
184184

185+
Documentation Notes
186+
-------------------
187+
188+
All docs are written using sphinx. Use pip or your package manager to
189+
install sphinx. In addition you will need to install a couple of
190+
sphinx extensions to process the files. A requirement's file can be
191+
found in docs/requirement.pip or website/www/requirements.pip. You can
192+
install these requirements using ``python -m pip install -r
193+
<path_to_requirements_file>``.
194+
195+
The extensions sphinx-sitemap generates a sitemap when building for
196+
the website. The sphinx-tabs extension generates tabs for displaying
197+
code examples in both TAL and Jinja2.
198+
199+
To build the documentation distributed with a Roundup release, run
200+
``python setup.py build_doc`` at the root of the source tree. To build
201+
docs for the website, see the ``updating www.roundup-tracker.org``
202+
section of ``website/README.txt`` or TL;DR ``cd website/www; make
203+
html``.
204+
185205
Testing Notes
186206
-------------
187207

doc/requirements.pip

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
sphinx-tabs

website/www/_templates/layout.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,10 @@
133133
</footer>
134134
{%- endblock %}
135135
<link rel="stylesheet" href="{{ pathto('_static/pygments.css', 1) }}" type="text/css" />
136+
{%- for cssfile in css_files %}
137+
<!-- loading css_files -->
138+
<link rel="stylesheet" href="{{ pathto(cssfile, 1) }}" type="text/css" />
139+
{%- endfor %}
136140
<script>
137141
/* locally hosted goatcounter https://www.goatcounter.com/ */
138142
/* include site info in path url to allow multiple sites to be

website/www/conf.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@
4343

4444
# Add any Sphinx extension module names here, as strings. They can be extensions
4545
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
46-
extensions = ['sphinx_sitemap']
46+
extensions = ['sphinx_sitemap', 'sphinx_tabs.tabs']
47+
48+
sphinx_tabs_valid_builders = ['linkcheck']
49+
sphinx_tabs_disable_tab_closing = True
4750

4851
# for sitemap default: "{lang}{version}subdir/{link}"
4952
sitemap_url_scheme = "{link}"

website/www/requirements.pip

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
sphinx_sitemap
1+
sphinx-sitemap
2+
sphinx-tabs

0 commit comments

Comments
 (0)