Getting the source .rst file path in Sphinx extension
Posted
by
Mikko Ohtamaa
on Stack Overflow
See other posts from Stack Overflow
or by Mikko Ohtamaa
Published on 2012-11-17T16:57:32Z
Indexed on
2012/11/17
16:59 UTC
Read the original article
Hit count: 346
python
|python-sphinx
I am writing a Sphinx extension and I need to know the document page source code file system path (.rst file location) to extract some version control system information of it. How can I get this information in my event handler / which event handler I should use?
Example:
# This package may contain traces of nuts
def on_html_page_context(app, pagename, templatename, context, doctree):
import ipdb ; ipdb.set_trace()
if doctree:
print doctree.source
def setup(app):
app.require_sphinx('1.0')
app.connect('html-page-context', on_html_page_context)
© Stack Overflow or respective owner