You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using both sphinx_autodoc and sphinx_autodoc_typehints extensions. And in class having attribute definition in docstring as well as type hint for the same. Then getting duplicate object definitions.
Is there any way to prefer docstring over type hint for definition of object. I want both extensions to be enabled.
How to Reproduce
conf.py
Configuration file for the Sphinx documentation builder.
For the full list of built-in configuration values, see the documentation:
.. automodule:: role
:members:
:undoc-members:
:show-inheritance:
Indices and tables
:ref:genindex
:ref:modindex
:ref:search
role.py
"""Module for Role schemas"""
from pydantic import BaseModel, ConfigDict
class Role(BaseModel):
"""
Pydantic model for Role schema.
Attributes:
Id (int): Primary key for the role.
GroupId (str): Group Id of the role.
RoleName (str): Name of the role.
"""
model_config = ConfigDict(from_attributes=True)
Id: int
GroupId: str
RoleName: str
Can you please edit the post to fix the source fences?
using both sphinx_autodoc and sphinx_autodoc_typehints extensions
Since this is an issue specific to the sphinx_autodoc_typehints extension I think you should ask at their repository. This is bound to be a common usage question so also consider searching the Sphinx tag at Stack Overflow. Please see the Get Help because this issue tracker is mostly for bugs and feature requests, not for usage questions.
This seems potentially similar to an issue already reported in sphinx-autodoc-typehints at tox-dev/sphinx-autodoc-typehints#419 - please feel free to correct me if I'm mistaken.
Describe the bug
When using both sphinx_autodoc and sphinx_autodoc_typehints extensions. And in class having attribute definition in docstring as well as type hint for the same. Then getting duplicate object definitions.
Is there any way to prefer docstring over type hint for definition of object. I want both extensions to be enabled.
How to Reproduce
conf.py
Configuration file for the Sphinx documentation builder.
For the full list of built-in configuration values, see the documentation:
https://www.sphinx-doc.org/en/master/usage/configuration.html
-- Project information -----------------------------------------------------
https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
project = 'General Project'
-- General configuration ---------------------------------------------------
https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
extensions = [
'sphinx.ext.napoleon',
'sphinx_autodoc_typehints',
'sphinx.ext.autodoc',
'sphinx.ext.duration',
'sphinx.ext.viewcode'
]
templates_path = ['_templates']
exclude_patterns = []
-- Options for HTML output -------------------------------------------------
https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
html_theme = 'sphinx_rtd_theme'
html_static_path = ['_static']
index.rst
Welcome to General Project's documentation!
.. automodule:: role
:members:
:undoc-members:
:show-inheritance:
Indices and tables
genindex
modindex
search
role.py
"""Module for Role schemas"""
from pydantic import BaseModel, ConfigDict
class Role(BaseModel):
"""
Pydantic model for Role schema.
Environment Information
Sphinx extensions
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: