<s> """<STR_LIT>""" <EOL> import sys <EOL> from six import PY2 , iteritems <EOL> import sphinx <EOL> from sphinx . ext . napoleon . docstring import GoogleDocstring , NumpyDocstring <EOL> class Config ( object ) : <EOL> """<STR_LIT>""" <EOL> _config_values = { <EOL> '<STR_LIT>' : ( True , '<STR_LIT>' ) , <EOL> '<STR_LIT>' : ( True , '<STR_LIT>' ) , <EOL> '<STR_LIT>' : ( False , '<STR_LIT>' ) , <EOL> '<STR_LIT>' : ( False , '<STR_LIT>' ) , <EOL> '<STR_LIT>' : ( False , '<STR_LIT>' ) , <EOL> '<STR_LIT>' : ( False , '<STR_LIT>' ) , <EOL> '<STR_LIT>' : ( False , '<STR_LIT>' ) , <EOL> '<STR_LIT>' : ( False , '<STR_LIT>' ) , <EOL> '<STR_LIT>' : ( True , '<STR_LIT>' ) , <EOL> '<STR_LIT>' : ( True , '<STR_LIT>' ) , <EOL> '<STR_LIT>' : ( True , '<STR_LIT>' ) <EOL> } <EOL> def __init__ ( self , ** settings ) : <EOL> for name , ( default , rebuild ) in iteritems ( self . _config_values ) : <EOL> setattr ( self , name , default ) <EOL> for name , value in iteritems ( settings ) : <EOL> setattr ( self , name , value ) <EOL> def setup ( app ) : <EOL> """<STR_LIT>""" <EOL> from sphinx . application import Sphinx <EOL> if not isinstance ( app , Sphinx ) : <EOL> return <EOL> _patch_python_domain ( ) <EOL> app . connect ( '<STR_LIT>' , _process_docstring ) <EOL> app . connect ( '<STR_LIT>' , _skip_member ) <EOL> for name , ( default , rebuild ) in iteritems ( Config . _config_values ) : <EOL> app . add_config_value ( name , default , rebuild ) <EOL> return { '<STR_LIT:version>' : sphinx . __display_version__ , '<STR_LIT>' : True } <EOL> def _patch_python_domain ( ) : <EOL> import sphinx . domains . python <EOL> from sphinx . domains . python import PyTypedField <EOL> import sphinx . locale <EOL> l_ = sphinx . locale . lazy_gettext <EOL> for doc_field in sphinx . domains . python . PyObject . doc_field_types : <EOL> if doc_field . name == '<STR_LIT>' : <EOL> doc_field . names = ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> break <EOL> sphinx . domains . python . PyObject . doc_field_types . append ( <EOL> PyTypedField ( '<STR_LIT>' , label = l_ ( '<STR_LIT>' ) , <EOL> names = ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) , <EOL> typerolename = '<STR_LIT>' , typenames = ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> can_collapse = True ) , <EOL> ) <EOL> def _process_docstring ( app , what , name , obj , options , lines ) : <EOL> """<STR_LIT>""" <EOL> result_lines = lines <EOL> if app . config . napoleon_numpy_docstring : <EOL> docstring = NumpyDocstring ( result_lines , app . config , app , what , name , <EOL> obj , options ) <EOL> result_lines = docstring . lines ( ) <EOL> if app . config . napoleon_google_docstring : <EOL> docstring = GoogleDocstring ( result_lines , app . config , app , what , name , <EOL> obj , options ) <EOL> result_lines = docstring . lines ( ) <EOL> lines [ : ] = result_lines [ : ] <EOL> def _skip_member ( app , what , name , obj , skip , options ) : <EOL> """<STR_LIT>""" <EOL> has_doc = getattr ( obj , '<STR_LIT>' , False ) <EOL> is_member = ( what == '<STR_LIT:class>' or what == '<STR_LIT>' or what == '<STR_LIT>' ) <EOL> if name != '<STR_LIT>' and name != '<STR_LIT>' and has_doc and is_member : <EOL> cls_is_owner = False <EOL> if what == '<STR_LIT:class>' or what == '<STR_LIT>' : <EOL> if PY2 : <EOL> cls = getattr ( obj , '<STR_LIT>' , getattr ( obj , '<STR_LIT>' , <EOL> None ) ) <EOL> cls_is_owner = ( cls and hasattr ( cls , name ) and <EOL> name in cls . __dict__ ) <EOL> elif sys . version_info >= ( <NUM_LIT:3> , <NUM_LIT:3> ) : <EOL> qualname = getattr ( obj , '<STR_LIT>' , '<STR_LIT>' ) <EOL> cls_path , _ , _ = qualname . rpartition ( '<STR_LIT:.>' ) <EOL> if cls_path : <EOL> try : <EOL> if '<STR_LIT:.>' in cls_path : <EOL> import importlib <EOL> import functools <EOL> mod = importlib . import_module ( obj . __module__ ) <EOL> mod_path = cls_path . split ( '<STR_LIT:.>' ) <EOL> cls = functools . reduce ( getattr , mod_path , mod ) <EOL> else : <EOL> cls = obj . __globals__ [ cls_path ] <EOL> except Exception : <EOL> cls_is_owner = False <EOL> else : <EOL> cls_is_owner = ( cls and hasattr ( cls , name ) and <EOL> name in cls . __dict__ ) <EOL> else : <EOL> cls_is_owner = False <EOL> else : <EOL> cls_is_owner = True <EOL> if what == '<STR_LIT>' or cls_is_owner : <EOL> is_special = name . startswith ( '<STR_LIT>' ) and name . endswith ( '<STR_LIT>' ) <EOL> is_private = not is_special and name . startswith ( '<STR_LIT:_>' ) <EOL> inc_special = app . config . napoleon_include_special_with_doc <EOL> inc_private = app . config . napoleon_include_private_with_doc <EOL> if ( is_special and inc_special ) or ( is_private and inc_private ) : <EOL> return False <EOL> return skip </s>
