Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve doc generation #537

Merged
merged 41 commits into from
Oct 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
f8a3514
Add an actual clean command.
PProfizi Oct 7, 2022
5651022
Add an actual clean command.
PProfizi Oct 7, 2022
59a7ec7
Set default language as "en" in conf.py to remove warning.
PProfizi Oct 7, 2022
a399da9
Fix 08.averaging\README.txt
PProfizi Oct 7, 2022
a748683
Fix indent
PProfizi Oct 7, 2022
f122405
Fix indent
PProfizi Oct 7, 2022
f4ba135
Fix warnings
PProfizi Oct 7, 2022
75032b0
Exclude examples/python_plugins from APIDOC as well as examples/examp…
PProfizi Oct 7, 2022
0f81110
Indicate to autodoc that ansys.dpf.core.examples.python_plugins shoul…
PProfizi Oct 7, 2022
7352a5a
Resolve sphinx warning
PProfizi Oct 7, 2022
ec1b333
Try installing pandoc
PProfizi Oct 7, 2022
6f5e080
Comment-out other jobs
PProfizi Oct 7, 2022
ce9d569
Comment-out other jobs
PProfizi Oct 7, 2022
f8afb5f
Add -P as argument to sphinx build, which runs the Python debugger pd…
PProfizi Oct 7, 2022
54e788a
Add a reset function after each example equivalent to the kill-dpf-se…
PProfizi Oct 7, 2022
483a25c
try shutting down servers manually.
PProfizi Oct 10, 2022
c24c430
Reset as it did not work.
PProfizi Oct 10, 2022
946f91c
Count servers both before and after each example
PProfizi Oct 10, 2022
ee1d2f5
Count servers both before and after each example
PProfizi Oct 10, 2022
23c5ece
Comment 03-exchange_data_between_servers.py
PProfizi Oct 10, 2022
89d4f75
Comment 11-server_types.py
PProfizi Oct 10, 2022
7a8935b
Add a waiting time for servers to close.
PProfizi Oct 10, 2022
3358caf
Merge branch 'master' into fix/doc_generation_2
PProfizi Oct 12, 2022
62999b4
Add garbage collection and call shutdown_all_session_servers after ea…
PProfizi Oct 12, 2022
0c5a2e1
Revert "Comment 11-server_types.py"
PProfizi Oct 12, 2022
4d7e2ba
Revert "Comment 03-exchange_data_between_servers.py"
PProfizi Oct 12, 2022
78b20ba
Shut servers down and collect garbage before the examples too.
PProfizi Oct 12, 2022
f686012
Merge branch 'master' into fix/doc_generation_2
PProfizi Oct 12, 2022
c037168
Revert "Comment-out other jobs"
PProfizi Oct 12, 2022
6087460
Revert "Comment-out other jobs"
PProfizi Oct 12, 2022
76c1c24
Debug upload_file_in_tmp_folder
PProfizi Oct 12, 2022
ace5829
Debug upload_file_in_tmp_folder
PProfizi Oct 12, 2022
9af3ce9
Remove debug warning
PProfizi Oct 12, 2022
c9d13ab
Use tmp_path pytest fixture instead of deprecated tmpdir in test_serv…
PProfizi Oct 12, 2022
a589153
Unskip test_upload_download on Windows for python 3.7 and 3.8
PProfizi Oct 12, 2022
73902fb
Revert "Unskip test_upload_download on Windows for python 3.7 and 3.8"
PProfizi Oct 12, 2022
d39f567
Revert "Use tmp_path pytest fixture instead of deprecated tmpdir in t…
PProfizi Oct 12, 2022
1882a8a
Revert "Remove debug warning"
PProfizi Oct 12, 2022
f04aecb
Revert "Debug upload_file_in_tmp_folder"
PProfizi Oct 12, 2022
9ee4f12
Revert "Debug upload_file_in_tmp_folder"
PProfizi Oct 12, 2022
6768e5f
Abort the build at first example error
PProfizi Oct 12, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .ci/build_doc.bat
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ call sphinx-apidoc -o ../docs/source/api ../ansys ../ansys/dpf/core/log.py ^
../ansys/dpf/core/help.py ../ansys/dpf/core/mapping_types.py ../ansys/dpf/core/ipconfig.py ^
../ansys/dpf/core/field_base.py ../ansys/dpf/core/cache.py ../ansys/dpf/core/misc.py ^
../ansys/dpf/core/check_version.py ../ansys/dpf/core/operators/build.py ../ansys/dpf/core/operators/specification.py ^
../ansys/dpf/core/vtk_helper.py ../ansys/dpf/core/label_space.py ^
../ansys/dpf/core/vtk_helper.py ../ansys/dpf/core/label_space.py ../ansys/dpf/core/examples/python_plugins/* ^
../ansys/dpf/core/examples/examples.py ^
-f --implicit-namespaces --separate --no-headings
pushd .
cd ../docs/
call make clean
call make html
call make html -v -v -v -P
popd
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,10 @@ jobs:
- name: "Setup Graphviz"
uses: ts-graphviz/setup-graphviz@v1

- name: "Install OS packages"
run: |
choco install pandoc

- name: "Install documentation packages for Python"
run: |
pip install -r requirements/requirements_docs.txt
Expand Down
25 changes: 25 additions & 0 deletions docs/make.bat
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ set SOURCEDIR=source
set BUILDDIR=build

if "%1" == "" goto help
if "%1" == "clean" goto clean

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
Expand All @@ -28,6 +29,30 @@ if errorlevel 9009 (
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end

:clean
echo.Cleaning files form previous build...
IF EXIST "build" (
rmdir "build" /s /q
)
IF EXIST "source\images\auto-generated" (
rmdir "source\images\auto-generated" /s /q
)
IF EXIST "source\examples\07-python-operators\plugins" (
robocopy "source\examples\07-python-operators\plugins" "source\_temp\plugins" /E >nul 2>&1
)
IF EXIST "source\examples" (
rmdir "source\examples" /s /q
)
IF EXIST "source\_temp\plugins" (
robocopy "source\_temp\plugins" "source\examples\07-python-operators\plugins" /E >nul 2>&1
)
IF EXIST "source\_temp" (
rmdir "source\_temp" /s /q
)

echo.Done.
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%

Expand Down
37 changes: 34 additions & 3 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@

autosummary_generate = True

autodoc_mock_imports = ["ansys.dpf.core.examples.python_plugins"]

# Add any paths that contain templates here, relative to this directory.
# templates_path = ['_templates']
Expand All @@ -85,7 +86,7 @@
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None
language = "en"

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
Expand All @@ -99,11 +100,35 @@
# -- Sphinx Gallery Options
from sphinx_gallery.sorting import FileNameSortKey


def reset_servers(gallery_conf, fname, when):
import psutil
from ansys.dpf.core import server
import gc

gc.collect()
server.shutdown_all_session_servers()

proc_name = "Ans.Dpf.Grpc"
nb_procs = 0
for proc in psutil.process_iter():
try:
# check whether the process name matches
if proc_name in proc.name():
# proc.kill()
nb_procs += 1
except psutil.NoSuchProcess:
pass
print(f"Counted {nb_procs} {proc_name} processes {when} the example.")


sphinx_gallery_conf = {
# convert rst to md for ipynb
"pypandoc": True,
# path to your examples scripts
"examples_dirs": ["../../examples"],
# abort build at first example error
'abort_on_example_error': True,
# path where to save gallery generated examples
"gallery_dirs": ["examples"],
# Patter to search for example files
Expand All @@ -118,18 +143,24 @@
# 'first_notebook_cell': ("%matplotlib inline\n"
# "from pyvista import set_plot_theme\n"
# "set_plot_theme('document')"),
"reset_modules_order": 'both',
"reset_modules": (reset_servers,),
}

autodoc_member_order = "bysource"


# -- Options for HTML output -------------------------------------------------
html_short_title = html_title = "PyDPF-Core"
html_theme = "ansys_sphinx_theme"
html_logo = pyansys_logo_black
html_theme_options = {
"github_url": "https://github.com/pyansys/DPF-Core",
"github_url": "https://github.com/pyansys/pydpf-core",
"show_prev_next": False,
"logo_link": "https://dpfdocs.pyansys.com/" # navigate to the main page
"show_breadcrumbs": True,
"additional_breadcrumbs": [
("PyAnsys", "https://docs.pyansys.com/"),
],
}


Expand Down
4 changes: 2 additions & 2 deletions docs/source/user_guide/operators.rst
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ You can create data sources in two ways:


Because several other examples use the ``Model`` class, this example uses the
``DataSources``class:
``DataSources`` class:

.. code-block:: python

Expand Down Expand Up @@ -168,7 +168,7 @@ can also be connected to work on a temporal subset:

Evaluate operators
~~~~~~~~~~~~~~~~~~
With all the required inputs assigned, you can output the :class:`ansys.dpf.core.fields_container`_
With all the required inputs assigned, you can output the :class:`ansys.dpf.core.fields_container`
class from the operator:

.. code-block:: python
Expand Down
2 changes: 1 addition & 1 deletion examples/03-advanced/04-extrapolation_stress_3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
###############################################################################
# Nodal stress result of integration points
###############################################################################
# The MAPLD command ``ERESX,NO``is used to copy directly the
# The MAPLD command ``ERESX,NO`` is used to copy directly the
# Gaussian (integration) points results to the nodes, instead of the
# results at nodes or elements (which are interpolation of results at a
# few gauss points).
Expand Down
2 changes: 1 addition & 1 deletion examples/03-advanced/05-extrapolation_strain_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
###############################################################################
# Extrapolate from integration points for elastic strain result
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# This example uses the ``gauss_to_node_fc``operator to compute nodal component
# This example uses the ``gauss_to_node_fc`` operator to compute nodal component
# elastic strain results from the elastic strain at the integration points.

# Create elastic strain operator to get strain result of integration points
Expand Down
2 changes: 1 addition & 1 deletion examples/03-advanced/10-asme_secviii_divtwo.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
#
# - ``alfasl`` = input("Introduce ``alfasl`` parameter from ASME\n")
# - ``alfasl`` = float(alfasl)
# -``m2`` = input("Introduce ``m2`` parameter from ASME\n")
# - ``m2`` = input("Introduce ``m2`` parameter from ASME\n")
# - ``m2`` = float(m2)
#
# For this exercise, ``alfasl`` = 2.2 and ``m2`` = .288, which is the same
Expand Down
3 changes: 1 addition & 2 deletions examples/08-averaging/00-compute_and_average.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,7 @@ def average_then_compute_von_mises(analysis):
# Plot the results
# ~~~~~~~~~~~~~~~~
# Plot both von Mises stress fields side by side to compare them.
# - The first plot displays the results when the equivalent stresses are calculated
# first.
# - The first plot displays the results when the equivalent stresses are calculated first.
# - The second plot shows the results when the averaging is done first.
#

Expand Down
2 changes: 1 addition & 1 deletion examples/08-averaging/README.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.. _averaging_examples
.. _averaging_examples:

Averaging examples
==================
Expand Down