|
28 | 28 | import datetime
|
29 | 29 | import os
|
30 | 30 | import sys
|
| 31 | +from pathlib import Path |
31 | 32 |
|
| 33 | +import tomllib |
32 | 34 | from pkg_resources import get_distribution
|
33 | 35 |
|
34 | 36 | try:
|
|
39 | 41 | )
|
40 | 42 | sys.exit(1)
|
41 | 43 |
|
42 |
| -# Get configuration information from setup.cfg |
43 |
| -from configparser import ConfigParser |
44 |
| - |
45 |
| -conf = ConfigParser() |
46 |
| -conf.read([os.path.join(os.path.dirname(__file__), "..", "setup.cfg")]) |
47 |
| -setup_cfg = dict(conf.items("metadata")) |
| 44 | +# Grab minversion from pyproject.toml |
| 45 | +with (Path(__file__).parents[1] / "pyproject.toml").open("rb") as f: |
| 46 | + pyproject = tomllib.load(f) |
48 | 47 |
|
49 | 48 | # -- General configuration ----------------------------------------------------
|
50 | 49 |
|
|
54 | 53 | # If your documentation needs a minimal Sphinx version, state it here.
|
55 | 54 | needs_sphinx = "1.3"
|
56 | 55 |
|
57 |
| - |
58 | 56 | intersphinx_mapping["emcee"] = (
|
59 | 57 | "https://emcee.readthedocs.io/en/stable/",
|
60 | 58 | None,
|
|
73 | 71 | # -- Project information ------------------------------------------------------
|
74 | 72 |
|
75 | 73 | # This does not *have* to match the package name, but typically does
|
76 |
| -project = setup_cfg["name"] |
77 |
| -author = setup_cfg["author"] |
78 |
| -copyright = "{0}, {1}".format(datetime.datetime.now().year, setup_cfg["author"]) |
| 74 | +project = pyproject["project"]["name"] |
| 75 | +author = pyproject["project"]["authors"][0]["name"] |
| 76 | +copyright = "{0}, {1}".format(datetime.datetime.now().year, author) |
79 | 77 |
|
80 | 78 | # The version info for the project you're documenting, acts as replacement for
|
81 | 79 | # |version| and |release|, also used in various other places throughout the
|
82 | 80 | # built documents.
|
83 | 81 |
|
84 |
| -package_version = get_distribution(setup_cfg["name"]).version |
| 82 | +package_version = get_distribution(project).version |
85 | 83 |
|
86 | 84 | # The short X.Y version.
|
87 | 85 | version = package_version.split("-", 1)[0]
|
|
91 | 89 |
|
92 | 90 | # -- Options for HTML output ---------------------------------------------------
|
93 | 91 |
|
94 |
| -# A NOTE ON HTML THEMES |
95 |
| -# The global astropy configuration uses a custom theme, 'bootstrap-astropy', |
96 |
| -# which is installed along with astropy. A different theme can be used or |
97 |
| -# the options for this theme can be modified by overriding some of the |
98 |
| -# variables set in the global configuration. The variables set in the |
99 |
| -# global configuration are listed below, commented out. |
100 |
| - |
101 | 92 | # Add any paths that contain custom themes here, relative to this directory.
|
102 | 93 | # To use a different custom theme, add the directory containing the theme.
|
103 | 94 | # html_theme_path = []
|
|
160 | 151 | # One entry per manual page. List of tuples
|
161 | 152 | # (source start file, name, description, authors, manual section).
|
162 | 153 | man_pages = [("index", project.lower(), project + " Documentation", [author], 1)]
|
163 |
| - |
164 |
| - |
165 |
| -## -- Options for the edit_on_github extension ---------------------------------------- |
166 |
| - |
167 |
| -if eval(setup_cfg.get("edit_on_github")): |
168 |
| - extensions += ["sphinx_astropy.ext.edit_on_github"] |
169 |
| - |
170 |
| - versionmod = __import__(setup_cfg["name"] + ".version") |
171 |
| - edit_on_github_project = setup_cfg["github_project"] |
172 |
| - if versionmod.version.release: |
173 |
| - edit_on_github_branch = "v" + versionmod.version.version |
174 |
| - else: |
175 |
| - edit_on_github_branch = "master" |
176 |
| - |
177 |
| - edit_on_github_source_root = "" |
178 |
| - edit_on_github_doc_root = "docs" |
0 commit comments