Skip to content

Commit fbb2cca

Browse files
authored
maint: implementing autoapi and general maintenance (#167)
1 parent cafd321 commit fbb2cca

25 files changed

+72
-214
lines changed

doc/Makefile

+11-2
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,20 @@ help:
1616
# Catch-all target: route all unknown targets to Sphinx using the new
1717
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
1818
%: Makefile
19-
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
19+
# TODO: these lines of code until $(SPHINXBUILD) should be removed once the feature branch is merged
20+
pip freeze > temp_req.txt;
21+
@if grep -q "sphinx-autoapi @ git+https://github.com/ansys/sphinx-autoapi" temp_req.txt;\
22+
then\
23+
echo found;\
24+
else\
25+
pip uninstall --yes sphinx-autoapi;\
26+
pip install "sphinx-autoapi @ git+https://github.com/ansys/sphinx-autoapi@feat/single-page-stable";\
27+
fi
28+
rm temp_req.txt;\
29+
$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O);
2030

2131
clean:
2232
rm -rf $(BUILDDIR)/*
23-
find . -type d -name "_autosummary" -exec rm -rf {} +
2433

2534
pdf:
2635
@$(SPHINXBUILD) -M latex "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

doc/make.bat

+7
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ if "%SPHINXBUILD%" == "" (
1010
set SOURCEDIR=source
1111
set BUILDDIR=_build
1212

13+
REM TODO: these lines of code should be removed once the feature branch is merged
14+
for /f %%i in ('pip freeze ^| findstr /c:"sphinx-autoapi @ git+https://github.com/ansys/sphinx-autoapi"') do set is_custom_sphinx_autoapi_installed=%%i
15+
if NOT "%is_custom_sphinx_autoapi_installed%" == "sphinx-autoapi" (
16+
pip uninstall --yes sphinx-autoapi
17+
pip install "sphinx-autoapi @ git+https://github.com/ansys/sphinx-autoapi@feat/single-page-stable")
18+
REM TODO: these lines of code should be removed once the feature branch is merged
19+
1320
if "%1" == "" goto help
1421
if "%1" == "clean" goto clean
1522
if "%1" == "linkcheck" goto linkcheck

doc/source/api/ast_class.rst

-74
This file was deleted.

doc/source/api/ast_functions.rst

-14
This file was deleted.

doc/source/api/autogenerateddirectory.rst

-11
This file was deleted.

doc/source/api/custom_functions.rst

-12
This file was deleted.

doc/source/api/directory_format.rst

-13
This file was deleted.

doc/source/api/download.rst

-14
This file was deleted.

doc/source/api/index.rst

-21
This file was deleted.

doc/source/api/load_xml_doc.rst

-14
This file was deleted.

doc/source/api/oxygen_xml.rst

-11
This file was deleted.

doc/source/api/writer.rst

-14
This file was deleted.

doc/source/conf.py

+42-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
"""Sphinx documentation configuration file."""
22
from datetime import datetime
33
import os
4-
5-
from ansys_sphinx_theme import ansys_favicon, get_version_match, pyansys_logo_black
4+
from pathlib import Path
5+
6+
from ansys_sphinx_theme import (
7+
ansys_favicon,
8+
get_autoapi_templates_dir_relative_path,
9+
get_version_match,
10+
pyansys_logo_black,
11+
)
612
from pyconverter.xml2py import __version__
713

814
# Project information
@@ -61,7 +67,7 @@
6167
"jupyter_sphinx",
6268
"numpydoc",
6369
"sphinx.ext.autodoc",
64-
"sphinx.ext.autosummary",
70+
"autoapi.extension",
6571
"sphinx_autodoc_typehints",
6672
"sphinx.ext.intersphinx",
6773
"sphinx.ext.extlinks",
@@ -84,14 +90,16 @@
8490
# numpydoc configuration
8591
numpydoc_show_class_members = False
8692
numpydoc_xref_param_type = True
93+
numpydoc_xref_param_type = True
94+
autosectionlabel_prefix_document = True
8795

8896
# Consider enabling numpydoc validation. See:
8997
# https://numpydoc.readthedocs.io/en/latest/validation.html#
9098
numpydoc_validate = True
9199
numpydoc_validation_checks = {
92100
"GL06", # Found unknown section
93101
"GL07", # Sections are in the wrong order.
94-
"GL08", # The object does not have a docstring
102+
# "GL08", # The object does not have a docstring
95103
"GL09", # Deprecation warning should precede extended summary
96104
"GL10", # reST directives {directives} must be followed by two colons
97105
"SS01", # No summary found
@@ -115,6 +123,36 @@
115123
# The master toctree document.
116124
master_doc = "index"
117125

126+
# Configuration for Sphinx autoapi
127+
autoapi_type = "python"
128+
autoapi_dirs = ["../../src"]
129+
autoapi_root = "api"
130+
autoapi_options = [
131+
"members",
132+
"undoc-members",
133+
"show-inheritance",
134+
"show-module-summary",
135+
"special-members",
136+
]
137+
autoapi_template_dir = get_autoapi_templates_dir_relative_path(Path(__file__))
138+
suppress_warnings = ["autoapi.python_import_resolution"]
139+
autoapi_python_use_implicit_namespaces = True
140+
autoapi_render_in_single_page = ["class", "enum", "exception"]
141+
142+
143+
def prepare_jinja_env(jinja_env) -> None:
144+
"""
145+
Customize the jinja env.
146+
147+
Notes
148+
-----
149+
See https://jinja.palletsprojects.com/en/3.0.x/api/#jinja2.Environment
150+
"""
151+
jinja_env.globals["project_name"] = project
152+
153+
154+
autoapi_prepare_jinja_env = prepare_jinja_env
155+
118156
# The language for content autogenerated by Sphinx. Refer to documentation
119157
# for a list of supported languages.
120158
#

doc/source/user_guide/index.rst

-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ directory by default. This diagram presents the format of the
6868

6969
.. toctree::
7070
:maxdepth: 1
71-
:hidden:
7271

7372
source_code
7473
objects

doc/source/user_guide/objects.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ XML objects
22
===========
33

44
This section describes common objects handled by the converter. It is not
5-
an exhaustive list. For more information, see :ref:`ref_api`.
5+
an exhaustive list. For more information, see the API reference section.
66

77
Images
88
------

pyproject.toml

+1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ doc = [
6262
"pytest-sphinx==0.5.0",
6363
"sphinx-autobuild==2021.3.14",
6464
"sphinx-autodoc-typehints==1.25.2",
65+
"sphinx-autoapi==3.0.0", # "sphinx-autoapi @ git+https://github.com/ansys/sphinx-autoapi@feat/single-page-option", ---> Installed directly in workflow
6566
"sphinx-copybutton==0.5.2",
6667
"sphinx-notfound-page==1.0.0",
6768
"sphinx-gallery==0.15.0",

src/pyconverter/xml2py/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2023 ANSYS, Inc. All rights reserved.
1+
# Copyright (c) 2024 ANSYS, Inc. All rights reserved.
22

33
"""
44
pyconverter.xml2py

src/pyconverter/xml2py/ast_tree.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2023 ANSYS, Inc. All rights reserved.
1+
# Copyright (c) 2024 ANSYS, Inc. All rights reserved.
22

33
import logging
44
import re

src/pyconverter/xml2py/cli.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2023 ANSYS, Inc. All rights reserved.
1+
# Copyright (c) 2024 ANSYS, Inc. All rights reserved.
22

33
"""Command Line Interface for PyConverter-XML2Py."""
44

src/pyconverter/xml2py/custom_functions.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2023 ANSYS, Inc. All rights reserved.
1+
# Copyright (c) 2024 ANSYS, Inc. All rights reserved.
22

33
import glob
44
import os

src/pyconverter/xml2py/directory_format.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2023 ANSYS, Inc. All rights reserved.
1+
# Copyright (c) 2024 ANSYS, Inc. All rights reserved.
22

33
import argparse
44
import os

src/pyconverter/xml2py/download.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Copyright (c) 2024 ANSYS, Inc. All rights reserved.
2+
13
"""Functions to download template datasets from the pyconverter-xml2py repository.
24
"""
35

0 commit comments

Comments
 (0)