sphinx-autodoc-typehints icon indicating copy to clipboard operation
sphinx-autodoc-typehints copied to clipboard

README does not explain whether this extension is still needed with the current versions of Sphinx

Open vbrozik opened this issue 3 years ago • 4 comments

The build-in extension sphinx.ext.autodoc contains the parameter autodoc_typehints with option description since the version 3.0. It seems that this configuration option makes sphinx-autodoc-typehints obsolete. Am I right?

In any way README should mention the relationship of this third-party extension to the current versions of the Sphinx package.

vbrozik avatar Mar 27 '21 19:03 vbrozik

Plus, it seems that napoleon now can use type annotations:

(https://www.sphinx-doc.org/en/master/usage/extensions/napoleon.html#type-annotations)

Maybe this piece of code is now obsolete?

mbello avatar Apr 08 '21 16:04 mbello

Latest sphinx, no sphinx-autodoc-typehints: image With sphinx-autodoc-typehints: image Which one would you prefer – the one with readable function signatures and annotations with clickable links, or the docs in the first image?

agronholm avatar Apr 08 '21 16:04 agronholm

@agronholm there is something wrong in your configuration. I do not use sphinx-autodoc-typehints. Here is my result:

image

Sphinx' conf.py:

...
extensions = [
    'sphinx.ext.autodoc',
    'sphinx.ext.doctest',
    'sphinx.ext.todo',
    'sphinx.ext.viewcode',
    'sphinx.ext.napoleon',
    'sphinx_rtd_theme',
]
...
autodoc_typehints = "description"
...
html_theme = 'sphinx_rtd_theme'
...
$ python3.9 -m pip list | grep -i sphinx
Sphinx                        3.5.4
sphinx-rtd-theme              0.5.2
sphinxcontrib-applehelp       1.0.2
sphinxcontrib-devhelp         1.0.2
sphinxcontrib-htmlhelp        1.0.3
sphinxcontrib-jsmath          1.0.1
sphinxcontrib-qthelp          1.0.3
sphinxcontrib-serializinghtml 1.1.4

I just noticed that the built-in functionality simplifies some of the type-annotations. Here is the original:

def flatten_to_list(
        json_struct: Union[dict[str, Any], list[Any]], /, *,
        parent: str = '', startindex: int = 1, parent_sep: str = '.',
        key_order: Iterable[str] = (),
        value_converter: Callable = str,
        key_converter: Callable = str) -> list[str]:

For me it is still not worth the effort of using an additional 3rd-party extension.

vbrozik avatar Apr 16 '21 09:04 vbrozik

For me it is still not worth the effort of using an additional 3rd-party extension.

You're free not to use this library. No one is forcing you to do so. This library has a different style and is more flexible than the core. For who wants that it will remain here and keep working.

gaborbernat avatar Jan 08 '22 11:01 gaborbernat