|
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.pdffit2") |
| 24 | +except Exception: |
| 25 | + fullversion = "No version found. The correct version will appear in the released version." |
| 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. |
|
26 | 32 | sys.path.insert(0, str(Path("../../src").resolve())) |
27 | 33 |
|
28 | 34 | # abbreviations |
29 | | -ab_authors = "Billinge Group members and community contributors" |
| 35 | +ab_authors = "Billinge group and community members." |
30 | 36 |
|
31 | 37 | # -- General configuration ------------------------------------------------ |
32 | 38 |
|
|
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.pdffit2", |
| 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. |
|
221 | 241 | # (source start file, target name, title, |
222 | 242 | # author, documentclass [howto, manual, or own class]). |
223 | 243 | latex_documents = [ |
224 | | - ("index", "diffpy.pdffit2.tex", "diffpy.pdffit2 Documentation", ab_authors, "manual"), |
| 244 | + ( |
| 245 | + "index", |
| 246 | + "diffpy.pdffit2.tex", |
| 247 | + "diffpy.pdffit2 Documentation", |
| 248 | + ab_authors, |
| 249 | + "manual", |
| 250 | + ), |
225 | 251 | ] |
226 | 252 |
|
227 | 253 | # The name of an image file (relative to this directory) to place at the top of |
|
249 | 275 |
|
250 | 276 | # One entry per manual page. List of tuples |
251 | 277 | # (source start file, name, description, authors, manual section). |
252 | | -man_pages = [("index", "diffpy.pdffit2", "diffpy.pdffit2 Documentation", ab_authors, 1)] |
| 278 | +man_pages = [ |
| 279 | + ( |
| 280 | + "index", |
| 281 | + "diffpy.pdffit2", |
| 282 | + "diffpy.pdffit2 Documentation", |
| 283 | + ab_authors, |
| 284 | + 1, |
| 285 | + ) |
| 286 | +] |
253 | 287 |
|
254 | 288 | # If true, show URL addresses after external links. |
255 | 289 | # man_show_urls = False |
|
0 commit comments