90
90
"EX01" : "No examples section found" ,
91
91
}
92
92
93
+ # Ignore these when evaluating end-of-line-"." checks
94
+ IGNORE_STARTS = (" " , "* " , "- " )
95
+
93
96
94
97
def error (code , ** kwargs ):
95
98
"""
@@ -257,13 +260,10 @@ def extended_summary(self):
257
260
258
261
@property
259
262
def doc_parameters (self ):
260
- return self ._get_doc_parameters ()
261
-
262
- def _get_doc_parameters (self , joiner = "" ):
263
263
parameters = collections .OrderedDict ()
264
264
for names , type_ , desc in self .doc ["Parameters" ]:
265
265
for name in names .split (", " ):
266
- parameters [name ] = (type_ , joiner . join ( desc ) )
266
+ parameters [name ] = (type_ , desc )
267
267
return parameters
268
268
269
269
@property
@@ -332,14 +332,15 @@ def directives_without_two_colons(self):
332
332
def parameter_type (self , param ):
333
333
return self .doc_parameters [param ][0 ]
334
334
335
- def parameter_desc (self , param , joiner = "" ):
336
- desc = self . _get_doc_parameters ( joiner ) [param ][1 ]
335
+ def parameter_desc (self , param ):
336
+ desc = " \n " . join ( self . doc_parameters [param ][1 ])
337
337
# Find and strip out any sphinx directives
338
338
for directive in DIRECTIVES :
339
339
full_directive = ".. {}" .format (directive )
340
340
if full_directive in desc :
341
341
# Only retain any description before the directive
342
- desc = desc [: desc .index (full_directive )]
342
+ desc = desc [: desc .index (full_directive )].rstrip ("\n " )
343
+ desc = desc .split ("\n " )
343
344
return desc
344
345
345
346
@property
@@ -544,17 +545,19 @@ def validate(func_name):
544
545
wrong_type = wrong_type ,
545
546
)
546
547
)
547
- this_desc = doc .parameter_desc (param , " \n " ). rstrip ( " \n " )
548
- if not this_desc :
548
+ this_desc = doc .parameter_desc (param )
549
+ if not '' . join ( this_desc ) :
549
550
errs .append (error ("PR07" , param_name = param ))
550
551
else :
551
- if this_desc [0 ].isalpha () and not this_desc [0 ].isupper ():
552
+ if this_desc [0 ][ 0 ] .isalpha () and not this_desc [ 0 ] [0 ].isupper ():
552
553
errs .append (error ("PR08" , param_name = param ))
553
554
# Not ending in "." is only an error if the last bit is not
554
555
# indented (e.g., quote or code block)
555
- if this_desc [- 1 ] != "." and \
556
- not this_desc . split ( " \n " ) [- 1 ].startswith (" " ):
556
+ if this_desc [- 1 ][ - 1 ] != "." and \
557
+ not this_desc [- 1 ].startswith (IGNORE_STARTS ):
557
558
errs .append (error ("PR09" , param_name = param ))
559
+ if param == 'axis' :
560
+ raise RuntimeError
558
561
559
562
if doc .is_function_or_method :
560
563
if not doc .returns :
@@ -571,7 +574,7 @@ def validate(func_name):
571
574
if desc [0 ].isalpha () and not desc [0 ].isupper ():
572
575
errs .append (error ("RT04" ))
573
576
if not desc .endswith ("." ) and \
574
- not desc .split ("\n " )[- 1 ].startswith (" " ):
577
+ not desc .split ("\n " )[- 1 ].startswith (IGNORE_STARTS ):
575
578
errs .append (error ("RT05" ))
576
579
577
580
if not doc .yields and "yield" in doc .method_source :
0 commit comments