Skip to content

Commit

Permalink
astropy version protect
Browse files Browse the repository at this point in the history
Signed-off-by: Nathaniel Starkman (@nstarman) <[email protected]>
  • Loading branch information
nstarman committed May 1, 2021
1 parent 711417f commit a0b5de7
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions sphinx_astropy/conf/v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

from os import path

import astropy
import sphinx
from distutils.version import LooseVersion

Expand Down Expand Up @@ -110,17 +111,19 @@ def check_sphinx_version(expected_version):
# https://github.com/numpy/numpydoc/blob/b352cd7635f2ea7748722f410a31f937d92545cc/numpydoc/xref.py#L62-L94
# numpydoc_xref_aliases = {}

# TODO! refactor if #11678 is implemented
from astropy.units.physical import _units_and_physical_types
numpydoc_xref_aliases_astropy_physical_type = {}
for _, ptypes in _units_and_physical_types:
ptypes = {ptypes} if isinstance(ptypes, str) else ptypes
for ptype in ptypes:
key = f"'{ptype}'"
val = f":ref:`:ref: '{ptype}' <astropy:{ptype}>`" # <= intersphinxed.
numpydoc_xref_aliases_astropy_physical_type[key] = val

del ptypes, key, val
if float(astropy.__version__[:3] >= 4.3:

# TODO! refactor if #11678 is implemented
from astropy.units.physical import _units_and_physical_types
for _, ptypes in _units_and_physical_types:
ptypes = {ptypes} if isinstance(ptypes, str) else ptypes
for ptype in ptypes:
key = f"'{ptype}'"
val = f":ref:`:ref: '{ptype}' <astropy:{ptype}>`" # <= intersphinxed.
numpydoc_xref_aliases_astropy_physical_type[key] = val

del ptypes, key, val

# -- Project information ------------------------------------------------------

Expand Down

0 comments on commit a0b5de7

Please sign in to comment.