|
5 | 5 | # https://www.sphinx-doc.org/en/master/usage/configuration.html
|
6 | 6 |
|
7 | 7 | from datetime import date
|
| 8 | +from functools import partial |
| 9 | +from pathlib import Path |
8 | 10 |
|
| 11 | +from setuptools_scm import get_version |
9 | 12 | from sphinx.application import Sphinx
|
10 | 13 |
|
11 |
| -from myst_parser import __version__ |
| 14 | +# -- Path setup -------------------------------------------------------------- |
12 | 15 |
|
| 16 | +PROJECT_ROOT_DIR = Path(__file__).parents[1].resolve() # pylint: disable=no-member |
| 17 | +get_scm_version = partial(get_version, root=PROJECT_ROOT_DIR) |
13 | 18 | # -- Project information -----------------------------------------------------
|
14 | 19 |
|
| 20 | +github_url = "https://github.com" |
| 21 | +github_repo_org = "ansible" |
| 22 | +github_repo_name = "ansible-language-server" |
| 23 | +github_repo_slug = f"{github_repo_org}/{github_repo_name}" |
| 24 | +github_repo_url = f"{github_url}/{github_repo_slug}" |
| 25 | +github_sponsors_url = f"{github_url}/sponsors" |
| 26 | + |
15 | 27 | project = "MyST Parser"
|
16 | 28 | copyright = f"{date.today().year}, Executable Book Project"
|
17 | 29 | author = "Executable Book Project"
|
18 |
| -version = __version__ |
| 30 | + |
| 31 | +# The short X.Y version |
| 32 | +version = ".".join( |
| 33 | + get_scm_version(local_scheme="no-local-version",).split( |
| 34 | + "." |
| 35 | + )[:3], |
| 36 | +) |
| 37 | + |
| 38 | +# The full version, including alpha/beta/rc tags |
| 39 | +release = get_scm_version() |
| 40 | + |
19 | 41 |
|
20 | 42 | master_doc = "index"
|
21 | 43 | language = "en"
|
|
28 | 50 | extensions = [
|
29 | 51 | "myst_parser",
|
30 | 52 | "sphinx.ext.autodoc",
|
| 53 | + "sphinx.ext.extlinks", |
31 | 54 | "sphinx.ext.intersphinx",
|
32 | 55 | "sphinx.ext.viewcode",
|
33 | 56 | "sphinx_design",
|
34 | 57 | "sphinxext.rediraffe",
|
35 | 58 | "sphinxcontrib.mermaid",
|
36 | 59 | "sphinxext.opengraph",
|
| 60 | + "sphinxcontrib.towncrier", # provides `towncrier-draft-entries` directive |
37 | 61 | ]
|
38 | 62 |
|
39 | 63 | # Add any paths that contain templates here, relative to this directory.
|
|
42 | 66 | # List of patterns, relative to source directory, that match files and
|
43 | 67 | # directories to ignore when looking for source files.
|
44 | 68 | # This pattern also affects html_static_path and html_extra_path.
|
45 |
| -exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"] |
| 69 | +exclude_patterns = [ |
| 70 | + "_build", |
| 71 | + "Thumbs.db", |
| 72 | + ".DS_Store", |
| 73 | + "changelog-fragments.d/**", # Towncrier-managed change notes |
| 74 | +] |
46 | 75 |
|
47 | 76 |
|
48 | 77 | # -- Options for HTML output -------------------------------------------------
|
|
93 | 122 | "attrs_image",
|
94 | 123 | ]
|
95 | 124 | myst_number_code_blocks = ["typescript"]
|
| 125 | +myst_substitutions = { |
| 126 | + "project": project, |
| 127 | + "release": release, |
| 128 | + "release_l": f"`{release}`", # Needed in draft changelog for spelling ext |
| 129 | + "version": version, |
| 130 | +} |
96 | 131 | myst_heading_anchors = 2
|
97 | 132 | myst_footnote_transition = True
|
98 | 133 | myst_dmath_double_inline = True
|
|
114 | 149 |
|
115 | 150 | suppress_warnings = ["myst.strikethrough"]
|
116 | 151 |
|
| 152 | +# -- Options for towncrier_draft extension ----------------------------------- |
| 153 | + |
| 154 | +towncrier_draft_autoversion_mode = "draft" # or: 'sphinx-version', 'sphinx-release' |
| 155 | +towncrier_draft_include_empty = True |
| 156 | +towncrier_draft_working_directory = PROJECT_ROOT_DIR |
| 157 | +# towncrier_draft_config_path = 'pyproject.toml' # relative to cwd |
| 158 | + |
| 159 | +# -- Options for extlinks extension ------------------------------------------ |
| 160 | + |
| 161 | +extlinks = { |
| 162 | + "issue": (f"{github_repo_url}/issues/%s", "#%s"), # noqa: WPS323 |
| 163 | + "pr": (f"{github_repo_url}/pull/%s", "PR #%s"), # noqa: WPS323 |
| 164 | + "commit": (f"{github_repo_url}/commit/%s", "%s"), # noqa: WPS323 |
| 165 | + "gh": (f"{github_url}/%s", "GitHub: %s"), # noqa: WPS323 |
| 166 | + "user": (f"{github_sponsors_url}/%s", "@%s"), # noqa: WPS323 |
| 167 | +} |
117 | 168 |
|
118 | 169 | intersphinx_mapping = {
|
119 | 170 | "python": ("https://docs.python.org/3.7", None),
|
|
0 commit comments