sphinx-contrib / datatemplates

Sphinx plugin for generating RST on the fly from data files and templates.
http://sphinxcontribdatatemplates.readthedocs.io/
Other
44 stars 19 forks source link

Produce error on non-existing attributes in jina2 #85

Closed oharboe closed 1 year ago

oharboe commented 3 years ago

If this change is made in conf.py, then HTML rendering will fail. These errors should only be reported for datatemplates.

Is there a way to configure this from conf.py??

See also #84

dhellmann commented 3 years ago

If this change is made in conf.py, then HTML rendering will fail. These errors should only be reported for datatemplates.

Is there a way to configure this from conf.py??

Since this is a backwards-incompatible change, we would definitely want to have a new configuration option added and we would want the default to not report errors for missing variables to maintain the behavior before this PR.

It doesn't look like the datatemplates extension uses any config options so far, but there's an example of how to add a boolean option in the spelling extension at https://github.com/sphinx-contrib/spelling/blob/master/sphinxcontrib/spelling/__init__.py#L28

We would want the config option to have datatemplates_ as a prefix, since there's no other namespacing for sphinx config options.

oharboe commented 3 years ago

My hack seems so dirty... I'm temporarily modifying the build environment, then restoring it.

Isn't there a cleaner way to do this?

I was wondering if there's a way to create a build environment specific to the datatemplate plugin from within conf.py...

Adding an option seems rather inflexible. I could imagine that many other kinds of modifications to the build environment would be needed and that if a plugin specific build environment could be made from within conf.py, that would be the way to do it...

dhellmann commented 3 years ago

My hack seems so dirty... I'm temporarily modifying the build environment, then restoring it.

Isn't there a cleaner way to do this?

I'm not familiar enough with Jinja internals to know. Perhaps? Maybe if we used lower level functions to render the templates instead of relying on Sphinx's wrappers.

I was wondering if there's a way to create a build environment specific to the datatemplate plugin from within conf.py...

Adding an option seems rather inflexible. I could imagine that many other kinds of modifications to the build environment would be needed and that if a plugin specific build environment could be made from within conf.py, that would be the way to do it...

I don't think asking someone writing documentation for arbitrary purposes to understand Jinja rendering internals so they can construct an environment object is going to give the best user experience.

oharboe commented 3 years ago

I agree that a good user experience is needed, but I'm puzzled by that there isn't a standard way to do this. Requires some googling to see what I can find...

I don't understand this pull request, but it seems like it wants to customize the template build environment...

https://github.com/sphinx-doc/sphinx/issues/4030