An example extension implementing this role might look like this: from docutils import nodes, utils import posixpath
def sfile_role(typ, rawtext, etext, lineno, inliner, options={}, content=[]): env = inliner.document.settings.env baseuri = env.config.sfile_base_uri text = utils.unescape(text) refnode = nodes.reference('', '', refuri=posixpath.join(baseuri, text)) refnode += nodes.literal(text, text) return [refnode], [] def setup(app): app.add_role('sfile', sfile_role) app.add_config_value('sfile_base_uri', 'http://example.com/source', True) The extension can be a separate file, or you can put that code into conf.py. Georg Dan Craig schrieb: > Ok, I'll try that. If you can point me to an example, I'd appreciate > it. > > Thanks, > Dan > > On Dec 15, 6:38 am, Georg Brandl <ge...@python.org> wrote: >> Dan Craig schrieb: >> >> > Is it possible to add functionality to some of the semantic markup >> > directives? Specifically, I'm interested in the :file: directive. >> > According to the documentation, all it does is format the text. I'd >> > like it to format the text and create a hyperlink to a source code >> > viewer. It looks like this could be similar to the PEP or RFC >> > directives. >> >> I'd just call the role differently, e.g. :sfile: -- then you can >> implement it in your own extension. >> >> Let me know if you need examples for that. >> >> Georg > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sphinx-dev" group. To post to this group, send email to sphinx-dev@googlegroups.com To unsubscribe from this group, send email to sphinx-dev+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sphinx-dev?hl=en -~----------~----~----~----~------~----~------~--~---