17
17
18
18
"""
19
19
20
- from copy import deepcopy
21
- import re
22
- import pydoc
23
- import inspect
24
- from collections .abc import Callable
25
20
import hashlib
21
+ import inspect
26
22
import itertools
23
+ import pydoc
24
+ import re
25
+ from collections .abc import Callable
26
+ from copy import deepcopy
27
27
28
- from docutils .nodes import citation , Text , section , comment , reference , inline
29
- import sphinx
30
- from sphinx .addnodes import pending_xref , desc_content
28
+ from docutils .nodes import Text , citation , comment , inline , reference , section
29
+ from sphinx .addnodes import desc_content , pending_xref
31
30
from sphinx .util import logging
32
- from sphinx .errors import ExtensionError
33
31
32
+ from . import __version__
34
33
from .docscrape_sphinx import get_doc_object
35
- from .validate import validate , ERROR_MSGS , get_validation_checks
34
+ from .validate import get_validation_checks , validate
36
35
from .xref import DEFAULT_LINKS
37
- from . import __version__
38
36
39
37
logger = logging .getLogger (__name__ )
40
38
@@ -248,10 +246,10 @@ def mangle_signature(app, what, name, obj, options, sig, retann):
248
246
return "" , ""
249
247
250
248
if not (isinstance (obj , Callable ) or hasattr (obj , "__argspec_is_invalid_" )):
251
- return
249
+ return None
252
250
253
251
if not hasattr (obj , "__doc__" ):
254
- return
252
+ return None
255
253
doc = get_doc_object (obj , config = {"show_class_members" : False })
256
254
sig = doc ["Signature" ] or _clean_text_signature (
257
255
getattr (obj , "__text_signature__" , None )
@@ -275,7 +273,7 @@ def _clean_text_signature(sig):
275
273
276
274
def setup (app , get_doc_object_ = get_doc_object ):
277
275
if not hasattr (app , "add_config_value" ):
278
- return # probably called by nose, better bail out
276
+ return None # probably called by nose, better bail out
279
277
280
278
global get_doc_object
281
279
get_doc_object = get_doc_object_
@@ -417,12 +415,18 @@ def match_items(lines, content_old):
417
415
418
416
Examples
419
417
--------
420
- >>> lines = ['', 'A', '', 'B', ' ', '', 'C', 'D']
421
- >>> lines_old = ['a', '', '', 'b', '', 'c']
422
- >>> items_old = [('file1.py', 0), ('file1.py', 1), ('file1.py', 2),
423
- ... ('file2.py', 0), ('file2.py', 1), ('file2.py', 2)]
418
+ >>> lines = ["", "A", "", "B", " ", "", "C", "D"]
419
+ >>> lines_old = ["a", "", "", "b", "", "c"]
420
+ >>> items_old = [
421
+ ... ("file1.py", 0),
422
+ ... ("file1.py", 1),
423
+ ... ("file1.py", 2),
424
+ ... ("file2.py", 0),
425
+ ... ("file2.py", 1),
426
+ ... ("file2.py", 2),
427
+ ... ]
424
428
>>> content_old = ViewList(lines_old, items=items_old)
425
- >>> match_items(lines, content_old) # doctest: +NORMALIZE_WHITESPACE
429
+ >>> match_items(lines, content_old) # doctest: +NORMALIZE_WHITESPACE
426
430
[('file1.py', 0), ('file1.py', 0), ('file2.py', 0), ('file2.py', 0),
427
431
('file2.py', 2), ('file2.py', 2), ('file2.py', 2), ('file2.py', 2)]
428
432
>>> # first 2 ``lines`` are matched to 'a', second 2 to 'b', rest to 'c'
0 commit comments