Wei-Wei Guo wrote:
> Dear all,
>
> I have a index.rst file like this:
>
> source
> |-- index.rst
> |-- mydict
> |-- index.rst
> |-- mytest.rst
>
> Those files are
>
> index.rst:
>
> Index Title
> ===========
>
> .. toctree:
>
> mydict/index
>
> mydict.rst:
>
> Mydict Title
> ============
>
> .. toctree:
>
> mytest
>
> mytest.rst:
>
> Mytest Title
> ============
>
> Nothing, only text.
>
>
> 'toctree' will put a bullet list there and replace the file names, such as
> 'mydict/index',
> to their page title, such as 'Index Title'. Can I just use the file name?
>
> And I don't want toctree be transformed to a bulllet list node. I want to use
> a new node
> for it. Can I do it?
>
>
Well, if I understood you correctly, I needed something similiar and
ended up with this small extension:
toctree_items = []
def html_page_context(app, pagename, templatename, context, doctree):
context['toctree_items'] = toctree_items
def env_updated(app, env):
master_doc = app.builder.config.master_doc
toctree = env.tocs[master_doc].traverse(lambda n: n.tagname ==
'toctree')[0]
global toctree_items
for link_label, pagename in toctree['entries']:
if pagename == 'self':
pagename = master_doc
pagetitle = env.toctree_items[pagename].astext()
toctree_items.insert(0, (pagename, pagetitle))
def setup(app):
app.connect('html-page-context', html_page_context)
app.connect('env-updated', env_updated)
I didn't want the toctree to be included as <ul> in the html-output but
I still needed that same info to generate navigation bars.
So I defined my toctrees to be hidden:
.. toctree::
:hidden:
And then dug the toctee information on 'env-updated' event (after all
nodes has been resolved) and passed that to template as a part of it's
context. I hope this helps a bit. That snippet isn't probably the best
way to do it, but I'm still quite newbie with Sphinx. :)
--
Tuomas
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---