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

Ignore rst_prolog option for function documentation #425

Open
g3n35i5 opened this issue Feb 8, 2024 · 4 comments
Open

Ignore rst_prolog option for function documentation #425

g3n35i5 opened this issue Feb 8, 2024 · 4 comments

Comments

@g3n35i5
Copy link

g3n35i5 commented Feb 8, 2024

Since #422 has been merged , the function documentation contains the rst_prolog option text.

The rst_prolog option is automatically inserted at the beginning of each source file read.
I currently use it to globally limit the toc tree depth.

With the changes in #422, the documentation of the individual functions is written to temporary rst files and then evaluated, as far as I understand it. This ensures that sphinx inserts the rst_prolog value and sphinx-autodoc-typehints seems to interpret this value not as an rst directive but as a string.

# Set maximum depth for the right sidebar content overview
rst_prolog = ":tocdepth: 3"

Selection_20240208_01

@gaborbernat
Copy link
Member

PR with a fix is welcome (with tests). Thanks!

@alexdlaird
Copy link

alexdlaird commented Mar 10, 2024

Similarly, adding any sort of replacement in conf.py

rst_prolog = """
.. |pyngrok_version| replace:: {pyngrok_version}
""".format(pyngrok_version=version)

replaces every typedoc hint, whether it matches the replacement string or not (in this case, version is 7.1.5):

311511175-9030faf9-2f7d-44f4-903a-c16167378448 311511176-f018d23a-082e-4d75-9f1c-9534b284c318

Presumably it's finding the union | operator too greedily. Here's how the docs should look: https://pyngrok.readthedocs.io/en/latest/api.html#module-pyngrok.ngrok

Solution until this is fixed is to pin back the version:

sphinx_autodoc_typehints==1.25.2

@gaborbernat
Copy link
Member

@flying-sheep can you take a look at this regression?

@flying-sheep
Copy link
Contributor

Should be simple: #436

The RSTParser class we use has a dedicated method to add pro- and epilogue. We can just replace that with something that does nothing.

You just need to add a test and it should be ready to go.

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

Successfully merging a pull request may close this issue.

4 participants