From 9016e7e99353ad7462b334fd5ba77e52fba707d2 Mon Sep 17 00:00:00 2001 From: Pablo Hoffman Date: Wed, 18 May 2011 14:43:34 -0300 Subject: [PATCH] added role to link to scrapy source code (not yet used) --- docs/_ext/scrapydocs.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docs/_ext/scrapydocs.py b/docs/_ext/scrapydocs.py index 3cc916972..6b1e6a9b4 100644 --- a/docs/_ext/scrapydocs.py +++ b/docs/_ext/scrapydocs.py @@ -1,3 +1,6 @@ +from docutils.parsers.rst.roles import set_classes +from docutils import nodes + def setup(app): app.add_crossref_type( directivename = "setting", @@ -19,3 +22,10 @@ def setup(app): rolename = "reqmeta", indextemplate = "pair: %s; reqmeta", ) + app.add_role('source', source_role) + +def source_role(name, rawtext, text, lineno, inliner, options={}, content=[]): + url = 'http://dev.scrapy.org/browser/' + text + set_classes(options) + node = nodes.reference(rawtext, text, refuri=ref, **options) + return [node], []