|
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.labpdfproc") |
| 24 | +except Exception: |
| 25 | + fullversion = ( |
| 26 | + "No version found. " |
| 27 | + "The correct version will appear in the released version." |
| 28 | + ) |
| 29 | + |
21 | 30 | # If extensions (or modules to document with autodoc) are in another directory, |
22 | 31 | # add these directories to sys.path here. If the directory is relative to the |
23 | 32 | # documentation root, use Path().resolve() to make it absolute, like shown here |
|
26 | 35 | sys.path.insert(0, str(Path("../../src").resolve())) |
27 | 36 |
|
28 | 37 | # abbreviations |
29 | | -ab_authors = "Billinge Group members and community contributors" |
| 38 | +ab_authors = ( |
| 39 | + "Yucong Chen, Till Schertenleib, Caden Myers, Billinge Group members" |
| 40 | +) |
30 | 41 |
|
31 | 42 | # -- General configuration ------------------------------------------------ |
32 | 43 |
|
|
43 | 54 | "sphinx.ext.viewcode", |
44 | 55 | "sphinx.ext.intersphinx", |
45 | 56 | "sphinx_rtd_theme", |
46 | | - "m2r", |
| 57 | + "sphinx_copybutton", |
| 58 | + "m2r2", |
47 | 59 | ] |
48 | 60 |
|
49 | 61 | # Add any paths that contain templates here, relative to this directory. |
|
68 | 80 | # |version| and |release|, also used in various other places throughout the |
69 | 81 | # built documents. |
70 | 82 |
|
71 | | -fullversion = version(project) |
72 | 83 | # The short X.Y version. |
73 | 84 | version = "".join(fullversion.split(".post")[:1]) |
74 | 85 | # The full version, including alpha/beta/rc tags. |
|
88 | 99 | # substitute YEAR in the copyright string |
89 | 100 | copyright = copyright.replace("%Y", year) |
90 | 101 |
|
| 102 | +# For sphinx_copybutton extension. |
| 103 | +# Do not copy "$" for shell commands in code-blocks. |
| 104 | +copybutton_prompt_text = r"^\$ " |
| 105 | +copybutton_prompt_is_regexp = True |
| 106 | + |
91 | 107 | # List of patterns, relative to source directory, that match files and |
92 | 108 | # directories to ignore when looking for source files. |
93 | 109 | exclude_patterns = ["build"] |
|
123 | 139 | # |
124 | 140 | html_theme = "sphinx_rtd_theme" |
125 | 141 |
|
| 142 | +html_context = { |
| 143 | + "display_github": True, |
| 144 | + "github_user": "diffpy", |
| 145 | + "github_repo": "diffpy.labpdfproc", |
| 146 | + "github_version": "main", |
| 147 | + "conf_py_path": "/docs/source/", |
| 148 | +} |
| 149 | + |
126 | 150 | # Theme options are theme-specific and customize the look and feel of a theme |
127 | 151 | # further. For a list of options available for each theme, see the |
128 | 152 | # documentation. |
|
0 commit comments