|
4 | 4 | # list see the documentation:
|
5 | 5 | # https://www.sphinx-doc.org/en/master/usage/configuration.html
|
6 | 6 |
|
| 7 | +from functools import partial |
| 8 | +from pathlib import Path |
| 9 | + |
| 10 | +from setuptools_scm import get_version |
| 11 | + |
7 | 12 | from sphinx.application import Sphinx
|
8 | 13 | from sphinx.util.docutils import SphinxDirective
|
9 | 14 |
|
10 |
| -from myst_parser import __version__ |
11 | 15 |
|
| 16 | +# -- Path setup -------------------------------------------------------------- |
| 17 | + |
| 18 | +PROJECT_ROOT_DIR = Path(__file__).parents[1].resolve() # pylint: disable=no-member |
| 19 | +get_scm_version = partial(get_version, root=PROJECT_ROOT_DIR) |
12 | 20 | # -- Project information -----------------------------------------------------
|
13 | 21 |
|
| 22 | +github_url = 'https://github.com' |
| 23 | +github_repo_org = 'ansible' |
| 24 | +github_repo_name = 'ansible-language-server' |
| 25 | +github_repo_slug = f'{github_repo_org}/{github_repo_name}' |
| 26 | +github_repo_url = f'{github_url}/{github_repo_slug}' |
| 27 | +github_sponsors_url = f'{github_url}/sponsors' |
| 28 | + |
14 | 29 | project = "MyST Parser"
|
15 | 30 | copyright = "2020, Executable Book Project"
|
16 | 31 | author = "Executable Book Project"
|
17 |
| -version = __version__ |
| 32 | + |
| 33 | +# The short X.Y version |
| 34 | +version = '.'.join( |
| 35 | + get_scm_version( |
| 36 | + local_scheme='no-local-version', |
| 37 | + ).split('.')[:3], |
| 38 | +) |
| 39 | + |
| 40 | +# The full version, including alpha/beta/rc tags |
| 41 | +release = get_scm_version() |
| 42 | + |
18 | 43 |
|
19 | 44 | master_doc = "index"
|
20 | 45 | language = "en"
|
|
27 | 52 | extensions = [
|
28 | 53 | "myst_parser",
|
29 | 54 | "sphinx.ext.autodoc",
|
| 55 | + 'sphinx.ext.extlinks', |
30 | 56 | "sphinx.ext.intersphinx",
|
31 | 57 | "sphinx.ext.viewcode",
|
32 | 58 | "sphinxcontrib.bibtex",
|
33 | 59 | "sphinx_panels",
|
34 | 60 | "sphinxext.rediraffe",
|
35 | 61 | "sphinxcontrib.mermaid",
|
36 | 62 | "sphinxext.opengraph",
|
| 63 | + 'sphinxcontrib.towncrier', # provides `towncrier-draft-entries` directive |
37 | 64 | ]
|
38 | 65 |
|
39 | 66 | # Add any paths that contain templates here, relative to this directory.
|
|
42 | 69 | # List of patterns, relative to source directory, that match files and
|
43 | 70 | # directories to ignore when looking for source files.
|
44 | 71 | # This pattern also affects html_static_path and html_extra_path.
|
45 |
| -exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"] |
| 72 | +exclude_patterns = [ |
| 73 | + "_build", "Thumbs.db", ".DS_Store", |
| 74 | + 'changelog-fragments.d/**', # Towncrier-managed change notes |
| 75 | +] |
46 | 76 |
|
47 | 77 |
|
48 | 78 | # -- Options for HTML output -------------------------------------------------
|
|
88 | 118 | "substitution",
|
89 | 119 | "tasklist",
|
90 | 120 | ]
|
| 121 | +myst_substitutions = { |
| 122 | + 'project': project, |
| 123 | + 'release': release, |
| 124 | + 'release_l': f'`{release}`', # Needed in draft changelog for spelling ext |
| 125 | + 'version': version, |
| 126 | +} |
91 | 127 | myst_heading_anchors = 2
|
92 | 128 | myst_footnote_transition = True
|
93 | 129 | myst_dmath_double_inline = True
|
|
102 | 138 | }
|
103 | 139 |
|
104 | 140 |
|
| 141 | +# -- Options for towncrier_draft extension ----------------------------------- |
| 142 | + |
| 143 | +towncrier_draft_autoversion_mode = 'draft' # or: 'sphinx-version', 'sphinx-release' |
| 144 | +towncrier_draft_include_empty = True |
| 145 | +towncrier_draft_working_directory = PROJECT_ROOT_DIR |
| 146 | +# Not yet supported: towncrier_draft_config_path = 'pyproject.toml' # relative to cwd |
| 147 | + |
| 148 | + |
105 | 149 | def run_apidoc(app):
|
106 | 150 | """generate apidoc
|
107 | 151 |
|
@@ -137,6 +181,16 @@ def run_apidoc(app):
|
137 | 181 | os.remove(os.path.join(api_folder, "modules.rst"))
|
138 | 182 |
|
139 | 183 |
|
| 184 | +# -- Options for extlinks extension ------------------------------------------ |
| 185 | + |
| 186 | +extlinks = { |
| 187 | + 'issue': (f'{github_repo_url}/issues/%s', '#'), # noqa: WPS323 |
| 188 | + 'pr': (f'{github_repo_url}/pull/%s', 'PR #'), # noqa: WPS323 |
| 189 | + 'commit': (f'{github_repo_url}/commit/%s', ''), # noqa: WPS323 |
| 190 | + 'gh': (f'{github_url}/%s', 'GitHub: '), # noqa: WPS323 |
| 191 | + 'user': (f'{github_sponsors_url}/%s', '@'), # noqa: WPS323 |
| 192 | +} |
| 193 | + |
140 | 194 | intersphinx_mapping = {
|
141 | 195 | "python": ("https://docs.python.org/3.7", None),
|
142 | 196 | "sphinx": ("https://www.sphinx-doc.org/en/master", None),
|
|
0 commit comments