def _check_docstrings(self,obj,errors):
import enchant
if hasattr(obj,"__doc__"):
skip_errors = [w for w in getattr(obj,"_DOC_ERRORS",[])]
chkr = enchant.checker.SpellChecker("en_AU",obj.__doc__,filters=[enchant.tokenize.URLFilter])
for err in chkr:
if len(err.word) == 1:
continue
if err.word.lower() in self.WORDS:
continue
if skip_errors and skip_errors[0] == err.word:
skip_errors.pop(0)
continue
errors.append((obj,err.word,err.wordpos))
msg = "\nDOCSTRING SPELLING ERROR: %s %s %d %s\n" % (obj,err.word,err.wordpos,chkr.suggest())
printf([msg],file=sys.stderr)
# Find and yield all child objects that should be checked
for name in dir(obj):
if name.startswith("__"):
continue
child = getattr(obj,name)
if hasattr(child,"__file__"):
if not hasattr(globals(),"__file__"):
continue
if not child.__file__.startswith(os.path.dirname(__file__)):
continue
else:
cmod = getattr(child,"__module__",None)
if not cmod:
cclass = getattr(child,"__class__",None)
cmod = getattr(cclass,"__module__",None)
if cmod and not cmod.startswith("enchant"):
continue
yield child
评论列表
文章目录