8000 DOC: allow np as a module for documentation · numpy/numpy@259ac3f · GitHub
[go: up one dir, main page]

Skip to content

Commit 259ac3f

Browse files
committed
DOC: allow np as a module for documentation
1 parent 16f19fc commit 259ac3f

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

doc/source/conf.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,21 @@
4141
project = 'NumPy'
4242
copyright = '2008-2018, The SciPy community'
4343

44+
import numpy
45+
46+
# Allow the shortcut `np.dtype`.
47+
# May fail if the shortcut needs to newly import.
48+
aliases = {}
49+
for name, module in sys.modules.items():
50+
parts = name.split('.', 1)
51+
if parts[0] == 'numpy':
52+
parts[0] = 'np'
53+
aliases[name] = module
54+
sys.modules.update(aliases)
55+
4456
# The default replacements for |version| and |release|, also used in various
4557
# other places throughout the built documents.
46-
#
47-
import numpy
58+
4859
# The short X.Y version (including .devXXXX, rcX, b1 suffixes if present)
4960
version = re.sub(r'(\d+\.\d+)\.\d+(.*)', r'\1\2', numpy.__version__)
5061
version = re.sub(r'(\.dev\d+).*?$', r'\1', version)

0 commit comments

Comments
 (0)
0