Skip to content

Commit e06ff3a

Browse files
Revathyvenugopal162pre-commit-ci[bot]pyansys-ci-bot
authored
fix: hide some implementation from run package and migrate to theme autoapi (#797)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: pyansys-ci-bot <92810346+pyansys-ci-bot@users.noreply.github.com>
1 parent 066ef83 commit e06ff3a

File tree

14 files changed

+61
-54
lines changed

14 files changed

+61
-54
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,4 +164,4 @@ cython_debug/
164164
# Ignore rendered examples
165165
doc/source/examples/
166166
doc/source/API/_autosummary/
167-
doc/source/autoapi
167+
doc/source/api

doc/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ SPHINXOPTS = -j auto
77
SPHINXBUILD = sphinx-build
88
SOURCEDIR = source
99
BUILDDIR = _build
10+
APIDIR = api
1011

1112
# Put it first so that "make" without argument is like "make help".
1213
help:
@@ -22,7 +23,7 @@ help:
2223
clean:
2324
rm -rf $(BUILDDIR)/*
2425
rm -rf source/examples/gallery_examples
25-
find . -type d -name "_autosummary" -exec rm -rf {} +
26+
find . -type d -name $(APIDIR) -exec rm -rf {} +
2627

2728
pdf:
2829
@$(SPHINXBUILD) -M latex "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

doc/changelog/797.fixed.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
hide some implementation from run package and migrate to theme autoapi

doc/make.bat

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ if "%SPHINXBUILD%" == "" (
99
)
1010
set SOURCEDIR=source
1111
set BUILDDIR=_build
12+
set APIDIR=source\api
1213

1314
if "%1" == "" goto help
1415
if "%1" == "clean" goto clean
@@ -32,7 +33,7 @@ goto end
3233

3334
:clean
3435
rmdir /s /q %BUILDDIR% > /NUL 2>&1
35-
for /d /r %SOURCEDIR% %%d in (_autosummary) do @if exist "%%d" rmdir /s /q "%%d"
36+
rmdir /s /q %APIDIR% > /NUL 2>&1
3637
goto end
3738

3839
:help

doc/source/_autoapi_templates/index.rst

Lines changed: 0 additions & 15 deletions
This file was deleted.

doc/source/conf.py

Lines changed: 34 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
copyright = f"(c) {datetime.datetime.now().year} ANSYS, Inc. All rights reserved"
1919
author = 'ANSYS Inc.'
2020
release = version = __version__
21-
cname = os.getenv("DOCUMENTATION_CNAME", default="nocname.com")
21+
cname = os.getenv("DOCUMENTATION_CNAME", default="dyna.docs.pyansys.com")
2222

2323
# Sphinx extensions
2424
extensions = [
@@ -31,6 +31,7 @@
3131
"sphinx_jinja",
3232
"pyvista.ext.plot_directive",
3333
"sphinx_design",
34+
"ansys_sphinx_theme.extension.autoapi",
3435
]
3536

3637
# Intersphinx mapping
@@ -126,6 +127,13 @@
126127
],
127128
"collapse_navigation": True,
128129
"use_edit_page_button": True,
130+
"ansys_sphinx_theme_autoapi": {
131+
"project": project,
132+
"ignore": [
133+
"*core/keywords/keyword_classes/auto*",
134+
],
135+
"output": "api",
136+
},
129137
}
130138

131139
# static path
@@ -134,25 +142,8 @@
134142

135143
# -- Declare the Jinja context -----------------------------------------------
136144
BUILD_API = True if os.environ.get("BUILD_API", "true") == "true" else False
137-
if not BUILD_API:
138-
exclude_patterns.append("_autoapi_templates")
139-
else:
140-
# Configuration for Sphinx autoapi
141-
extensions.append("autoapi.extension")
142-
autoapi_dirs = ["../../src/ansys"]
143-
autoapi_ignore = ["*core/keywords/keyword_classes/auto*"]
144-
autoapi_type = "python"
145-
autoapi_options = [
146-
"members",
147-
"undoc-members",
148-
"show-inheritance",
149-
"show-module-summary",
150-
"special-members",
151-
]
152-
autoapi_template_dir = "_autoapi_templates"
153-
suppress_warnings = ["autoapi.python_import_resolution", "config.cache"]
154-
exclude_patterns.append("_autoapi_templates/index.rst")
155-
autoapi_python_use_implicit_namespaces = True
145+
146+
suppress_warnings = ["autoapi.python_import_resolution", "config.cache"]
156147

157148
BUILD_EXAMPLES = (
158149
True if os.environ.get("BUILD_EXAMPLES", "true") == "true" else False
@@ -194,3 +185,26 @@
194185
"build_examples": BUILD_EXAMPLES,
195186
},
196187
}
188+
189+
190+
def skip_run_subpackage(app, what, name, obj, skip, options):
191+
"""Skip specific members of the 'run' subpackage during documentation generation.
192+
193+
This function skips:
194+
- All modules under 'ansys.dyna.core.run' except 'local_solver' and 'options'.
195+
- Within 'local_solver', skips all members except the 'run_dyna' function.
196+
"""
197+
198+
199+
if name.startswith("ansys.dyna.core.run.") and not (name.startswith("ansys.dyna.core.run.local_solver") or name.startswith("ansys.dyna.core.run.options")):
200+
skip = True
201+
202+
if name.startswith("ansys.dyna.core.run.local_solver"):
203+
if what == "function" and name!= "ansys.dyna.core.run.local_solver.run_dyna":
204+
skip = True
205+
206+
return skip
207+
208+
def setup(sphinx):
209+
"""Add custom extensions to Sphinx."""
210+
sphinx.connect("autoapi-skip-member", skip_run_subpackage)

doc/source/index.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ PyDYNA documentation |version|
2424

2525
{% if build_api %}
2626
.. grid-item-card:: :fa:`wrench` API reference
27-
:link: autoapi/index
27+
:link: api/index
2828
:link-type: doc
2929

3030
Explore the API reference documentation for PyDYNA, including
@@ -33,6 +33,7 @@ PyDYNA documentation |version|
3333
{% endif %}
3434

3535
{% if build_examples %}
36+
3637
.. grid-item-card:: :fa:`clone` Examples
3738
:link: examples/index
3839
:link-type: doc
@@ -65,7 +66,7 @@ PyDYNA documentation |version|
6566
getting-started/index
6667
user-guide/index
6768
{% if build_api %}
68-
autoapi/index
69+
api/index
6970
{% endif %}
7071
{% if build_examples %}
7172
examples/index

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ doc = [
8080
"sphinx-copybutton==0.5.2",
8181
"sphinx-gallery==0.19.0",
8282
"sphinx-autodoc-typehints==3.1.0",
83-
"ansys-sphinx-theme==1.3.2",
83+
"ansys-sphinx-theme==1.4.2",
8484
"pypandoc==1.15",
8585
"nbsphinx==0.9.6",
8686
"ipywidgets==8.1.6",

src/ansys/dyna/core/lib/deck.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -252,10 +252,10 @@ def _expand_helper(self, search_paths: typing.List[str], recurse: bool) -> typin
252252
def expand(self, cwd=None, recurse=True):
253253
"""Get a new deck that is flattened copy of `self`.
254254
255-
A flattened deck is one where the *INCLUDE keywords are replaced
255+
A flattened deck is one where the ``*INCLUDE`` keywords are replaced
256256
by the contents of the file that is included.
257257
`cwd` is a working directory used to resolve the filename
258-
If `recurse` is true, *INCLUDE keywords within included decks
258+
If `recurse` is true, ``*INCLUDE`` keywords within included decks
259259
are expanded, recursively.
260260
"""
261261
cwd = cwd or os.getcwd()
@@ -424,7 +424,7 @@ def get_kwds_by_type(self, str_type: str) -> typing.Iterator[KeywordBase]:
424424
425425
Examples
426426
--------
427-
Get all *SECTION_* keywords in the deck.
427+
Get all ``*SECTION_*`` keywords in the deck.
428428
429429
>>>deck.get_kwds_by_type("SECTION")
430430
"""
@@ -446,7 +446,7 @@ def get_kwds_by_full_type(self, str_type: str, str_subtype: str) -> typing.Itera
446446
447447
Examples
448448
--------
449-
Get all *SECTION_SHELL keyword instances in the deck.
449+
Get all ``*SECTION_SHELL`` keyword instances in the deck.
450450
451451
>>>deck.get_kwds_by_full_type("SECTION", "SHELL")
452452
"""
@@ -485,10 +485,11 @@ def get(self, **kwargs) -> typing.List[KeywordBase]:
485485
486486
Parameters
487487
----------
488-
:Keyword Arguments:
489-
* *type* (``str``) --
488+
- *kwargs* (``dict``) --
489+
Keyword arguments.
490+
* *type* (``str``) --
490491
The type of keyword to get. For example, "SECTION" returns all section keywords.
491-
* *filter* (``callable``) --
492+
* *filter* (``callable``) --
492493
The filter to apply to the result. Only keywords which pass the filter will be returned.
493494
494495
"""

src/ansys/dyna/core/lib/kwd_line_formatter.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,11 @@ def _contract_data(spec: typing.List[tuple], data: typing.List) -> typing.Iterab
127127
def load_dataline(spec: typing.List[tuple], line_data: str, parameter_set: ParameterSet = None) -> typing.List:
128128
"""loads a keyword card line with fixed column offsets and width from string
129129
spec: list of tuples representing the (offset, width, type) of each field
130-
type can be a Flag which represents the True and False value
130+
type can be a Flag which represents the True and False value
131131
line_data: string with keyword data
132-
example:
132+
133+
Example
134+
-------
133135
>>> load_dataline([(0,10, int),(10,10, str)], ' 1 hello')
134136
(1, 'hello')
135137
"""

0 commit comments

Comments
 (0)