sphinx-extensions2 / sphinx-jinja2

A sphinx extension to render jinja based templates
https://sphinx-jinja2.readthedocs.io/
MIT License
6 stars 2 forks source link

ERROR: Directive 'jinja' cannot be mocked: MockingError: MockStateMachine has not yet implemented attribute 'insert_input' #3

Open ice-tong opened 4 months ago

ice-tong commented 4 months ago

Hi, thanks for the nice work! I found sphinx-jinja2 very useful when I needed to customise the generated documentation.

Since the generated documentation contains markdown syntax, I try to use myst-parser with sphinx-jinja2, but encountered the following error:

I’d be really grateful if you had any suggestions that could help me with this issue!

eudoxos commented 2 months ago

The template output is fed back into the RST parser. When the source uses MyST parser (please confirm), this error will be triggered:

   Directive 'jinja' cannot be mocked: MockingError: MockStateMachine has not yet implemented 'insert_input'.

The workaround is to wrap the jinja directive inside rst-eval

```{rst-eval}
   .. jinja::
      :ctx: {"foo":"bar"}

      Baz.

rather than using it directly:
   :ctx: {"foo":"bar"}

   Baz.