|
| 1 | +#!python3 |
| 2 | + |
| 3 | +""" |
| 4 | +Configuration for project documentation using Sphinx. |
| 5 | +""" |
| 6 | + |
| 7 | +# standard |
| 8 | +import sys |
| 9 | +from datetime import datetime |
| 10 | +from os import environ, path |
| 11 | + |
| 12 | +sys.path.insert(0, path.abspath("..")) # move into project package |
| 13 | + |
| 14 | +# Package |
| 15 | +from profile_manager import __about__ |
| 16 | + |
| 17 | +# -- Project information ----------------------------------------------------- |
| 18 | +author = __about__.__author__ |
| 19 | +copyright = __about__.__copyright__ |
| 20 | +description = __about__.__summary__ |
| 21 | +project = __about__.__title__ |
| 22 | +version = release = __about__.__version__ |
| 23 | + |
| 24 | +# -- General configuration --------------------------------------------------- |
| 25 | + |
| 26 | +# Add any Sphinx extension module names here, as strings. They can be |
| 27 | +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom |
| 28 | +# ones. |
| 29 | +extensions = [ |
| 30 | + # Sphinx included |
| 31 | + "sphinx.ext.autodoc", |
| 32 | + "sphinx.ext.autosectionlabel", |
| 33 | + "sphinx.ext.extlinks", |
| 34 | + "sphinx.ext.githubpages", |
| 35 | + "sphinx.ext.intersphinx", |
| 36 | + "sphinx.ext.viewcode", |
| 37 | + # 3rd party |
| 38 | + "myst_parser", |
| 39 | + "sphinx_copybutton", |
| 40 | +] |
| 41 | + |
| 42 | + |
| 43 | +# The suffix(es) of source filenames. |
| 44 | +# You can specify multiple suffix as a list of string: |
| 45 | +source_suffix = {".md": "markdown", ".rst": "restructuredtext"} |
| 46 | +autosectionlabel_prefix_document = True |
| 47 | +# The master toctree document. |
| 48 | +master_doc = "index" |
| 49 | + |
| 50 | + |
| 51 | +# List of patterns, relative to source directory, that match files and |
| 52 | +# directories to ignore when looking for source files. |
| 53 | +# This pattern also affects html_static_path and html_extra_path . |
| 54 | +exclude_patterns = [ |
| 55 | + "_build", |
| 56 | + ".venv", |
| 57 | + "Thumbs.db", |
| 58 | + ".DS_Store", |
| 59 | + "_output", |
| 60 | + "ext_libs", |
| 61 | + "tests", |
| 62 | + "demo", |
| 63 | +] |
| 64 | + |
| 65 | +# The name of the Pygments (syntax highlighting) style to use. |
| 66 | +pygments_style = "sphinx" |
| 67 | + |
| 68 | + |
| 69 | +# -- Options for HTML output ------------------------------------------------- |
| 70 | + |
| 71 | +# -- Theme |
| 72 | + |
| 73 | +html_favicon = str(__about__.__icon_path__) |
| 74 | +html_logo = str(__about__.__icon_path__) |
| 75 | +# uncomment next line if you store some statics which are not directly linked into the markdown/RST files |
| 76 | +# html_static_path = ["static/include_additional"] |
| 77 | +html_theme = "furo" |
| 78 | + |
| 79 | +# -- EXTENSIONS -------------------------------------------------------- |
| 80 | + |
| 81 | +# Sphinx API doc |
| 82 | +autodoc_mock_imports = [ |
| 83 | + "qgis.core", |
| 84 | + "qgis.gui", |
| 85 | + "qgis.PyQt", |
| 86 | + "qgis.PyQt.QtCore", |
| 87 | + "qgis.PyQt.QtGui", |
| 88 | + "qgis.PyQt.QtNetwork", |
| 89 | + "qgis.PyQt.QtWidgets", |
| 90 | + "qgis.utils", |
| 91 | +] |
| 92 | + |
| 93 | +# Configuration for intersphinx (refer to others docs). |
| 94 | +intersphinx_mapping = { |
| 95 | + "PyQt5": ("https://www.riverbankcomputing.com/static/Docs/PyQt5", None), |
| 96 | + "python": ("https://docs.python.org/3/", None), |
| 97 | + "qgis": ("https://qgis.org/pyqgis/master/", None), |
| 98 | +} |
| 99 | + |
| 100 | +# MyST Parser |
| 101 | +myst_enable_extensions = [ |
| 102 | + "colon_fence", |
| 103 | + "deflist", |
| 104 | + "dollarmath", |
| 105 | + "html_image", |
| 106 | + "linkify", |
| 107 | + "replacements", |
| 108 | + "smartquotes", |
| 109 | + "substitution", |
| 110 | +] |
| 111 | + |
| 112 | +myst_substitutions = { |
| 113 | + "author": author, |
| 114 | + "date_update": datetime.now().strftime("%d %B %Y"), |
| 115 | + "description": description, |
| 116 | + "qgis_version_max": __about__.__plugin_md__.get("general").get( |
| 117 | + "qgismaximumversion" |
| 118 | + ), |
| 119 | + "qgis_version_min": __about__.__plugin_md__.get("general").get( |
| 120 | + "qgisminimumversion" |
| 121 | + ), |
| 122 | + "repo_url": __about__.__uri__, |
| 123 | + "title": project, |
| 124 | + "version": version, |
| 125 | +} |
| 126 | + |
| 127 | +myst_url_schemes = ("http", "https", "mailto") |
| 128 | + |
| 129 | + |
| 130 | +# -- API Doc -------------------------------------------------------- |
| 131 | +# run api doc |
| 132 | +def run_apidoc(_): |
| 133 | + from sphinx.ext.apidoc import main |
| 134 | + |
| 135 | + cur_dir = path.normpath(path.dirname(__file__)) |
| 136 | + output_path = path.join(cur_dir, "_apidoc") |
| 137 | + modules = path.normpath(path.join(cur_dir, "../profile_manager")) |
| 138 | + exclusions = ["../.venv", "../tests"] |
| 139 | + main(["-e", "-f", "-M", "-o", output_path, modules] + exclusions) |
| 140 | + |
| 141 | + |
| 142 | +# launch setup |
| 143 | +def setup(app): |
| 144 | + app.connect("builder-inited", run_apidoc) |
0 commit comments