|
1 | | -# pylint: disable=invalid-name |
2 | | -# pylint: disable=consider-using-f-string |
3 | 1 | """ |
4 | | -Configuration file for building documentation. |
| 2 | +Sphinx configuration for miepython documentation. |
5 | 3 |
|
6 | | -Sphinx builds the docs using couple of external modules: napoleon and nbsphinx. |
7 | | -
|
8 | | -The overall format is controlled by `.rst` files. The top level file is `index.rst` |
9 | | -
|
10 | | -`napoleon` builds the API in HTML assuming that the code is documented with |
11 | | -docstrings that follow the Google docstring format. |
12 | | -
|
13 | | -`nbsphinx` convert the Jupyter notebooks to html with nbsphinx, will |
| 4 | +Uses: |
| 5 | +- sphinx.ext.napoleon for Google-style docstrings |
| 6 | +- nbsphinx for rendering Jupyter notebooks (pre-executed; no execution on RTD) |
14 | 7 | """ |
15 | | -import re |
16 | | -import os.path |
| 8 | +from importlib.metadata import version as pkg_version |
17 | 9 |
|
18 | 10 | project = "miepython" |
| 11 | +release = pkg_version(project) |
| 12 | +version = release |
19 | 13 |
|
| 14 | +root_doc = "index" |
20 | 15 |
|
21 | | -def get_init_property(prop): |
22 | | - """Return property from __init__.py.""" |
23 | | - here = os.path.abspath(os.path.dirname(__file__)) |
24 | | - file_name = os.path.join(here, "..", project, "__init__.py") |
25 | | - regex = r'{}\s*=\s*[\'"]([^\'"]*)[\'"]'.format(prop) |
26 | | - with open(file_name, "r", encoding="utf-8") as file: |
27 | | - result = re.search(regex, file.read()) |
28 | | - return result.group(1) |
29 | | - |
30 | | - |
31 | | -release = get_init_property("__version__") |
32 | | -author = get_init_property("__author__") |
33 | | -copyright = get_init_property("__copyright__") |
34 | | - |
35 | | -master_doc = "index" |
36 | | - |
37 | | -# -- General configuration --------------------------------------------------- |
38 | | - |
39 | | -# Sphinx extension modules |
40 | 16 | extensions = [ |
| 17 | + "sphinx.ext.autodoc", |
41 | 18 | "sphinx.ext.napoleon", |
42 | 19 | "sphinx.ext.viewcode", |
43 | 20 | "sphinx.ext.mathjax", |
44 | 21 | "sphinx_automodapi.automodapi", |
45 | 22 | "nbsphinx", |
46 | 23 | ] |
47 | | -numpydoc_show_class_members = False |
| 24 | + |
48 | 25 | napoleon_use_param = False |
49 | 26 | napoleon_use_rtype = False |
| 27 | +numpydoc_show_class_members = False |
50 | 28 |
|
51 | | -# List of patterns, relative to source directory, of files to ignore |
52 | | -exclude_patterns = ["_build", "14_fields.ipynb", "1d-efield.ipynb", "Untitled*", "MnNn-calc.ipynb"] |
| 29 | +exclude_patterns = [ |
| 30 | + "_build", |
| 31 | + ".ipynb_checkpoints", |
| 32 | + "Untitled*.ipynb", |
| 33 | + "x_MnNn_calc.ipynb", |
| 34 | + "x_14_fields.ipynb", |
| 35 | + "x_one_d_efield.ipynb", |
| 36 | +] |
53 | 37 |
|
54 | | -# I execute the notebooks manually in advance. |
55 | 38 | nbsphinx_execute = "never" |
56 | | -nbsphinx_allow_errors = True |
57 | | - |
58 | | -# -- Options for HTML output ------------------------------------------------- |
| 39 | +nbsphinx_allow_errors = False |
59 | 40 |
|
60 | 41 | html_theme = "sphinx_rtd_theme" |
61 | 42 | html_scaled_image_link = False |
|
0 commit comments