Skip to content

Commit ee90f2c

Browse files
authored
Fix doc issue where parameters listed twice in description (#916)
* Update sphinx pin to version 4.4.0 * Remove sphinx extension sphinx_autodoc_typehints
1 parent 3efb080 commit ee90f2c

File tree

3 files changed

+28
-9
lines changed

3 files changed

+28
-9
lines changed

doc/conf.py

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@
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.
4137
extensions = [
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.
5350
templates_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)

doc/primer.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
.. _3d_cad_primer:
22

33
.. _cadquery_concepts:
4+
45
CadQuery Concepts
56
===================================
67

@@ -274,7 +275,7 @@ knowledge of the different C++ libraries to be able to achieve what you want. To
274275
The package name of any class is written at the top of the documentation page. Often it's written in the class name itself as a prefix.
275276

276277
Going back and forth between the APIs
277-
~~~~~~~~~~~~~~~~~~~~~~
278+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
278279

279280
While the 3 APIs provide 3 different layer of complexity and functionality you can mix the 3 layers as you wish.
280281
Below is presented the different ways you can interact with the different API layers.

environment.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@ dependencies:
88
- ipython
99
- ocp=7.5.1
1010
- pyparsing>=2.1.9
11-
- sphinx=3.2.1
11+
- sphinx=4.4.0
1212
- sphinx_rtd_theme
13-
- sphinx-autodoc-typehints
1413
- black=19.10b0
1514
- mypy
1615
- codecov

0 commit comments

Comments
 (0)