<s> """<STR_LIT>""" <EOL> from docutils import nodes , utils <EOL> from docutils . parsers . rst . roles import set_classes <EOL> def make_link_node ( rawtext , app , type , slug , options ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> base = app . config . github_project_url <EOL> if not base : <EOL> raise AttributeError <EOL> if not base . endswith ( '<STR_LIT:/>' ) : <EOL> base += '<STR_LIT:/>' <EOL> except AttributeError , err : <EOL> raise ValueError ( '<STR_LIT>' % str ( err ) ) <EOL> ref = base + type + '<STR_LIT:/>' + slug + '<STR_LIT:/>' <EOL> set_classes ( options ) <EOL> prefix = "<STR_LIT:#>" <EOL> if type == '<STR_LIT>' : <EOL> prefix = "<STR_LIT>" + prefix <EOL> node = nodes . reference ( rawtext , prefix + utils . unescape ( slug ) , refuri = ref , <EOL> ** options ) <EOL> return node <EOL> def ghissue_role ( name , rawtext , text , lineno , inliner , options = { } , content = [ ] ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> issue_num = int ( text ) <EOL> if issue_num <= <NUM_LIT:0> : <EOL> raise ValueError <EOL> except ValueError : <EOL> msg = inliner . reporter . error ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' % text , line = lineno ) <EOL> prb = inliner . problematic ( rawtext , rawtext , msg ) <EOL> return [ prb ] , [ msg ] <EOL> app = inliner . document . settings . env . app <EOL> if '<STR_LIT>' in name . lower ( ) : <EOL> category = '<STR_LIT>' <EOL> elif '<STR_LIT>' in name . lower ( ) : <EOL> category = '<STR_LIT>' <EOL> else : <EOL> msg = inliner . reporter . error ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' % name , line = lineno ) <EOL> prb = inliner . problematic ( rawtext , rawtext , msg ) <EOL> return [ prb ] , [ msg ] <EOL> node = make_link_node ( rawtext , app , category , str ( issue_num ) , options ) <EOL> return [ node ] , [ ] <EOL> def ghuser_role ( name , rawtext , text , lineno , inliner , options = { } , content = [ ] ) : <EOL> """<STR_LIT>""" <EOL> app = inliner . document . settings . env . app <EOL> ref = '<STR_LIT>' + text <EOL> node = nodes . reference ( rawtext , text , refuri = ref , ** options ) <EOL> return [ node ] , [ ] <EOL> def ghcommit_role ( name , rawtext , text , lineno , inliner , options = { } , content = [ ] ) : <EOL> """<STR_LIT>""" <EOL> app = inliner . document . settings . env . app <EOL> try : <EOL> base = app . config . github_project_url <EOL> if not base : <EOL> raise AttributeError <EOL> if not base . endswith ( '<STR_LIT:/>' ) : <EOL> base += '<STR_LIT:/>' <EOL> except AttributeError , err : <EOL> raise ValueError ( '<STR_LIT>' % str ( err ) ) <EOL> ref = base + text <EOL> node = nodes . reference ( rawtext , text [ : <NUM_LIT:6> ] , refuri = ref , ** options ) <EOL> return [ node ] , [ ] <EOL> def setup ( app ) : <EOL> """<STR_LIT>""" <EOL> app . info ( '<STR_LIT>' ) <EOL> app . add_role ( '<STR_LIT>' , ghissue_role ) <EOL> app . add_role ( '<STR_LIT>' , ghissue_role ) <EOL> app . add_role ( '<STR_LIT>' , ghuser_role ) <EOL> app . add_role ( '<STR_LIT>' , ghcommit_role ) <EOL> app . add_config_value ( '<STR_LIT>' , None , '<STR_LIT>' ) <EOL> return </s>
