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

Use parameters type hints automatically with sphinx #1137

Merged
merged 5 commits into from
Oct 3, 2024

Conversation

VincentRouvreau
Copy link
Contributor

@VincentRouvreau VincentRouvreau commented Sep 26, 2024

Only for RipsPersistence for the moment.

image

@VincentRouvreau VincentRouvreau marked this pull request as ready for review September 27, 2024 05:24
https://joblib.readthedocs.io/en/latest/generated/joblib.Parallel.html for more details.
"""Constructor for the RipsPersistence class.

:param homology_dimensions: The returned persistence diagrams dimension(s).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see you switched from Google-style to plain RST. Is that because it wasn't possible while sticking to Google-style?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was just following what is explained in sphinx-autodoc-typehints documentation. Google style is also working, so I reverted to it on 52aa602

"sphinxcontrib.bibtex",
"sphinx_paramlinks",
]

autodoc_class_signature = "separated"
autodoc_typehints = "none"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at https://github.com/tox-dev/sphinx-autodoc-typehints#options, it suggests we should add napoleon_use_rtype = True. It has 0 effect currently, but it might become relevant when we add more annotations?

always_use_bars_union = True looks a bit prettier than the default (False), but that's subjective.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added napoleon_use_rtype = True and always_use_bars_union = True on 20c7761

@VincentRouvreau
Copy link
Contributor Author

VincentRouvreau commented Oct 2, 2024

What I found nice (and thanks @mglisse for pointing the question), I have:
Screenshot from 2024-10-02 10-20-58
But if I precise a type, like for homology_dimensions in this example:

        Parameters:
            homology_dimensions (int or list of int): The returned persistence diagrams dimension(s).

The type is substituted, with the one that is explicitly given in code, we will have:
image

@VincentRouvreau VincentRouvreau added the 3.11.0 GUDHI version 3.11.0 label Oct 3, 2024
@VincentRouvreau VincentRouvreau merged commit 2f92e88 into GUDHI:master Oct 3, 2024
5 of 7 checks passed
@VincentRouvreau VincentRouvreau deleted the sphinx_typehints branch October 3, 2024 06:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.11.0 GUDHI version 3.11.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants