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

Custom Jinja2 filters #200

Closed
Markus-Goetz opened this issue Apr 30, 2020 · 1 comment
Closed

Custom Jinja2 filters #200

Markus-Goetz opened this issue Apr 30, 2020 · 1 comment

Comments

@Markus-Goetz
Copy link

Markus-Goetz commented Apr 30, 2020

In issue #160 @AWhetter mentions that it is possible to introduce custom Jinja2 filters to sphinx-autoapi via the conf.py. I am not quite sure how this is supposed to happen. While Sphinx will execfile() the conf.py, the Jinja2 environment spawned there, would be different from the one created in mappers/base.py.

Hence, I am not seeing a way to provide sphinx-autoapi with custom filters. Would you mind explaining how this can be achieved?

Edit: I could imagine this feature could also be provided by a execfile() on a Python source code file, defined in the conf.py, where the Jinja2 object is passed into. A user can then arbitrarily customize the Jinja2 instance.

@AWhetter
Copy link
Collaborator

AWhetter commented May 15, 2020

This currently isn't possible. It's still something that I think would be useful. I envisioned it as working by adding a new option in conf.py that would take a list of Jinja filters (and tests and globals) defined in the conf.py and that eventually get passed into the jinja environment here.

We would also need to tidy up the API of PythonPythonMapper objects. We document them but it would be a good idea to make sure that they are conforming to the documentation and making anything private that needs to be and documenting anything that needs to be.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants