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

Autosummary lists functions but does not generate documentation pages #11998

Open
aeisenbarth opened this issue Feb 22, 2024 · 3 comments
Open

Comments

@aeisenbarth
Copy link

Describe the bug

When using autosummary with recursion, functions in the summaries are not clickable while modules are. There is no page with full documentation generated for each function.

I see that other projects have full documentation of their functions, and I assume this is the wanted behavior. I also don't see other projects having extra stub generating scripts besides autosummary_generate = True.

Actual behavior

Function is not clickable
Screenshot from 2024-02-22 12-06-09

Expected behavior

Function is clickable
Screenshot from 2024-02-22 12-13-52

How to Reproduce

my_module.py

def my_function(*args, **kwargs):
    pass

conf.py

extensions = ["sphinx.ext.autosummary"]
autosummary_generate = True

index.rst

.. autosummary::
   :toctree:
   :recursive:

   my_module

Environment Information

Platform:              linux; (Linux-5.15.0-91-generic-x86_64-with-glibc2.35)
Python version:        3.9.17 (main, Jul  5 2023, 20:41:20) 
[GCC 11.2.0])
Python implementation: CPython
Sphinx version:        7.2.6
Docutils version:      0.20.1
Jinja2 version:        3.1.2
Pygments version:      2.16.1

Sphinx extensions

["sphinx.ext.autosummary"]

Additional context

No response

@aeisenbarth
Copy link
Author

A workaround is to copy the original template to _templates/autosummary/module.rst in your root docs directory and patch a single line in the functions section:

--- module.rst
+++ module.rst
@@ -18,6 +18,7 @@
    .. rubric:: {{ _('Functions') }}
 
    .. autosummary::
+      :toctree:
    {% for item in functions %}
       {{ item }}

As a downside, the custom template copies a lot of unchanged code, which does not get updates if you update sphinx.


Should I create a pull request? Is this the right place to fix, and are there other items like classes/methods where this also need to be applied?

@jayaddison
Copy link
Contributor

I see that other projects have full documentation of their functions, and I assume this is the wanted behavior. I also don't see other projects having extra stub generating scripts besides autosummary_generate = True.

@aeisenbarth could you link to a sample documentation project that does offer hyperlinked function documentation? (preferably one with an open source license, to make it easier to compare the configuration details)

@aeisenbarth
Copy link
Author

After further inspection, I am not sure whether there is some extra build process on top of what is specified in conf.py, when projects are hosted on readthedocs? (maybe sphinx-autoapi)

Others (xarray) explicitly specify every item.

I didn't observe projects that use autosummary to summarize unclickable items, but not document the items in some way. It seems to be desirable to document them. The question is maybe whether autosummary should do it by default or rather not.

DanielAdriaansen added a commit to dtcenter/METcalcpy that referenced this issue Apr 4, 2024
bikegeek pushed a commit to dtcenter/METcalcpy that referenced this issue Apr 12, 2024
* Changes URL for coding standards to point to the METplus wrappers contributors guide coding standards.

* Changes wording from build to make to be consistent with experience using newer sphinx.

* Changes to allow autosummary to work and document the diagnostics submodule.

* Adds new menu entry for the diagnostics submodule.

* RST file for autosummary to use, with change from default module.rst file to get the functions to be clickable per sphinx-doc/sphinx#11998.

* RST file for the diagnostic submodule.

* Adds the generated directory from sphinx in the diag_api subdirectory to the gitignore.

* Adds a new land_surface diagnostic file to contain functions for land/surface applications.

* Adds __pycache__ to gitignore.

* Adds sphinx execution times RST file to gitignore.

* Removes cruft from testing, adds exception raising, and updates docstring formatting to match Sphinx https://sphinx-rtd-tutorial.readthedocs.io/en/latest/docstrings.html.

* Restructure function to handle invalid types. This may not be the right way to do this.

* Removes erroneous menu entries from testing documentation.

* Adds test for calc_tci function and test data.

* Adds Xarray and Pandas dependencies for building documentation, and lifts Python version for building documentation from 3.8 to 3.10.

* Adds TCI test to the unit test config.

* Changes name to remove API.

* Trying to get GHA to run.

* Updating pandas/xarray versions.

* Double equals.

* Changes RST heading level and adds description of the diagnostic reference.

* Moves the diagnostic calculation reference to a sub-menu within the User's Guide.

* Testing failure when readthedocs reports a warning.

* Adds back xarray readthedocs requirement.

* Update docs/Contributors_Guide/index.rst

Co-authored-by: Julie Prestopnik <jpresto@ucar.edu>

* Adds reference for  function.

* Adds bool for turning on/off the pandas and xarray tests.

* Adds new skipna argument to the function, which is passed to pandas and xarray. The default is set to True, but a user can override if they wish.

* Renames diag_api directory to diag_ref.

* Renames testing file for land_surface diagnostics to support additional land_surface diagnostics in the future.

* Turns on the Sphinx napoleon extension to support Google and NumPy docstrings and re-writes the  docstring using Google format.

* Updates Google docstring to acheive desired formatting.

* Adds dunder init file.

* Renames hyperlink and menu entry.

* Changed a directory name and forgot to update the ignore file.

* Removes directory not intended to be in repository.

---------

Co-authored-by: Julie Prestopnik <jpresto@ucar.edu>
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