8000 DOC: allow np as a module for documentation by mattip · Pull Request #11344 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

DOC: allow np as a module for documentation #11344

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,21 @@
project = 'NumPy'
copyright = '2008-2018, The SciPy community'

import numpy

# Allow the shortcut `np.dtype`.
# May fail if the shortcut needs to newly import.
aliases = {}
for name, module in sys.modules.items():
parts = name.split('.', 1)
if parts[0] == 'numpy':
parts[0] = 'np'
aliases[name] = module
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I missed a line, sorry: name = '.'.join(parts)

sys.modules.update(aliases)

# The default replacements for |version| and |release|, also used in various
# other places throughout the built documents.
#
import numpy

# The short X.Y version (including .devXXXX, rcX, b1 suffixes if present)
version = re.sub(r'(\d+\.\d+)\.\d+(.*)', r'\1\2', numpy.__version__)
version = re.sub(r'(\.dev\d+).*?$', r'\1', version)
Expand Down
0