2727# sys.path.insert(0, os.path.abspath('.'))
2828
2929
30- def setup (app ):
31- app .add_css_file ("tables.css" )
32-
33-
3430# -- General configuration -----------------------------------------------------
3531
3632# If your documentation needs a minimal Sphinx version, state it here.
@@ -40,14 +36,15 @@ def setup(app):
4036# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
4137extensions = [
4238 "sphinx.ext.autodoc" ,
43- "sphinx_autodoc_typehints" ,
4439 "sphinx.ext.viewcode" ,
4540 "sphinx.ext.autosummary" ,
4641 "cadquery.cq_directive" ,
4742 "sphinx.ext.mathjax" ,
4843]
4944
50- always_document_param_types = True
45+ autodoc_typehints = "both"
46+ autodoc_typehints_description_target = "all"
47+ autodoc_typehints_format = "short"
5148
5249# Add any paths that contain templates here, relative to this directory.
5350templates_path = ["_templates" ]
@@ -288,3 +285,25 @@ def setup(app):
288285
289286# How to display URL addresses: 'footnote', 'no', or 'inline'.
290287# texinfo_show_urls = 'footnote'
288+
289+
290+ def process_docstring_insert_self (app , what , name , obj , options , lines ):
291+ """
292+ Insert self in front of documented params for instance methods
293+ """
294+
295+ if (
296+ what == "method"
297+ and getattr (obj , "__self__" , None ) is None
298+ and "self" in obj .__annotations__
299+ ):
300+ for i , dstr in enumerate (lines ):
301+ if dstr .startswith (":param" ):
302+ lines .insert (i , ":param self:" )
303+ break
304+
305+
306+ def setup (app ):
307+
308+ app .add_css_file ("tables.css" )
309+ app .connect ("autodoc-process-docstring" , process_docstring_insert_self )
0 commit comments