|
1 | 1 | # -*- coding: utf-8 -*- |
2 | | -# Licensed under a 3-clause BSD style license - see LICENSE.rst |
3 | | -# |
4 | | -# Astropy documentation build configuration file. |
5 | | -# |
6 | | -# This file is execfile()d with the current directory set to its containing dir. |
7 | | -# |
8 | | -# Note that not all possible configuration values are present in this file. |
9 | | -# |
10 | | -# All configuration values have a default. Some values are defined in |
11 | | -# the global Astropy configuration which is loaded here before anything else. |
12 | | -# See astropy.sphinx.conf for which values are set there. |
13 | | - |
14 | | -# If extensions (or modules to document with autodoc) are in another directory, |
15 | | -# add these directories to sys.path here. If the directory is relative to the |
16 | | -# documentation root, use os.path.abspath to make it absolute, like shown here. |
17 | | -# sys.path.insert(0, os.path.abspath('..')) |
18 | | -# IMPORTANT: the above commented section was generated by sphinx-quickstart, but |
19 | | -# is *NOT* appropriate for astropy or Astropy affiliated packages. It is left |
20 | | -# commented out with this explanation to make it clear why this should not be |
21 | | -# done. If the sys.path entry above is added, when the astropy.sphinx.conf |
22 | | -# import occurs, it will import the *source* version of astropy instead of the |
23 | | -# version installed (if invoked as "make html" or directly with sphinx), or the |
24 | | -# version in the build directory (if "python setup.py build_sphinx" is used). |
25 | | -# Thus, any C-extensions that are needed to build the documentation will *not* |
26 | | -# be accessible, and the documentation will not build correctly. |
27 | | - |
28 | | -import os |
| 2 | + |
29 | 3 | import sys |
30 | 4 | import datetime |
31 | | -from importlib import import_module |
| 5 | +from importlib.metadata import version as get_version |
| 6 | +from pathlib import Path |
| 7 | + |
32 | 8 |
|
33 | 9 | try: |
34 | 10 | from sphinx_astropy.conf.v1 import * # noqa |
35 | 11 | except ImportError: |
36 | 12 | print('ERROR: the documentation requires the sphinx-astropy package to be installed') |
37 | 13 | sys.exit(1) |
38 | 14 |
|
39 | | -# Get configuration information from setup.cfg |
40 | | -from configparser import ConfigParser |
41 | | -conf = ConfigParser() |
| 15 | +import tomllib |
42 | 16 |
|
43 | | -conf.read([os.path.join(os.path.dirname(__file__), '..', 'setup.cfg')]) |
44 | | -setup_cfg = dict(conf.items('metadata')) |
| 17 | +# Grab minversion from pyproject.toml |
| 18 | +with (Path(__file__).parents[1] / "pyproject.toml").open("rb") as f: |
| 19 | + pyproject = tomllib.load(f) |
| 20 | + |
| 21 | +__minimum_python_version__ = pyproject["project"]["requires-python"].replace(">=", "") |
45 | 22 |
|
46 | 23 | # -- General configuration ---------------------------------------------------- |
47 | 24 |
|
|
76 | 53 | # -- Project information ------------------------------------------------------ |
77 | 54 |
|
78 | 55 | # This does not *have* to match the package name, but typically does |
79 | | -project = setup_cfg['name'] |
80 | | -author = setup_cfg['author'] |
81 | | -copyright = '{0}, {1}'.format( |
82 | | - datetime.datetime.now().year, setup_cfg['author']) |
| 56 | +project = pyproject["project"]["name"] |
| 57 | +author = ", ".join(v["name"] for v in pyproject["project"]["authors"]) |
| 58 | +copyright = f"{datetime.datetime.now().year}, {author}" |
83 | 59 |
|
84 | 60 | # The version info for the project you're documenting, acts as replacement for |
85 | 61 | # |version| and |release|, also used in various other places throughout the |
86 | 62 | # built documents. |
87 | | - |
88 | | -import_module(setup_cfg['name']) |
89 | | -package = sys.modules[setup_cfg['name']] |
90 | | - |
91 | | -# The short X.Y version. |
92 | | -version = package.__version__.split('-', 1)[0] |
93 | | -# The full version, including alpha/beta/rc tags. |
94 | | -release = package.__version__ |
| 63 | +release: str = get_version("marxs") |
| 64 | +# for example take major/minor |
| 65 | +version: str = ".".join(release.split(".")[:2]) |
95 | 66 |
|
96 | 67 |
|
97 | 68 | # -- Options for HTML output -------------------------------------------------- |
|
163 | 134 | man_pages = [('index', project.lower(), project + u' Documentation', |
164 | 135 | [author], 1)] |
165 | 136 |
|
166 | | - |
167 | | -# -- Options for the edit_on_github extension --------------------------------- |
168 | | - |
169 | | -if setup_cfg.get('edit_on_github').lower() == 'true': |
170 | | - |
171 | | - extensions += ['sphinx_astropy.ext.edit_on_github'] |
172 | | - |
173 | | - edit_on_github_project = setup_cfg['github_project'] |
174 | | - edit_on_github_branch = "master" |
175 | | - |
176 | | - edit_on_github_source_root = "" |
177 | | - edit_on_github_doc_root = "docs" |
178 | | - edit_on_github_skip_regex = '_.*|api/.*' |
179 | | - |
180 | 137 | # -- Resolving issue number to links in changelog ----------------------------- |
181 | | -github_issues_url = 'https://github.com/{0}/issues/'.format(setup_cfg['github_project']) |
| 138 | +github_issues_url = pyproject["project"]["urls"]["Issues"] |
182 | 139 |
|
183 | 140 |
|
184 | 141 | # -- Options for linkcheck output ------------------------------------------- |
|
0 commit comments