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

Docstring section Yield type doesn't hyperlink in napoleon #10982

Open
electric-coder opened this issue Nov 19, 2022 · 0 comments
Open

Docstring section Yield type doesn't hyperlink in napoleon #10982

electric-coder opened this issue Nov 19, 2022 · 0 comments

Comments

@electric-coder
Copy link

electric-coder commented Nov 19, 2022

Describe the bug

Not sure if this is a new bug or a regression, see #8004. I'm reporting this bug as specific to the Yield docstring section of the sphinx.ext.napoleon extension for Google style docstrings, (perhaps #10134 is also related but it seems NumPy specific.)

So whatever the relevant configurations of napoleon or autodoc you use -I tried this with every combination I could think of- it seems the type of the Yield docstring section is never hyperlinked.

How to Reproduce

A minimal conf.py (I think it's better in this case to include all the relevant configurations with explicit values):

import os
import sys

sys.path.insert(0, os.path.abspath(os.path.join('..', '..', 'src')))

extensions = [
    'sphinx.ext.autodoc',
    'sphinx.ext.napoleon',
    'sphinx.ext.intersphinx',
]

templates_path = ['_templates']
exclude_patterns = []

html_theme = 'alabaster'
html_static_path = ['_static']

toc_object_entries = False
add_module_names = False
add_function_parentheses = True
smartquotes = False

intersphinx_mapping = {'python': ('https://docs.python.org/3', None)}

autodoc_typehints_format = 'short'
autodoc_typehints_description_target = 'all'
autodoc_preserve_defaults = True
autodoc_class_signature = 'mixed'
autodoc_docstring_signature = False

napoleon_google_docstring = True
napoleon_numpy_docstring = False
napoleon_include_init_with_doc = False
napoleon_include_private_with_doc = True
napoleon_include_special_with_doc = True
napoleon_use_admonition_for_examples = True
napoleon_use_admonition_for_notes = True
napoleon_use_admonition_for_references = False
napoleon_use_ivar = True
napoleon_use_keyword = True
napoleon_use_param = True
napoleon_use_rtype = True
napoleon_preprocess_types = False
napoleon_type_aliases = None
napoleon_attr_annotations = False

A simple example module my_package.my_module.py

from typing import Iterator


class MyClass:

    def test_method(self, my_arg) -> Iterator[int]:
        """Test docstring

        Args:
            my_arg (int): text.
        Yields:
            Iterator[int]: text
        """
        yield 1

A minimal my.rst

title this
==========

.. module:: my_package.my_module

    .. autoclass:: MyClass
        :members:

A screenshot showing the problem:

github_yield

Environment Information

Platform:              win32; (Windows-10-10.0.19041-SP0)
Python version:        3.9.0 (tags/v3.9.0:9cf6752, Oct  5 2020, 15:34:40) [MSC v .1927 64 bit (AMD64)])
Python implementation: CPython
Sphinx version:        5.3.0
Docutils version:      0.17.1
Jinja2 version:        3.1.2

Sphinx extensions

['sphinx.ext.autodoc',
'sphinx.ext.napoleon',
'sphinx.ext.intersphinx']
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