|
4 | 4 | # list see the documentation:
|
5 | 5 | # https://www.sphinx-doc.org/en/master/usage/configuration.html
|
6 | 6 |
|
| 7 | +from pathlib import Path |
| 8 | + |
7 | 9 | from sphinx.application import Sphinx
|
8 | 10 | from sphinx.util.docutils import SphinxDirective
|
9 | 11 |
|
10 | 12 | from myst_parser import __version__
|
11 | 13 |
|
| 14 | + |
| 15 | +# -- Path setup -------------------------------------------------------------- |
| 16 | + |
| 17 | +PROJECT_ROOT_DIR = Path(__file__).parents[1].resolve() # pylint: disable=no-member |
12 | 18 | # -- Project information -----------------------------------------------------
|
13 | 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 | + |
14 | 27 | project = "MyST Parser"
|
15 | 28 | copyright = "2020, Executable Book Project"
|
16 | 29 | author = "Executable Book Project"
|
17 | 30 | version = __version__
|
| 31 | +release = version # FIXME: generate full version w/ setuptools-scm |
18 | 32 |
|
19 | 33 | master_doc = "index"
|
20 | 34 | language = "en"
|
|
27 | 41 | extensions = [
|
28 | 42 | "myst_parser",
|
29 | 43 | "sphinx.ext.autodoc",
|
| 44 | + 'sphinx.ext.extlinks', |
30 | 45 | "sphinx.ext.intersphinx",
|
31 | 46 | "sphinx.ext.viewcode",
|
32 | 47 | "sphinxcontrib.bibtex",
|
33 | 48 | "sphinx_panels",
|
34 | 49 | "sphinxext.rediraffe",
|
35 | 50 | "sphinxcontrib.mermaid",
|
36 | 51 | "sphinxext.opengraph",
|
| 52 | + 'sphinxcontrib.towncrier', # provides `towncrier-draft-entries` directive |
37 | 53 | ]
|
38 | 54 |
|
39 | 55 | # Add any paths that contain templates here, relative to this directory.
|
|
42 | 58 | # List of patterns, relative to source directory, that match files and
|
43 | 59 | # directories to ignore when looking for source files.
|
44 | 60 | # This pattern also affects html_static_path and html_extra_path.
|
45 |
| -exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"] |
| 61 | +exclude_patterns = [ |
| 62 | + "_build", "Thumbs.db", ".DS_Store", |
| 63 | + 'changelog-fragments.d/**', # Towncrier-managed change notes |
| 64 | +] |
46 | 65 |
|
47 | 66 |
|
48 | 67 | # -- Options for HTML output -------------------------------------------------
|
|
88 | 107 | "substitution",
|
89 | 108 | "tasklist",
|
90 | 109 | ]
|
| 110 | +myst_substitutions = { |
| 111 | + 'project': project, |
| 112 | + 'release': release, |
| 113 | + 'release_l': f'`{release}`', # Needed in draft changelog for spelling ext |
| 114 | + 'version': version, |
| 115 | +} |
91 | 116 | myst_heading_anchors = 2
|
92 | 117 | myst_footnote_transition = True
|
93 | 118 | myst_dmath_double_inline = True
|
|
102 | 127 | }
|
103 | 128 |
|
104 | 129 |
|
| 130 | +# -- Options for towncrier_draft extension ----------------------------------- |
| 131 | + |
| 132 | +towncrier_draft_autoversion_mode = 'draft' # or: 'sphinx-version', 'sphinx-release' |
| 133 | +towncrier_draft_include_empty = True |
| 134 | +towncrier_draft_working_directory = PROJECT_ROOT_DIR |
| 135 | +# Not yet supported: towncrier_draft_config_path = 'pyproject.toml' # relative to cwd |
| 136 | + |
| 137 | + |
105 | 138 | def run_apidoc(app):
|
106 | 139 | """generate apidoc
|
107 | 140 |
|
@@ -137,6 +170,16 @@ def run_apidoc(app):
|
137 | 170 | os.remove(os.path.join(api_folder, "modules.rst"))
|
138 | 171 |
|
139 | 172 |
|
| 173 | +# -- Options for extlinks extension ------------------------------------------ |
| 174 | + |
| 175 | +extlinks = { |
| 176 | + 'issue': (f'{github_repo_url}/issues/%s', '#'), # noqa: WPS323 |
| 177 | + 'pr': (f'{github_repo_url}/pull/%s', 'PR #'), # noqa: WPS323 |
| 178 | + 'commit': (f'{github_repo_url}/commit/%s', ''), # noqa: WPS323 |
| 179 | + 'gh': (f'{github_url}/%s', 'GitHub: '), # noqa: WPS323 |
| 180 | + 'user': (f'{github_sponsors_url}/%s', '@'), # noqa: WPS323 |
| 181 | +} |
| 182 | + |
140 | 183 | intersphinx_mapping = {
|
141 | 184 | "python": ("https://docs.python.org/3.7", None),
|
142 | 185 | "sphinx": ("https://www.sphinx-doc.org/en/master", None),
|
|
0 commit comments