|
18 | 18 | from importlib.metadata import version
|
19 | 19 | from pathlib import Path
|
20 | 20 |
|
| 21 | +# Attempt to import the version dynamically from GitHub tag. |
| 22 | +try: |
| 23 | + fullversion = version("diffpy.utils") |
| 24 | +except Exception: |
| 25 | + fullversion = "No version found. The correct version will appear in the released version." # noqa: E501 |
| 26 | + |
21 | 27 | # If extensions (or modules to document with autodoc) are in another directory,
|
22 | 28 | # add these directories to sys.path here. If the directory is relative to the
|
23 | 29 | # documentation root, use Path().resolve() to make it absolute, like shown here.
|
|
43 | 49 | "sphinx.ext.viewcode",
|
44 | 50 | "sphinx.ext.intersphinx",
|
45 | 51 | "sphinx_rtd_theme",
|
| 52 | + "sphinx_copybutton", |
46 | 53 | "m2r",
|
47 | 54 | ]
|
48 | 55 |
|
|
88 | 95 | # substitute YEAR in the copyright string
|
89 | 96 | copyright = copyright.replace("%Y", year)
|
90 | 97 |
|
| 98 | +# For sphinx_copybutton extension. |
| 99 | +# Do not copy "$" for shell commands in code-blocks. |
| 100 | +copybutton_prompt_text = r"^\$ " |
| 101 | +copybutton_prompt_is_regexp = True |
| 102 | + |
91 | 103 | # List of patterns, relative to source directory, that match files and
|
92 | 104 | # directories to ignore when looking for source files.
|
93 | 105 | exclude_patterns = ["build"]
|
|
123 | 135 | #
|
124 | 136 | html_theme = "sphinx_rtd_theme"
|
125 | 137 |
|
| 138 | +html_context = { |
| 139 | + "display_github": True, |
| 140 | + "github_user": "diffpy", |
| 141 | + "github_repo": "diffpy.utils", |
| 142 | + "github_version": "main", |
| 143 | + "conf_py_path": "/doc/source/", |
| 144 | +} |
| 145 | + |
126 | 146 | # Theme options are theme-specific and customize the look and feel of a theme
|
127 | 147 | # further. For a list of options available for each theme, see the
|
128 | 148 | # documentation.
|
|
256 | 276 | # One entry per manual page. List of tuples
|
257 | 277 | # (source start file, name, description, authors, manual section).
|
258 | 278 | man_pages = [
|
259 |
| - ("index", "diffpy.utils", "diffpy.utils Documentation", ab_authors, 1) |
| 279 | + ( |
| 280 | + "index", |
| 281 | + "diffpy.utils", |
| 282 | + "diffpy.utils Documentation", |
| 283 | + ab_authors, |
| 284 | + 1, |
| 285 | + ) |
260 | 286 | ]
|
261 | 287 |
|
262 | 288 | # If true, show URL addresses after external links.
|
|
0 commit comments