I ended up chasing your mention of ``html-page-context``,
making an extension with this in setup(app)

    app.connect('html-page-context', sphinxed)

in sphinxed(app, pagename, templatename, context, doctree)

I munge the fqname and a couple other things, register the result as

    context['sphinxed_url'] = sphinxed_url

Then layout.html contains

      <li><a href="{{ sphinxed_url|e }}">{{ _('Edit source') }}</a></li>

This gives the result I want. Is it a reasonable approach?

it all makes some sense except for the ``|e`` in {{ sphinxed_url|e}}

sphinxed_url is a Grok page which will open an editor with the source
file loaded, after editing it will run ``make html``

I think I'll find this really handy.


On Sat, Oct 18, 2008 at 3:20 PM, Georg Brandl <[EMAIL PROTECTED]> wrote:
>
> Pierre GM schrieb:
>> All,
>>
>> I'm writing a directive to automatically produce some plots from some 
>> scripts.
>>
>> How can I intercept the name of the .rst file where this directive is
>> present ?
>>
>> For example, let's say I have a file source/examples/plotting/basics.rst 
>> where
>> my directive ".. plot:: name_of_the_script" is present somewhere. I need to
>> find that the file is in "source/examples/plotting/", so that I can know how
>> far back I need to go to access the files (that are copied in build).
>>
>> Any idea or pointer to the famous manual are welcome.
>> Thx a lot in advance!
>
> The current docname is in "state.document.settings.env.docname" while the
> directive function is called (look e.g. at toctree_directive in
> directives/other.py).
>
> I'm sorry for the late answer.
>
> Georg
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sphinx-dev" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sphinx-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to