2011-05-18 14:43:34 -03:00
|
|
|
from docutils.parsers.rst.roles import set_classes
|
|
|
|
from docutils import nodes
|
|
|
|
|
2008-12-16 11:53:20 +00:00
|
|
|
def setup(app):
|
2008-12-29 19:02:56 +00:00
|
|
|
app.add_crossref_type(
|
2008-12-16 11:53:20 +00:00
|
|
|
directivename = "setting",
|
|
|
|
rolename = "setting",
|
|
|
|
indextemplate = "pair: %s; setting",
|
|
|
|
)
|
2009-01-02 19:48:31 +00:00
|
|
|
app.add_crossref_type(
|
|
|
|
directivename = "signal",
|
|
|
|
rolename = "signal",
|
|
|
|
indextemplate = "pair: %s; signal",
|
|
|
|
)
|
2010-08-19 00:04:52 -03:00
|
|
|
app.add_crossref_type(
|
|
|
|
directivename = "command",
|
|
|
|
rolename = "command",
|
|
|
|
indextemplate = "pair: %s; command",
|
|
|
|
)
|
2010-09-09 21:37:35 -03:00
|
|
|
app.add_crossref_type(
|
|
|
|
directivename = "reqmeta",
|
|
|
|
rolename = "reqmeta",
|
|
|
|
indextemplate = "pair: %s; reqmeta",
|
|
|
|
)
|
2011-05-18 14:43:34 -03:00
|
|
|
app.add_role('source', source_role)
|
2012-04-11 15:53:23 -03:00
|
|
|
app.add_role('commit', commit_role)
|
2012-08-31 18:39:30 -03:00
|
|
|
app.add_role('issue', issue_role)
|
2012-04-11 15:53:23 -03:00
|
|
|
app.add_role('rev', rev_role)
|
2011-05-18 14:43:34 -03:00
|
|
|
|
|
|
|
def source_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
|
2012-04-11 15:53:23 -03:00
|
|
|
ref = 'https://github.com/scrapy/scrapy/blob/master/' + text
|
2011-05-18 14:43:34 -03:00
|
|
|
set_classes(options)
|
|
|
|
node = nodes.reference(rawtext, text, refuri=ref, **options)
|
|
|
|
return [node], []
|
2012-04-11 15:53:23 -03:00
|
|
|
|
2012-08-31 18:39:30 -03:00
|
|
|
def issue_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
|
|
|
|
ref = 'https://github.com/scrapy/scrapy/issues/' + text
|
|
|
|
set_classes(options)
|
|
|
|
node = nodes.reference(rawtext, 'issue ' + text, refuri=ref, **options)
|
|
|
|
return [node], []
|
|
|
|
|
2012-04-11 15:53:23 -03:00
|
|
|
def commit_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
|
|
|
|
ref = 'https://github.com/scrapy/scrapy/commit/' + text
|
|
|
|
set_classes(options)
|
|
|
|
node = nodes.reference(rawtext, 'commit ' + text, refuri=ref, **options)
|
|
|
|
return [node], []
|
|
|
|
|
|
|
|
def rev_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
|
|
|
|
ref = 'http://hg.scrapy.org/scrapy/changeset/' + text
|
|
|
|
set_classes(options)
|
|
|
|
node = nodes.reference(rawtext, 'r' + text, refuri=ref, **options)
|
|
|
|
return [node], []
|