Skip to content

Commit 518d7bf

Browse files
MAINT: add typehint example (#169)
* add typehint in plot_contour to test extension * add autodoc_typehints variable * follow exact notation in sphinx-autodoc-typehints documentation * working version when docs generated locally * typehints example in plot_contour * fix style * remove Optional * remove Optional Co-authored-by: PProfizi <[email protected]>
1 parent 32bd9bd commit 518d7bf

File tree

4 files changed

+13
-8
lines changed

4 files changed

+13
-8
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ instance/
7171
.scrapy
7272

7373
# Sphinx documentation
74-
doc/build/
74+
docs/build/
75+
docs/source/api/_autosummary
76+
docs/source/examples
7577

7678
# PyBuilder
7779
.pybuilder/

docs/source/conf.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@
5555
"sphinx_gallery.gen_gallery",
5656
]
5757

58+
typehints_defaults = "comma"
59+
simplify_optional_unions = False
60+
5861
# Intersphinx mapping
5962
intersphinx_mapping = {
6063
"python": ("https://docs.python.org/dev", None),

requirements/requirements_docs.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ sphinx-notfound-page==0.8.3
1111
sphinx-copybutton==0.5.0
1212
sphinx-gallery==0.11.1
1313
ansys_sphinx_theme==0.6.0
14-
sphinx-autodoc-typehints
14+
sphinx-autodoc-typehints==1.19.1

src/ansys/dpf/post/result_data.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ def _sort_fields_container_with_labels(self, option_id, display_option):
322322
new_fields_container.add_field(label, field)
323323
return new_fields_container
324324

325-
def plot_contour(self, display_option: str = "time", option_id=1, **kwargs):
325+
def plot_contour(self, display_option: str = "time", option_id: int = 1, **kwargs):
326326
"""Plot the contour result on its mesh support.
327327
328328
The obtained figure depends on the support, which can be a
@@ -333,11 +333,11 @@ def plot_contour(self, display_option: str = "time", option_id=1, **kwargs):
333333
334334
Parameters
335335
----------
336-
display_option : str, optional
337-
Name of the label to display. The default is ``"time"``.
338-
option_id: int, optional
339-
Label ID to display. The default is ``1``.
340-
**kwargs : optional
336+
display_option :
337+
Name of the label to display.
338+
option_id :
339+
Label ID to display.
340+
**kwargs :
341341
Additional keyword arguments for the plotter. For keyword
342342
arguments, see ``help(pyvista.plot)``.
343343

0 commit comments

Comments
 (0)