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

Extension fails to find templates in Sphinx templates_path #18

Closed
goerz opened this issue Mar 18, 2021 · 0 comments · Fixed by #19
Closed

Extension fails to find templates in Sphinx templates_path #18

goerz opened this issue Mar 18, 2021 · 0 comments · Fixed by #19
Assignees
Labels
bug Something isn't working

Comments

@goerz
Copy link
Owner

goerz commented Mar 18, 2021

It appears that the doctr_versions_menu extension will not use a custom doctr-versions-menu.js_t in the templates_path defined in Sphinx' conf.py.

The problem is in the following code:
https://github.com/goerz/doctr_versions_menu/blob/63ec6aa0037b1c62cf46ba632a56a59f17700aac/src/doctr_versions_menu/ext.py#L26-L28

Here, we use app.config.templates_path, which by default is ['_templates'], where _templates is supposed to be relative to the folder in which conf.py resides. However, we use it here as a path relative to the current working directory. Generally, there will be no folder _templates in the current working directory, so the extension falls back to str(Path(__file__).parent / '_template', i.e. the built-in default template. The custom template will not be used, and there will be no warning.

Strangely, the tests didn't catch this, even though we explicitly tests that custom templates work. This must be some weird detail of sphinx-testing. 🤷

@goerz goerz added the bug Something isn't working label Mar 18, 2021
@goerz goerz self-assigned this Mar 18, 2021
goerz added a commit that referenced this issue Mar 18, 2021
@goerz goerz closed this as completed in #19 Mar 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant