Skip to content

Commit 346829e

Browse files
authored
Add documentation rendering (#250)
* Add cython signatures * Add documentation based on sphinx * Add changelog
1 parent 10e6a3f commit 346829e

File tree

7 files changed

+87
-0
lines changed

7 files changed

+87
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
.idea # Pycharm related file
33
*.so
44
build
5+
docs/_build
6+
docs/.docs_venv
57
*.egg-info
68
__pycache__
79
env

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
All notable changes to this project will be documented in this file.
44

5+
## latest
6+
7+
* Added support for documentation rendering https://github.com/precice/python-bindings/pull/250
8+
59
## 3.3.1
610

711
* Remove root user option from the usage of the preCICE image in the release workflow https://github.com/precice/python-bindings/commit/0a9ccd449e875f0165bebc968b3a23d6d9094b0d

docs/build.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env bash
2+
3+
if [[ ! -f "../pyproject.toml" ]]; then
4+
echo "Please run from the docs directory."
5+
exit 1
6+
fi
7+
8+
TARGET=singlehtml
9+
10+
python3 -m venv --clear .docs_venv
11+
12+
echo "Installing dependencies"
13+
.docs_venv/bin/pip install sphinx myst_parser sphinx-rtd-theme
14+
15+
echo "Installing python bindings"
16+
.docs_venv/bin/pip install --force --no-cache ..
17+
18+
echo "Building the website"
19+
.docs_venv/bin/sphinx-build -M ${TARGET} . _build

docs/conf.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Configuration file for the Sphinx documentation builder.
2+
#
3+
# For the full list of built-in configuration values, see the documentation:
4+
# https://www.sphinx-doc.org/en/master/usage/configuration.html
5+
6+
import datetime
7+
8+
project = "pyprecice"
9+
author = "The preCICE developers"
10+
copyright = f"{datetime.datetime.now().year}, {author}"
11+
12+
extensions = [
13+
"sphinx.ext.autodoc",
14+
"sphinx.ext.intersphinx",
15+
"myst_parser",
16+
]
17+
18+
intersphinx_mapping = {
19+
"python": ("https://docs.python.org/3/", None),
20+
"numpy": ("https://numpy.org/doc/stable/", None),
21+
"mpi4py": ("https://mpi4py.readthedocs.io/en/latest/", None),
22+
}
23+
24+
# exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", ".docs_venv"]
25+
include_patterns = ["*.rst", "*.md"]
26+
27+
html_theme = "sphinx_rtd_theme"
28+
29+
source_suffix = {
30+
".rst": "restructuredtext",
31+
".md": "markdown",
32+
}
33+
34+
autodoc_class_signature = "separated"
35+
autodoc_typehints = "description"
36+
autodoc_typehints_format = "short"
37+
autodoc_member_order = "bysource"
38+
39+
suppress_warnings = ["myst.xref_missing"]
40+
41+
# The cython detection relyies on a built and installed version of the package
42+
try:
43+
import precice
44+
except:
45+
raise RuntimeError("Cannot import precice. Please install pyprecice first")

docs/index.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
The preCICE python bindings
2+
===========================
3+
4+
.. toctree::
5+
:maxdepth: 1
6+
:caption: Contents:
7+
8+
precice
9+
MigrationGuide
10+
ReleaseGuide

docs/precice.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
The pyprecice package
2+
=====================
3+
4+
.. automodule:: cyprecice
5+
:members:
6+
:undoc-members:

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ def get_extensions():
4848
extra_compile_args=compile_args,
4949
extra_link_args=link_args,
5050
define_macros=[("NPY_NO_DEPRECATED_API", "NPY_1_7_API_VERSION")],
51+
cython_directives={"embedsignature": True},
5152
)
5253
]
5354

0 commit comments

Comments
 (0)