<s> """<STR_LIT>""" <EOL> from urlparse import urljoin <EOL> from docutils import nodes , utils <EOL> from docutils . parsers . rst . roles import set_classes <EOL> def make_node ( rawtext , app , type_ , slug , options ) : <EOL> """<STR_LIT>""" <EOL> if app . config . github_user is None : <EOL> raise ValueError ( <EOL> "<STR_LIT>" ) <EOL> base_url = "<STR_LIT>" % ( app . config . github_user , <EOL> app . config . project ) <EOL> relative = '<STR_LIT>' % ( type_ , slug ) <EOL> full_ref = urljoin ( base_url , relative ) <EOL> set_classes ( options ) <EOL> if type_ == '<STR_LIT>' : <EOL> type_ = '<STR_LIT>' <EOL> node = nodes . reference ( rawtext , type_ + '<STR_LIT:U+0020>' + utils . unescape ( slug ) , <EOL> refuri = full_ref , ** options ) <EOL> return node <EOL> def github_sha ( name , rawtext , text , lineno , inliner , <EOL> options = None , content = None ) : <EOL> """<STR_LIT>""" <EOL> options = options or { } <EOL> content = content or [ ] <EOL> app = inliner . document . settings . env . app <EOL> node = make_node ( rawtext , app , '<STR_LIT>' , text , options ) <EOL> return [ node ] , [ ] <EOL> def github_issue ( name , rawtext , text , lineno , inliner , <EOL> options = None , content = None ) : <EOL> """<STR_LIT>""" <EOL> options = options or { } <EOL> content = content or [ ] <EOL> try : <EOL> issue = int ( text ) <EOL> except ValueError : <EOL> msg = inliner . reporter . error ( <EOL> "<STR_LIT>" % text , <EOL> line = lineno ) <EOL> problem = inliner . problematic ( rawtext , rawtext , msg ) <EOL> return [ problem ] , [ msg ] <EOL> app = inliner . document . settings . env . app <EOL> node = make_node ( rawtext , app , '<STR_LIT>' , str ( issue ) , options ) <EOL> return [ node ] , [ ] <EOL> def github_pull_request ( name , rawtext , text , lineno , inliner , options = None , <EOL> content = None ) : <EOL> """<STR_LIT>""" <EOL> options = options or { } <EOL> content = content or [ ] <EOL> app = inliner . document . settings . env . app <EOL> node = make_node ( rawtext , app , '<STR_LIT>' , text , options ) <EOL> return [ node ] , [ ] <EOL> def setup ( app ) : <EOL> """<STR_LIT>""" <EOL> app . info ( '<STR_LIT>' ) <EOL> app . add_role ( '<STR_LIT>' , github_sha ) <EOL> app . add_role ( '<STR_LIT>' , github_issue ) <EOL> app . add_role ( '<STR_LIT>' , github_pull_request ) <EOL> app . add_config_value ( '<STR_LIT>' , None , '<STR_LIT>' ) </s>
