Skip to content

Commit 162139f

Browse files
authored
Sphinx 9 compatibility
* LinearPhaseFunc parameters need default values. * Use a substitutions file for docs so that astropy docstrings can be used
1 parent 843b1a2 commit 162139f

3 files changed

Lines changed: 86 additions & 48 deletions

File tree

docs/conf.py

Lines changed: 50 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -30,26 +30,30 @@
3030
import sys
3131

3232
import matplotlib
33-
matplotlib.use('agg')
33+
34+
matplotlib.use("agg")
3435

3536
try:
3637
from sphinx_astropy.conf.v1 import *
3738
except ImportError:
38-
print('ERROR: the documentation requires the sphinx-astropy package to be'
39-
' installed')
39+
print(
40+
"ERROR: the documentation requires the sphinx-astropy package to be"
41+
" installed"
42+
)
4043
sys.exit(1)
4144

4245
# Get configuration information from setup.cfg
4346
from configparser import ConfigParser # noqa: E402
47+
4448
conf = ConfigParser()
4549

46-
conf.read([os.path.join(os.path.dirname(__file__), '..', 'setup.cfg')])
47-
setup_cfg = dict(conf.items('metadata'))
50+
conf.read([os.path.join(os.path.dirname(__file__), "..", "setup.cfg")])
51+
setup_cfg = dict(conf.items("metadata"))
4852

4953
# -- General configuration ----------------------------------------------------
5054

5155
# By default, highlight as Python 3.
52-
highlight_language = 'python3'
56+
highlight_language = "python3"
5357

5458
# If your documentation needs a minimal Sphinx version, state it here.
5559
# needs_sphinx = '1.2'
@@ -60,16 +64,18 @@
6064

6165
# List of patterns, relative to source directory, that match files and
6266
# directories to ignore when looking for source files.
63-
exclude_patterns.append('_templates')
67+
exclude_patterns.append("_templates")
6468

6569
# This is added to the end of RST files - a good place to put substitutions to
6670
# be used globally.
67-
rst_epilog += """
68-
"""
71+
with open("substitutions.txt") as inf:
72+
rst_epilog += inf.read()
6973

70-
extensions += ['sphinx.ext.intersphinx',
71-
'sphinx_automodapi.smart_resolver',
72-
'sphinx.ext.autosectionlabel']
74+
extensions += [
75+
"sphinx.ext.intersphinx",
76+
"sphinx_automodapi.smart_resolver",
77+
"sphinx.ext.autosectionlabel",
78+
]
7379

7480
# For example, index:Introduction for a section called Introduction that
7581
# appears in document index.rst.
@@ -83,20 +89,19 @@
8389
# -- Project information ------------------------------------------------------
8490

8591
# This does not *have* to match the package name, but typically does
86-
project = setup_cfg['package_name']
87-
author = setup_cfg['author']
88-
copyright = '{0}, {1}'.format(
89-
datetime.datetime.now().year, setup_cfg['author'])
92+
project = setup_cfg["package_name"]
93+
author = setup_cfg["author"]
94+
copyright = "{0}, {1}".format(datetime.datetime.now().year, setup_cfg["author"])
9095

9196
# The version info for the project you're documenting, acts as replacement for
9297
# |version| and |release|, also used in various other places throughout the
9398
# built documents.
9499

95-
__import__(setup_cfg['package_name'])
96-
package = sys.modules[setup_cfg['package_name']]
100+
__import__(setup_cfg["package_name"])
101+
package = sys.modules[setup_cfg["package_name"]]
97102

98103
# The short X.Y version.
99-
version = package.__version__.split('-', 1)[0]
104+
version = package.__version__.split("-", 1)[0]
100105
# The full version, including alpha/beta/rc tags.
101106
release = package.__version__
102107

@@ -113,68 +118,68 @@
113118

114119
# Add any paths that contain custom themes here, relative to this directory.
115120
# To use a different custom theme, add the directory containing the theme.
116-
#html_theme_path = []
121+
# html_theme_path = []
117122

118123
# The theme to use for HTML and HTML Help pages. See the documentation for
119124
# a list of builtin themes. To override the custom theme, set this to the
120125
# name of a builtin theme or the name of a custom theme in html_theme_path.
121-
#html_theme = 'sphinx_rtd_theme'
126+
# html_theme = 'sphinx_rtd_theme'
122127

123128
# Please update these texts to match the name of your package.
124129
html_theme_options = {
125-
'logotext1': 'sb', # white, semi-bold
126-
'logotext2': 'py', # orange, light
127-
'logotext3': ':docs' # white, light
130+
"logotext1": "sb", # white, semi-bold
131+
"logotext2": "py", # orange, light
132+
"logotext3": ":docs", # white, light
128133
}
129134

130135

131136
# Custom sidebar templates, maps document names to template names.
132-
#html_sidebars = {}
137+
# html_sidebars = {}
133138

134139
# The name of an image file (relative to this directory) to place at the top
135140
# of the sidebar.
136-
#html_logo = ''
141+
# html_logo = ''
137142

138143
# The name of an image file (within the static path) to use as favicon of the
139144
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
140145
# pixels large.
141-
#html_favicon = ''
146+
# html_favicon = ''
142147

143148
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
144149
# using the given strftime format.
145-
#html_last_updated_fmt = ''
150+
# html_last_updated_fmt = ''
146151

147152
# The name for this set of Sphinx documents. If None, it defaults to
148153
# "<project> v<release> documentation".
149-
html_title = '{0} v{1}'.format(project, release)
154+
html_title = "{0} v{1}".format(project, release)
150155

151156
# Output file base name for HTML help builder.
152-
htmlhelp_basename = project + 'doc'
157+
htmlhelp_basename = project + "doc"
153158

154159

155160
# -- Options for LaTeX output -------------------------------------------------
156161

157162
# Grouping the document tree into LaTeX files. List of tuples
158163
# (source start file, target name, title, author, documentclass [howto/manual]).
159-
latex_documents = [('index', project + '.tex', project + u' Documentation',
160-
author, 'manual')]
164+
latex_documents = [
165+
("index", project + ".tex", project + " Documentation", author, "manual")
166+
]
161167

162168

163169
# -- Options for manual page output -------------------------------------------
164170

165171
# One entry per manual page. List of tuples
166172
# (source start file, name, description, authors, manual section).
167-
man_pages = [('index', project.lower(), project + u' Documentation',
168-
[author], 1)]
173+
man_pages = [("index", project.lower(), project + " Documentation", [author], 1)]
169174

170175

171176
# -- Options for the edit_on_github extension ---------------------------------
172177

173-
if eval(setup_cfg.get('edit_on_github')):
174-
extensions += ['sphinx_astropy.ext.edit_on_github']
178+
if eval(setup_cfg.get("edit_on_github")):
179+
extensions += ["sphinx_astropy.ext.edit_on_github"]
175180

176-
versionmod = __import__(setup_cfg['package_name'] + '.version')
177-
edit_on_github_project = setup_cfg['github_project']
181+
versionmod = __import__(setup_cfg["package_name"] + ".version")
182+
edit_on_github_project = setup_cfg["github_project"]
178183
if versionmod.version.release:
179184
edit_on_github_branch = "v" + versionmod.version.version
180185
else:
@@ -184,18 +189,17 @@
184189
edit_on_github_doc_root = "docs"
185190

186191
# -- Resolving issue number to links in changelog -----------------------------
187-
github_issues_url = 'https://github.com/{0}/issues/'.format(
188-
setup_cfg['github_project'])
192+
github_issues_url = "https://github.com/{0}/issues/".format(setup_cfg["github_project"])
189193

190194
# -- compile list of field names
191195
# import compile_fieldnames
192196

193197
# --- intersphinx setup
194-
intersphinx_mapping['astroquery'] = (
195-
'https://astroquery.readthedocs.io/en/stable/', None)
198+
intersphinx_mapping["astroquery"] = (
199+
"https://astroquery.readthedocs.io/en/stable/",
200+
None,
201+
)
196202

197-
intersphinx_mapping['synphot'] = (
198-
'https://synphot.readthedocs.io/en/stable/', None)
203+
intersphinx_mapping["synphot"] = ("https://synphot.readthedocs.io/en/stable/", None)
199204

200-
intersphinx_mapping['astropy'] = (
201-
'https://docs.astropy.org/en/stable/', None)
205+
intersphinx_mapping["astropy"] = ("https://docs.astropy.org/en/stable/", None)

docs/substitutions.txt

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
.. ReST substitutions and links for the docs and docstrings.
2+
3+
.. This file is included in the conf.py rst_epilog variable.
4+
5+
.. Keep common items aligned with the astropy substitutions
6+
.. (astropy/docs/common_links.rst) to avoid issues with inheriting
7+
.. substitutions from astropy classes
8+
9+
.. NumPy
10+
.. |ndarray| replace:: :class:`numpy.ndarray`
11+
12+
.. Astropy
13+
.. Coordinates
14+
.. |Angle| replace:: `~astropy.coordinates.Angle`
15+
.. |Latitude| replace:: `~astropy.coordinates.Latitude`
16+
.. |Longitude| replace:: :class:`~astropy.coordinates.Longitude`
17+
.. |BaseFrame| replace:: `~astropy.coordinates.BaseCoordinateFrame`
18+
.. |SkyCoord| replace:: :class:`~astropy.coordinates.SkyCoord`
19+
20+
.. Table
21+
.. |Column| replace:: :class:`~astropy.table.Column`
22+
.. |MaskedColumn| replace:: :class:`~astropy.table.MaskedColumn`
23+
.. |TableColumns| replace:: :class:`~astropy.table.TableColumns`
24+
.. |Row| replace:: :class:`~astropy.table.Row`
25+
.. |Table| replace:: :class:`~astropy.table.Table`
26+
.. |QTable| replace:: :class:`~astropy.table.QTable`
27+
28+
.. Time
29+
.. |Time| replace:: :class:`~astropy.time.Time`
30+
31+
.. Units
32+
.. |PhysicalType| replace:: :class:`~astropy.units.PhysicalType`
33+
.. |Quantity| replace:: :class:`~astropy.units.Quantity`
34+
.. |Unit| replace:: :class:`~astropy.units.UnitBase`

sbpy/photometry/core.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -728,8 +728,8 @@ class LinearPhaseFunc(DiskIntegratedPhaseFunc):
728728
"""
729729

730730
_unit = 'mag'
731-
H = Parameter(description='Absolute magnitude')
732-
S = Parameter(description='Linear slope (mag/deg)')
731+
H = Parameter(description='Absolute magnitude', default=5 * u.mag)
732+
S = Parameter(description='Linear slope (mag/deg)', default=0.04 * u.mag / u.deg)
733733
input_units = {'x': u.deg}
734734

735735
@staticmethod

0 commit comments

Comments
 (0)