sphinx-doc / sphinx-doc/sphinx

Autodoc: Method signature from docstring does not work for methods with no additonal arguments

Open
#5,409 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

extensions:autodoc type:bug
Dominant language
Python
Stars
8k
Forks
2.6k
PR merge metrics
No merged PRs in 30d

Description

Method signatures are not inferred from docstring, if no arguments are given.

Problem

I have a bunch of types created using C-extensions. I would like to include their function signature using the autodoc_docstring_signature option. For most methods, this works correctly. However, for functions accepting no additional arguments (other than self), the signature is simply

"""
some_method()

The description begins here.
...
"""

which renders as

some_method

instead of the expected

some_method()

This problem does only occur in methods from C-extensions, methods in normal Python classes are rendered correctly.

Reproducible project / your project

https://github.com/padix-key/biotite branch doc

For example in the type biotite.structure.BondList in the method as_array()

Environment info
  • OS: Xubuntu 18.04
  • Python version: 3.6
  • Sphinx version: 1.7.8

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the autodoc_docstring_signature handling and reproduce the issue using biotite.structure.BondList.as_array() from the linked project. The work is complete when a C-extension method documented as some_method() renders with the parentheses instead of only some_method.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
documentation
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.