Skip to content

Commit d74f4de

Browse files
authored
📚 DOCS remove jinja templating (useblocks#1079)
It has no benefit and causes issues with raw jinja and latex builds
1 parent 6abd389 commit d74f4de

File tree

8 files changed

+27
-74
lines changed

8 files changed

+27
-74
lines changed

‎docs/conf.py

+1-22
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@
1818
# documentation root, use os.path.abspath to make it absolute, like shown here.
1919
#
2020
import os
21-
from typing import Any, Dict, List
22-
23-
from sphinx.application import Sphinx
21+
from typing import Any, Dict
2422

2523
from sphinx_needs import __version__
2624

@@ -510,25 +508,6 @@ def custom_defined_func():
510508
html_context = {}
511509

512510

513-
def rstjinja(app: Sphinx, _docname: str, source: List[str]) -> None:
514-
"""
515-
Render our pages as a jinja template for fancy templating goodness.
516-
"""
517-
# Make sure we're outputting HTML
518-
if app.builder.format != "html" and app.builder.name != "linkcheck":
519-
return
520-
src = source[0]
521-
from jinja2 import Template
522-
523-
template = Template(src, autoescape=True)
524-
rendered = template.render(**app.config.html_context)
525-
source[0] = rendered
526-
527-
528-
def setup(app: Sphinx) -> None:
529-
app.connect("source-read", rstjinja)
530-
531-
532511
# LINKCHECK config
533512
# https://www.sphinx-doc.org/en/master/usage/configuration.html?highlight=linkcheck#options-for-the-linkcheck-builder
534513
linkcheck_ignore = [

‎docs/configuration.rst

+12-23
Original file line numberDiff line numberDiff line change
@@ -661,8 +661,6 @@ If you do not set ``needs_report_template``, the default template used is:
661661
662662
.. code-block:: jinja
663663
664-
{% raw -%}
665-
666664
{# Output for needs_types #}
667665
{% if types|length != 0 %}
668666
.. dropdown:: Need Types
@@ -739,7 +737,7 @@ If you do not set ``needs_report_template``, the default template used is:
739737
{% endif %}
740738
{# Output for needs metrics #}
741739
742-
{% endraw %}
740+
743741
744742
The plugin provides the following variables which you can use in your custom Jinja template:
745743
@@ -770,13 +768,12 @@ By default the following template is used:
770768
771769
.. code-block:: jinja
772770
773-
{% raw -%}
774771
{%- if is_need -%}
775772
<size:12>{{type_name}}</size>\\n**{{title|wordwrap(15, wrapstring='**\\\\n**')}}**\\n<size:10>{{id}}</size>
776773
{%- else -%}
777774
<size:12>{{type_name}} (part)</size>\\n**{{content|wordwrap(15, wrapstring='**\\\\n**')}}**\\n<size:10>{{id_parent}}.**{{id}}**</size>
778775
{%- endif -%}
779-
{% endraw %}
776+
780777
781778
782779
.. _needs_id_required:
@@ -1550,7 +1547,7 @@ Default: ``False``.
15501547
needs_service_all_data = True
15511548
15521549
1553-
{% raw %}
1550+
15541551
15551552
.. _needs_external_needs:
15561553
@@ -1626,7 +1623,7 @@ keys:
16261623
The related CSS class definition must be done by the user, e.g. by :ref:`own_css`.
16271624
(*optional*) (*default*: ``external_link``)
16281625
1629-
{% endraw %}
1626+
16301627
16311628
.. _needs_needextend_strict:
16321629
@@ -1718,7 +1715,7 @@ All named capture group values get injected, so that parts of the option-value c
17181715
link name and url.
17191716
17201717
**Example**:
1721-
{% raw %}
1718+
17221719
17231720
.. code-block:: python
17241721
@@ -1740,7 +1737,7 @@ link name and url.
17401737
'options': ['github']
17411738
}
17421739
}
1743-
{% endraw %}
1740+
17441741
17451742
|ex|
17461743
@@ -1955,7 +1952,7 @@ constraints_results is a dictionary similar in structure to needs_constraints ab
19551952
"critical": {
19561953
"check_0": "'critical' in tags",
19571954
"severity": "CRITICAL",
1958-
"error_message": "need {% raw %}{{id}}{% endraw %} does not fulfill CRITICAL constraint, because tags are {% raw %}{{tags}}{% endraw %}"
1955+
"error_message": "need {{id}} does not fulfill CRITICAL constraint, because tags are {{tags}}"
19591956
}
19601957
19611958
}
@@ -2137,8 +2134,6 @@ You can use the data passed via needs_render_context as shown below:
21372134
21382135
.. code-block:: jinja
21392136
2140-
{% raw -%}
2141-
21422137
.. req:: Need with jinja_content enabled
21432138
:id: JINJA1D8913
21442139
:jinja_content: true
@@ -2153,9 +2148,7 @@ You can use the data passed via needs_render_context as shown below:
21532148
+ author[1]
21542149
{% endfor %}
21552150
2156-
{% endraw %}
2157-
2158-
{% raw -%}
2151+
21592152
21602153
.. req:: Need with jinja_content enabled
21612154
:id: JINJA1D8913
@@ -2168,7 +2161,7 @@ You can use the data passed via needs_render_context as shown below:
21682161
* {{ author[0] }} --> ID-{{ author[1] }}
21692162
{% endfor %}
21702163
2171-
{% endraw %}
2164+
21722165
21732166
21742167
.. _needs_debug_measurement:
@@ -2205,8 +2198,6 @@ If nothing is set, the following default template is used:
22052198
22062199
.. code-block:: jinja
22072200
2208-
{% raw -%}
2209-
22102201
.. _{{id}}:
22112202
22122203
{% if hide == false -%}
@@ -2236,7 +2227,7 @@ If nothing is set, the following default template is used:
22362227
22372228
{% endif -%}
22382229
2239-
{% endraw %}
2230+
22402231
22412232
Available jinja variables are:
22422233
@@ -2254,7 +2245,7 @@ Available jinja variables are:
22542245
22552246
.. warning::
22562247
2257-
You must add a reference like `.. _{{ '{{id}}' }}:` to the template. Otherwise linking will not work!
2248+
You must add a reference like `.. _{{id}}:` to the template. Otherwise linking will not work!
22582249
22592250
.. _needs_template_collapse:
22602251
@@ -2268,8 +2259,6 @@ Default value:
22682259
22692260
.. code-block:: jinja
22702261
2271-
{% raw -%}
2272-
22732262
.. _{{id}}:
22742263
22752264
{% if hide == false -%}
@@ -2298,7 +2287,7 @@ Default value:
22982287
{{content|indent(4) }}
22992288
23002289
{% endif -%}
2301-
{% endraw %}
2290+
23022291
23032292
For more details please see :ref:`needs_template`.
23042293

‎docs/directives/need.rst

+4-7
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ and stores its PlantUML code under given key from :ref:`needuml` directive under
197197

198198
This diagram data can then be used in other :ref:`needuml` calls to combine and reuse PlantUML elements.
199199

200-
{% raw %}
200+
201201

202202
|ex|
203203

@@ -251,7 +251,7 @@ Reuse of :need:`SP_INT` inside a :ref:`needuml`:
251251

252252
system => int_a
253253

254-
{% endraw %}
254+
255255

256256
This simple mechanism is really powerful to design reusable and configurable SW architecture diagrams.
257257
For more examples and details, please read :ref:`needuml`.
@@ -553,7 +553,6 @@ Default: False
553553

554554
.. code-block:: jinja
555555
556-
{% raw -%}
557556
.. req:: First Req Need
558557
:id: JINJAID123
559558
:jinja_content: false
@@ -584,12 +583,10 @@ Default: False
584583
Need with ``:jinja_content:`` equal to ``true``.
585584
This requirement has status: **{{ status }}**.
586585
587-
{% endraw %}
586+
588587
589588
|out|
590589

591-
{% raw -%}
592-
593590
.. req:: First Req Need
594591
:id: JINJAID123
595592
:jinja_content: false
@@ -620,7 +617,7 @@ Default: False
620617
Need with ``:jinja_content:`` equal to ``true``.
621618
This requirement has status: **{{ status }}**.
622619

623-
{% endraw %}
620+
624621

625622
.. _title_from_content:
626623

‎docs/directives/needarch.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{% raw %}
1+
22

33
.. _needarch:
44

@@ -256,4 +256,4 @@ does detect different parameter sets and does import `uml()` calls with differen
256256
{{uml('COMP_T_002')}}
257257
{% endif %}
258258

259-
{% endraw %}
259+

‎docs/directives/needuml.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{% raw %}
1+
22

33
.. _needuml:
44

@@ -741,4 +741,4 @@ NeedUml Examples
741741

742742
class_x o-- class_y
743743

744-
{% endraw %}
744+

‎docs/layout_styles.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -287,13 +287,13 @@ The head-line for the default Sphinx-Needs layout ``clean`` looks like this::
287287
You are free to surround a layout function with a rst role. Like ``**<<meta("title")>>**`` to get a bold printed title.
288288

289289
Sometimes an argument for a layout function shall be based on a given need option. In this cases the option name
290-
can be surrounded by ``{%raw%}{{ .. }}{%endraw%}``.
290+
can be surrounded by ``{{ .. }}``.
291291
As example, there may be an ``author`` option in a bug-need and you want to show a picture of the author in the grid
292292
``simple_side_right_partial``.
293293

294294
The line for the ``side`` area could look like::
295295

296-
'<<image("_images/{%raw%}{{author}}{%endraw%}.png", align="center")>>'
296+
'<<image("_images/{{author}}.png", align="center")>>'
297297

298298
.. spec:: My test spec
299299
:author: daniel
@@ -326,7 +326,7 @@ Here is the complete used code::
326326
'head': ['**<<meta("title")>>** for *<<meta("author")>>*'],
327327
'meta': ['**status**: <<meta("status")>>',
328328
'**author**: <<meta("author")>>'],
329-
'side': ['<<image("_images/{%raw%}{{author}}{%endraw%}.png", align="center")>>']
329+
'side': ['<<image("_images/{{author}}.png", align="center")>>']
330330
}
331331
}
332332
}

‎docs/roles.rst

-12
Original file line numberDiff line numberDiff line change
@@ -202,21 +202,9 @@ They are also getting the part_id as link description.
202202
203203
|out|
204204

205-
{% if READTHEDOCS %}
206-
..
207-
208-
.. image:: _static/need_part_as_flow.png
209-
:align: center
210-
211-
{% else %}
212-
213205
.. needflow::
214206
:filter: id in ["my_car_1","impl_my_car_1"]
215207

216-
{% endif %}
217-
218-
219-
220208
**Presentation in needtable**
221209

222210
Please see :ref:`needtable_show_parts` of :ref:`needtable` configuration documentation.

‎docs/services/open_needs.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.. _open_needs_service:
22

3-
{% raw %}
3+
44

55
Open-Needs services
66
===================
@@ -199,7 +199,7 @@ The logic and syntax is the same as used by `mapping <#mapping>`_.
199199
:language: python
200200
:lines: 329-346
201201

202-
{% endraw %}
202+
203203

204204
Examples
205205
--------
@@ -226,4 +226,4 @@ Examples
226226

227227
.. image:: /_images/ons_table.png
228228
:align: center
229-
:width: 60%
229+
:width: 60%

0 commit comments

Comments
 (0)