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

.rst_t apidoc template files are not found #12916

Closed
Sbte opened this issue Sep 24, 2024 · 5 comments · Fixed by #12929
Closed

.rst_t apidoc template files are not found #12916

Sbte opened this issue Sep 24, 2024 · 5 comments · Fixed by #12929

Comments

@Sbte
Copy link

Sbte commented Sep 24, 2024

Describe the bug

Most likely since #11165 (at least since 7.4.0, not before that) my apidoc template files are not found anymore. They are called module.rst_t and package.rst_t. Renaming them to module.rst.jinja and package.rst.jinja fixes the issue, but this breaks compatibility with earlier sphinx versions. Moreover, .rst_t files will only be marked as deprecated starting 31 December 2024.

How to Reproduce

conf.py:

extensions = [
    'sphinxcontrib.apidoc',
]

templates_path = ['templates']
exclude_patterns = ['_build']

apidoc_module_dir = 'mod'
apidoc_output_dir = 'reference'

apidoc_separate_modules = True

templates/module.rst_t:

{%- if show_headings %}
{{- basename | e | heading }}

The template was found!
-----------------------

{% endif -%}
.. automodule:: {{ qualname }}
{%- for option in automodule_options %}
   :{{ option }}:
{%- endfor %}

index.rst

Hello World
===========

.. toctree::
   :maxdepth: 2
   :caption: API documentation

   reference/mod

mod/mod.py:

class Test:
    '''This is a test class'''
    pass

Using this configuration, you don't see the line "The template was found!" on the index page or anywhere else. Renaming templates/module.rst_t to templates/module.rst.jinja fixes the issue, but breaks compatibility with other sphinx versions.

Environment Information

Platform:              linux; (Linux-6.8.0-40-generic-x86_64-with-glibc2.35)
Python version:        3.10.12 (main, Sep 11 2024, 15:47:36) [GCC 11.4.0])
Python implementation: CPython
Sphinx version:        8.0.2
Docutils version:      0.20.1
Jinja2 version:        3.1.4
Pygments version:      2.18.0

Sphinx extensions

`['sphinxcontrib.apidoc']`

Additional context

No response

@Sbte Sbte added the type:bug label Sep 24, 2024
@AA-Turner
Copy link
Member

cc @jayaddison

@jayaddison
Copy link
Contributor

This seems to be a problem, yep. Thank you for the bugreport @Sbte. Although #11165 is where these changes were first prepared, I believe the first release to include them was v7.4.0 after they were (re)introduced by #12364.

This also seems to be a regression since it breaks existing functionality, so I'll add the appropriate bugtracker label. I should be able to start on a fix within the next day or two.

@jayaddison
Copy link
Contributor

@Sbte I believe that pull request #12929 should resolve this - it includes some test coverage intended to demonstrate that it does, but if you have any time available to confirm that it fixes the problem that'd be much apprecated!

@hennjanssen
Copy link

I encountered exactly the same problem and tested different versions of Sphinx on my project (which is using *.rst_t files as templates):

Sphinx version Success?
7.3.7 🆗
7.4.0 👎
8.0.2 👎
8.1.0 from #12929 🆗

I was always using Python 3.12.5 on Ubuntu 22.04 with WSL. I hope that my contribution is helpful.

@Sbte
Copy link
Author

Sbte commented Sep 30, 2024

@Sbte I believe that pull request #12929 should resolve this - it includes some test coverage intended to demonstrate that it does, but if you have any time available to confirm that it fixes the problem that'd be much apprecated!

Yes, that seems to have fixed it, thanks!

@AA-Turner AA-Turner added this to the 8.1.0 milestone Oct 6, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants