Skip to content

MNT Drop Python 2.7 and 3.4 support #236

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

Merged
merged 1 commit into from
Oct 23, 2019
Merged
Show file tree
Hide file tree
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
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ sudo: false
matrix:
include:
- python: 3.7
- python: 3.6
env: SPHINX_SPEC="==2.1.0" SPHINXOPTS=""
- python: 3.5
env: SPHINX_SPEC="==1.6.5" SPHINXOPTS=""
- python: 3.7
- python: 2.7
cache:
directories:
- $HOME/.cache/pip
Expand Down
2 changes: 2 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ docstrings formatted according to the NumPy documentation format.
The extension also adds the code description directives
``np:function``, ``np-c:function``, etc.

numpydoc requires Python 3.5+ and sphinx 1.6.5+.

For usage information, please refer to the `documentation
<https://numpydoc.readthedocs.io/>`_.

Expand Down
2 changes: 1 addition & 1 deletion doc/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Installation
============

The extension is available from:
This extension requires Python 3.5+, sphinx 1.6.5+ and is available from:

* `numpydoc on PyPI <http://pypi.python.org/pypi/numpydoc>`_
* `numpydoc on GitHub <https://github.com/numpy/numpydoc/>`_
Expand Down
2 changes: 0 additions & 2 deletions numpydoc/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import division, absolute_import, print_function

__version__ = '1.0.0.dev0'


Expand Down
7 changes: 1 addition & 6 deletions numpydoc/docscrape.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
"""Extract reference documentation from the NumPy source tree.

"""
from __future__ import division, absolute_import, print_function

import inspect
import textwrap
import re
import pydoc
from warnings import warn
from collections import namedtuple
try:
from collections.abc import Callable, Mapping
except ImportError:
from collections import Callable, Mapping
from collections.abc import Callable, Mapping
import copy
import sys

Expand Down
19 changes: 4 additions & 15 deletions numpydoc/docscrape_sphinx.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
from __future__ import division, absolute_import, print_function

import sys
import re
import inspect
import textwrap
import pydoc
try:
from collections.abc import Callable
except ImportError:
from collections import Callable
from collections.abc import Callable
import os

from jinja2 import FileSystemLoader
Expand All @@ -19,11 +13,6 @@
from .docscrape import NumpyDocString, FunctionDoc, ClassDoc
from .xref import make_xref

if sys.version_info[0] >= 3:
sixu = lambda s: s
else:
sixu = lambda s: unicode(s, 'unicode_escape')


IMPORT_MATPLOTLIB_RE = r'\b(import +matplotlib|from +matplotlib +import)\b'

Expand Down Expand Up @@ -290,12 +279,12 @@ def _str_member_list(self, name):

if others:
maxlen_0 = max(3, max([len(p.name) + 4 for p in others]))
hdr = sixu("=") * maxlen_0 + sixu(" ") + sixu("=") * 10
fmt = sixu('%%%ds %%s ') % (maxlen_0,)
hdr = "=" * maxlen_0 + " " + "=" * 10
fmt = '%%%ds %%s ' % (maxlen_0,)
out += ['', '', hdr]
for param in others:
name = "**" + param.name.strip() + "**"
desc = sixu(" ").join(x.strip()
desc = " ".join(x.strip()
for x in param.desc).strip()
if param.type:
desc = "(%s) %s" % (param.type, desc)
Expand Down
50 changes: 17 additions & 33 deletions numpydoc/numpydoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,11 @@
.. [1] https://github.com/numpy/numpydoc

"""
from __future__ import division, absolute_import, print_function

from copy import deepcopy
import sys
import re
import pydoc
import inspect
try:
from collections.abc import Callable
except ImportError:
from collections import Callable
from collections.abc import Callable
import hashlib
import itertools

Expand All @@ -35,21 +29,15 @@
from sphinx.addnodes import pending_xref, desc_content
from sphinx.util import logging

if sphinx.__version__ < '1.0.1':
raise RuntimeError("Sphinx 1.0.1 or newer is required")
if sphinx.__version__ < '1.6.5':
raise RuntimeError("Sphinx 1.6.5 or newer is required")

from .docscrape_sphinx import get_doc_object
from .xref import DEFAULT_LINKS
from . import __version__

logger = logging.getLogger(__name__)

if sys.version_info[0] >= 3:
sixu = lambda s: s
else:
sixu = lambda s: unicode(s, 'unicode_escape')


HASH_LEN = 12

def rename_references(app, what, name, obj, options, lines):
Expand All @@ -58,7 +46,7 @@ def rename_references(app, what, name, obj, options, lines):
references = set()
for line in lines:
line = line.strip()
m = re.match(sixu(r'^\.\. +\[(%s)\]') %
m = re.match(r'^\.\. +\[(%s)\]' %
app.config.numpydoc_citation_re,
line, re.I)
if m:
Expand All @@ -73,10 +61,10 @@ def rename_references(app, what, name, obj, options, lines):
for r in references:
new_r = prefix + '-' + r
for i, line in enumerate(lines):
lines[i] = lines[i].replace(sixu('[%s]_') % r,
sixu('[%s]_') % new_r)
lines[i] = lines[i].replace(sixu('.. [%s]') % r,
sixu('.. [%s]') % new_r)
lines[i] = lines[i].replace('[%s]_' % r,
'[%s]_' % new_r)
lines[i] = lines[i].replace('.. [%s]' % r,
'.. [%s]' % new_r)


def _is_cite_in_numpydoc_docstring(citation_node):
Expand Down Expand Up @@ -166,33 +154,29 @@ def mangle_docstrings(app, what, name, obj, options, lines):
}

cfg.update(options or {})
u_NL = sixu('\n')
u_NL = '\n'
if what == 'module':
# Strip top title
pattern = '^\\s*[#*=]{4,}\\n[a-z0-9 -]+\\n[#*=]{4,}\\s*'
title_re = re.compile(sixu(pattern), re.I | re.S)
lines[:] = title_re.sub(sixu(''), u_NL.join(lines)).split(u_NL)
title_re = re.compile(pattern, re.I | re.S)
lines[:] = title_re.sub('', u_NL.join(lines)).split(u_NL)
else:
try:
doc = get_doc_object(obj, what, u_NL.join(lines), config=cfg,
builder=app.builder)
if sys.version_info[0] >= 3:
doc = str(doc)
else:
doc = unicode(doc)
lines[:] = doc.split(u_NL)
lines[:] = str(doc).split(u_NL)
except:
logger.error('[numpydoc] While processing docstring for %r', name)
raise

if (app.config.numpydoc_edit_link and hasattr(obj, '__name__') and
obj.__name__):
if hasattr(obj, '__module__'):
v = dict(full_name=sixu("%s.%s") % (obj.__module__, obj.__name__))
v = dict(full_name="%s.%s" % (obj.__module__, obj.__name__))
else:
v = dict(full_name=obj.__name__)
lines += [sixu(''), sixu('.. htmlonly::'), sixu('')]
lines += [sixu(' %s') % x for x in
lines += ['', '.. htmlonly::', '']
lines += [' %s' % x for x in
(app.config.numpydoc_edit_link % v).split("\n")]

# call function to replace reference numbers so that there are no
Expand All @@ -218,8 +202,8 @@ def mangle_signature(app, what, name, obj, options, sig, retann):
doc = get_doc_object(obj, config={'show_class_members': False})
sig = doc['Signature'] or getattr(obj, '__text_signature__', None)
if sig:
sig = re.sub(sixu("^[^(]*"), sixu(""), sig)
return sig, sixu('')
sig = re.sub("^[^(]*", "", sig)
return sig, ''


def setup(app, get_doc_object_=get_doc_object):
Expand Down
8 changes: 0 additions & 8 deletions numpydoc/tests/test_docscrape.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# -*- encoding:utf-8 -*-
from __future__ import division, absolute_import, print_function

from collections import namedtuple
from copy import deepcopy
import re
Expand All @@ -24,12 +22,6 @@
from pytest import warns as assert_warns


if sys.version_info[0] >= 3:
sixu = lambda s: s
else:
sixu = lambda s: unicode(s, 'unicode_escape')


doc_txt = '''\
numpy.multivariate_normal(mean, cov, shape=None, spam=None)

Expand Down
2 changes: 0 additions & 2 deletions numpydoc/tests/test_numpydoc.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# -*- encoding:utf-8 -*-
from __future__ import division, absolute_import, print_function

from copy import deepcopy
from numpydoc.numpydoc import mangle_docstrings
from numpydoc.xref import DEFAULT_LINKS
Expand Down
2 changes: 0 additions & 2 deletions numpydoc/tests/test_xref.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# -*- encoding:utf-8 -*-
from __future__ import division, absolute_import, print_function

from numpydoc.xref import make_xref

xref_aliases = {
Expand Down
14 changes: 6 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import division, print_function

import sys
import os

Expand All @@ -9,8 +7,8 @@

from numpydoc import __version__ as version

if sys.version_info[:2] < (2, 7) or (3, 0) <= sys.version_info[0:2] < (3, 4):
raise RuntimeError("Python version 2.7 or >= 3.4 required.")
if sys.version_info < (3, 5):
raise RuntimeError("Python version >= 3.5 required.")


def read(fname):
Expand All @@ -36,18 +34,18 @@ def read(fname):
"License :: OSI Approved :: BSD License",
"Topic :: Documentation",
"Programming Language :: Python",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6"],
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should add 3.8 but can do it later

],
keywords="sphinx numpy",
author="Pauli Virtanen and others",
author_email="[email protected]",
url="https://numpydoc.readthedocs.io",
license="BSD",
install_requires=["sphinx >= 1.6.5", 'Jinja2>=2.3'],
python_requires=">=3.5",
package_data={'numpydoc': [
'tests/test_*.py',
'tests/tinybuild/Makefile',
Expand Down