<s> """<STR_LIT>""" <EOL> __docformat__ = '<STR_LIT>' <EOL> import re , sys , os . path , string <EOL> from xml . dom . minidom import Text as _Text <EOL> from epydoc . apidoc import * <EOL> _NO_DOCS = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> _NO_BASIC = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> _NO_RETURN = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> _NO_PARAM = [ '<STR_LIT>' ] <EOL> class DocChecker : <EOL> """<STR_LIT>""" <EOL> MODULE = <NUM_LIT:1> <EOL> CLASS = <NUM_LIT:2> <EOL> FUNC = <NUM_LIT:4> <EOL> VAR = <NUM_LIT:8> <EOL> PARAM = <NUM_LIT:64> <EOL> RETURN = <NUM_LIT> <EOL> PROPERTY = <NUM_LIT> <EOL> ALL_T = <NUM_LIT:1> + <NUM_LIT:2> + <NUM_LIT:4> + <NUM_LIT:8> + <NUM_LIT:16> + <NUM_LIT:32> + <NUM_LIT:64> + <NUM_LIT> + <NUM_LIT> <EOL> TYPE = <NUM_LIT> <EOL> AUTHOR = <NUM_LIT> <EOL> VERSION = <NUM_LIT> <EOL> DESCR = <NUM_LIT> <EOL> ALL_C = <NUM_LIT> + <NUM_LIT> + <NUM_LIT> + <NUM_LIT> + <NUM_LIT> <EOL> PRIVATE = <NUM_LIT> <EOL> ALL = ALL_T + ALL_C + PRIVATE <EOL> def __init__ ( self , docindex ) : <EOL> """<STR_LIT>""" <EOL> self . _docindex = docindex <EOL> self . _checks = <NUM_LIT:0> <EOL> self . _last_warn = None <EOL> self . _out = sys . stdout <EOL> self . _num_warnings = <NUM_LIT:0> <EOL> def check ( self , * check_sets ) : <EOL> """<STR_LIT>""" <EOL> if not check_sets : <EOL> check_sets = ( DocChecker . MODULE | DocChecker . CLASS | <EOL> DocChecker . FUNC | DocChecker . VAR | <EOL> DocChecker . DESCR , ) <EOL> self . _warnings = { } <EOL> log . start_progress ( '<STR_LIT>' ) <EOL> for j , checks in enumerate ( check_sets ) : <EOL> self . _check ( checks ) <EOL> log . end_progress ( ) <EOL> for ( warning , docs ) in self . _warnings . items ( ) : <EOL> docs = sorted ( docs ) <EOL> docnames = '<STR_LIT:\n>' . join ( [ '<STR_LIT>' % self . _name ( d ) for d in docs ] ) <EOL> log . warning ( '<STR_LIT>' % ( warning , docnames ) ) <EOL> def _check ( self , checks ) : <EOL> self . _checks = checks <EOL> valdocs = sorted ( self . _docindex . reachable_valdocs ( <EOL> imports = False , packages = False , bases = False , submodules = False , <EOL> subclasses = False , private = ( checks & DocChecker . PRIVATE ) ) ) <EOL> docs = set ( ) <EOL> for d in valdocs : <EOL> if not isinstance ( d , GenericValueDoc ) : docs . add ( d ) <EOL> for doc in valdocs : <EOL> if isinstance ( doc , NamespaceDoc ) : <EOL> for d in doc . variables . values ( ) : <EOL> if isinstance ( d . value , GenericValueDoc ) : docs . add ( d ) <EOL> for i , doc in enumerate ( sorted ( docs ) ) : <EOL> if isinstance ( doc , ModuleDoc ) : <EOL> self . _check_module ( doc ) <EOL> elif isinstance ( doc , ClassDoc ) : <EOL> self . _check_class ( doc ) <EOL> elif isinstance ( doc , RoutineDoc ) : <EOL> self . _check_func ( doc ) <EOL> elif isinstance ( doc , PropertyDoc ) : <EOL> self . _check_property ( doc ) <EOL> elif isinstance ( doc , VariableDoc ) : <EOL> self . _check_var ( doc ) <EOL> else : <EOL> log . error ( "<STR_LIT>" % doc ) <EOL> def _name ( self , doc ) : <EOL> name = str ( doc . canonical_name ) <EOL> if isinstance ( doc , RoutineDoc ) : name += '<STR_LIT>' <EOL> return name <EOL> def _check_basic ( self , doc ) : <EOL> """<STR_LIT>""" <EOL> if ( ( self . _checks & DocChecker . DESCR ) and <EOL> ( doc . descr in ( None , UNKNOWN ) ) ) : <EOL> if doc . docstring in ( None , UNKNOWN ) : <EOL> self . warning ( '<STR_LIT>' , doc ) <EOL> else : <EOL> self . warning ( '<STR_LIT>' , doc ) <EOL> if self . _checks & DocChecker . AUTHOR : <EOL> for tag , arg , descr in doc . metadata : <EOL> if '<STR_LIT>' == tag : break <EOL> else : <EOL> self . warning ( '<STR_LIT>' , doc ) <EOL> if self . _checks & DocChecker . VERSION : <EOL> for tag , arg , descr in doc . metadata : <EOL> if '<STR_LIT:version>' == tag : break <EOL> else : <EOL> self . warning ( '<STR_LIT>' , doc ) <EOL> def _check_module ( self , doc ) : <EOL> """<STR_LIT>""" <EOL> if self . _checks & DocChecker . MODULE : <EOL> self . _check_basic ( doc ) <EOL> def _check_class ( self , doc ) : <EOL> """<STR_LIT>""" <EOL> if self . _checks & DocChecker . CLASS : <EOL> self . _check_basic ( doc ) <EOL> def _check_property ( self , doc ) : <EOL> if self . _checks & DocChecker . PROPERTY : <EOL> self . _check_basic ( doc ) <EOL> def _check_var ( self , doc ) : <EOL> """<STR_LIT>""" <EOL> if self . _checks & DocChecker . VAR : <EOL> if ( self . _checks & ( DocChecker . DESCR | DocChecker . TYPE ) and <EOL> doc . descr in ( None , UNKNOWN ) and <EOL> doc . type_descr in ( None , UNKNOWN ) and <EOL> doc . docstring in ( None , UNKNOWN ) ) : <EOL> self . warning ( '<STR_LIT>' , doc ) <EOL> else : <EOL> if ( self . _checks & DocChecker . DESCR and <EOL> doc . descr in ( None , UNKNOWN ) ) : <EOL> self . warning ( '<STR_LIT>' , doc ) <EOL> if ( self . _checks & DocChecker . TYPE and <EOL> doc . type_descr in ( None , UNKNOWN ) ) : <EOL> self . warning ( '<STR_LIT>' , doc ) <EOL> def _check_func ( self , doc ) : <EOL> """<STR_LIT>""" <EOL> name = doc . canonical_name <EOL> if ( self . _checks & DocChecker . FUNC and <EOL> doc . docstring in ( None , UNKNOWN ) and <EOL> doc . canonical_name [ - <NUM_LIT:1> ] not in _NO_DOCS ) : <EOL> self . warning ( '<STR_LIT>' , doc ) <EOL> return <EOL> if ( self . _checks & DocChecker . FUNC and <EOL> doc . canonical_name [ - <NUM_LIT:1> ] not in _NO_BASIC ) : <EOL> self . _check_basic ( doc ) <EOL> if ( self . _checks & DocChecker . RETURN and <EOL> doc . canonical_name [ - <NUM_LIT:1> ] not in _NO_RETURN ) : <EOL> if ( doc . return_type in ( None , UNKNOWN ) and <EOL> doc . return_descr in ( None , UNKNOWN ) ) : <EOL> self . warning ( '<STR_LIT>' , doc ) <EOL> if ( self . _checks & DocChecker . PARAM and <EOL> doc . canonical_name [ - <NUM_LIT:1> ] not in _NO_PARAM ) : <EOL> if doc . arg_descrs in ( None , UNKNOWN ) : <EOL> self . warning ( '<STR_LIT>' , doc ) <EOL> else : <EOL> args_with_descr = [ ] <EOL> for arg , descr in doc . arg_descrs : <EOL> if isinstance ( arg , basestring ) : <EOL> args_with_descr . append ( arg ) <EOL> else : <EOL> args_with_descr += arg <EOL> for posarg in doc . posargs : <EOL> if ( self . _checks & DocChecker . DESCR and <EOL> posarg not in args_with_descr ) : <EOL> self . warning ( '<STR_LIT>' , doc ) <EOL> if ( self . _checks & DocChecker . TYPE and <EOL> posarg not in doc . arg_types ) : <EOL> self . warning ( '<STR_LIT>' , doc ) <EOL> def warning ( self , msg , doc ) : <EOL> self . _warnings . setdefault ( msg , set ( ) ) . add ( doc ) </s>
