Fix doc issue where parameters listed twice in description (#916)

* Update sphinx pin to version 4.4.0
* Remove sphinx extension sphinx_autodoc_typehints
This commit is contained in:
Lorenz
2022-03-26 09:46:09 -04:00
committed by GitHub
parent 3efb08034a
commit ee90f2ce28
3 changed files with 28 additions and 9 deletions

View File

@ -27,10 +27,6 @@ import cadquery
# sys.path.insert(0, os.path.abspath('.'))
def setup(app):
app.add_css_file("tables.css")
# -- General configuration -----------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here.
@ -40,14 +36,15 @@ def setup(app):
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = [
"sphinx.ext.autodoc",
"sphinx_autodoc_typehints",
"sphinx.ext.viewcode",
"sphinx.ext.autosummary",
"cadquery.cq_directive",
"sphinx.ext.mathjax",
]
always_document_param_types = True
autodoc_typehints = "both"
autodoc_typehints_description_target = "all"
autodoc_typehints_format = "short"
# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]
@ -288,3 +285,25 @@ texinfo_documents = [
# How to display URL addresses: 'footnote', 'no', or 'inline'.
# texinfo_show_urls = 'footnote'
def process_docstring_insert_self(app, what, name, obj, options, lines):
"""
Insert self in front of documented params for instance methods
"""
if (
what == "method"
and getattr(obj, "__self__", None) is None
and "self" in obj.__annotations__
):
for i, dstr in enumerate(lines):
if dstr.startswith(":param"):
lines.insert(i, ":param self:")
break
def setup(app):
app.add_css_file("tables.css")
app.connect("autodoc-process-docstring", process_docstring_insert_self)