|
| 1 | +# Configuration file for the Sphinx documentation builder. |
| 2 | + |
| 3 | +project = "OPM Python Documentation" |
| 4 | +copyright = "2024 Equinor ASA" |
| 5 | +author = "Håkon Hægland" |
| 6 | + |
| 7 | +# Function to extract release version from dune.module file |
| 8 | +def extract_opm_simulators_release(): |
| 9 | + version_file_path = '../../../dune.module' |
| 10 | + with open(version_file_path, 'r') as file: |
| 11 | + for line in file: |
| 12 | + if line.startswith('Version:'): |
| 13 | + version_string = line.split(':')[1].strip() |
| 14 | + return version_string |
| 15 | + return "unknown" # Fallback version |
| 16 | + |
| 17 | +release = extract_opm_simulators_release() |
| 18 | + |
| 19 | +# -- General configuration --------------------------------------------------- |
| 20 | +import os |
| 21 | +import sys |
| 22 | + |
| 23 | +# For regular Python packages, the path to the package is usually added to sys.path |
| 24 | +# here such that autodoc can find the modules. However, our Python module |
| 25 | +# opm.simulators.BlackOilSimulator is not generated yet. Since it is a pybind11 |
| 26 | +# extension module, it needs to be compiled as part of the opm-simulators build |
| 27 | +# process (which requires building opm-common first and so on). The full compilation |
| 28 | +# of opm-simulators requres time and storage resources, so we do not want to |
| 29 | +# do this as part of the documentation build. Instead, we will use a sphinx extension |
| 30 | +# (Python script) to generate documentation from a JSON input file. (This JSON file |
| 31 | +# is also is also used to generate a C++ header file with docstrings. The header file |
| 32 | +# is generated when opm-simulators is built and is then included |
| 33 | +# in the pybind11 binding code for the BlackOilSimulator class. In this way, the |
| 34 | +# opm.simulators.BlackOilSimulator Python module will also have access to the docstrings.) |
| 35 | +sys.path.insert(0, os.path.abspath("../src")) |
| 36 | +# Our sphinx extension that will use the docstrings.json file to generate documentation |
| 37 | +extensions = ["opm_simulators_docs.sphinx_ext_docstrings"] |
| 38 | +# Path to docstrings.json |
| 39 | +opm_simulators_docstrings_path = os.path.abspath('../../docstrings_simulators.json') |
| 40 | +opm_common_docstrings_path = os.path.abspath('../../docstrings_common.json') |
| 41 | + |
| 42 | +templates_path = ["_templates"] |
| 43 | +exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"] |
| 44 | + |
| 45 | + |
| 46 | +# -- Options for HTML output ------------------------------------------------- |
| 47 | +# See: https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output |
| 48 | +html_theme = "sphinx_rtd_theme" |
| 49 | +html_static_path = ["_static"] |
| 50 | +html_context = { |
| 51 | + "display_github": True, |
| 52 | + "github_user": "OPM", |
| 53 | + "github_repo": "opm-simulators", |
| 54 | + "github_version": "master", |
| 55 | + "conf_py_path": "/python/docs/", |
| 56 | +} |
0 commit comments