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

Return types not shown for methods #219

Closed
joelberkeley-secondmind opened this issue Jun 9, 2020 · 5 comments
Closed

Return types not shown for methods #219

joelberkeley-secondmind opened this issue Jun 9, 2020 · 5 comments
Labels
Bug Good First Issue Good issue for first time contributors Language: Python

Comments

@joelberkeley-secondmind
Copy link

joelberkeley-secondmind commented Jun 9, 2020

I'm seeing the return types shown for module-level functions, but not for methods.

It renders a bit like

class Foo
    my_method(self, a: str)

my_function(a: Union[int, str]) → str

I'm using

Sphinx 3.0.4
sphinx-autoapi 1.3.0
sphinx-rtd-theme 0.4.3

my conf.py

project = ...  # removed
copyright = ...  # removed
author = ...  # removed
release = "v0.1.0"

extensions = []
add_module_names = False

# sphinx-autoapi
extensions.append('autoapi.extension')
autoapi_dirs = ['../package_name']
autoapi_python_class_content = "both"
autoapi_options = [
    'members',
    'undoc-members',  # this is temporary until we add docstrings across the codebase
    'show-inheritance',
    'show-module-summary',
    'special-members',
    'imported-members',
    'inherited-members',
]

# intersphinx
extensions.append('sphinx.ext.intersphinx')
intersphinx_mapping = {
    'python': ('https://docs.python.org/3/', None),
}

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']

# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages.  See the documentation for
# a list of builtin themes.
html_theme = "sphinx_rtd_theme"

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']

# If True, show link to rst source on rendered HTML pages
html_show_sourcelink = False

# theme-specific options. see theme docs for more info
html_theme_options = {
    "collapse_navigation": False,
    "titles_only": True,
}
@AWhetter AWhetter added the Good First Issue Good issue for first time contributors label Jun 23, 2020
@joelberkeley-secondmind
Copy link
Author

joelberkeley-secondmind commented Aug 7, 2020

@AWhetter I've migrated to 1.4.0 but I'm still not seeing method return types. I've copy pasted the class A in tests/python/py3example/example/example.py but it's showing in the rst as

.. py:class:: A

   A

   Initialize self.  See help(type(self)) for accurate signature.

   .. attribute:: instance_var
      :annotation: :bool = True

      This is an instance_var.


   .. method:: my_prop(self)
      :property:


      My property.


   .. method:: my_method(self)


      My method.

@AWhetter
Copy link
Collaborator

AWhetter commented Sep 1, 2020

I can't reproduce your issue. It's missing a lot of other bits of that class but it's not clear to me why. Please can you give a more complete example that's failing.

@joelberkeley-secondmind
Copy link
Author

I truncated the output. I'll add a more complete version

@joelberkeley-secondmind
Copy link
Author

actually, i retract that, that's exactly what I get. My configuration is (with some details replaced with dummy values)

project = "foo"
copyright = "bar"
author = "baz"

release = 'v0.2.0-alpha'

extensions = []
add_module_names = False

# sphinx-autoapi
extensions.append('autoapi.extension')
autoapi_dirs = ['../foo']
autoapi_add_toctree_entry = False
autoapi_python_class_content = "both"
autoapi_options = [
    'members',
    'inherited-members',
    'private-members',
    'special-members',
    'imported-members',
    'show-inheritance',
]

templates_path = ['_templates']
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']

# -- Options for HTML output -------------------------------------------------

html_theme = "pydata_sphinx_theme"
html_static_path = ['_static']

@joelberkeley-secondmind
Copy link
Author

can confirm this is now working for me on version 1.5.0, thanks very much for all your help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Good First Issue Good issue for first time contributors Language: Python
Projects
None yet
Development

No branches or pull requests

2 participants