-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Am 18.03.2010 16:22, schrieb Schollii:
> Currently (sphinx 0.6.5) the "toctree()" function that can be called
> from template code (such as layout.html) only takes one parameter. The
> file environment.py contains a function get_toctree_for(self, docname,
> builder, collapse) which calls self.resolve_toctree(docname, builder,
> toctreenode, prune=True, collapse=collapse). The resolve_toctree()
> actually accepts another parameter, titles_only, the value of which
> should be settable from the html template (layout.html). I use this
> for http://pubsub.sourceforge.net.
> 
> The following fix is simple and means that any *new* "toc_tree()"
> template parameters handled by resolve_toctree() can be supported
> without changing any code outside of resolve_toctreee() : replace the
> keyword args that are template-related by a **templKw parameter to
> _get_local_toctree() and get_toctree_for() and pass it to
> resolve_toctree(). Only two files are affected, environment.py and
> builders/html.py (the other builders do not override get_toctree_for()
> AFAICT):
> 
> --- C:/Python24/Lib/site-packages/Sphinx-0.6.5-py2.4.egg_orig/sphinx/
> environment.py        Thu Mar 18 09:59:23 2010
> +++ C:/Python24/Lib/site-packages/Sphinx-0.6.5-py2.4.egg/sphinx/
> environment.py        Thu Mar 18 09:57:40 2010
> @@ -933,12 +933,12 @@
>              node['refuri'] = node['anchorname'] or '#'
>          return toc
> 
> -    def get_toctree_for(self, docname, builder, collapse):
> +    def get_toctree_for(self, docname, builder, **tmplKw):
>          """Return the global TOC nodetree."""
>          doctree = self.get_doctree(self.config.master_doc)
>          for toctreenode in doctree.traverse(addnodes.toctree):
>              result = self.resolve_toctree(docname, builder,
> toctreenode,
> -                                          prune=True,
> collapse=collapse)
> +                                          prune=True, **tmplKw)
>              if result is not None:
>                  return result
> 
> For html.py, the patch is:
> 
> --- C:/Python24/Lib/site-packages/Sphinx-0.6.5-py2.4.egg_orig/sphinx/
> builders/html.py      Thu Mar 18 09:59:25 2010
> +++ C:/Python24/Lib/site-packages/Sphinx-0.6.5-py2.4.egg/sphinx/
> builders/html.py      Thu Mar 18 09:55:40 2010
> @@ -623,9 +623,9 @@
>          if self.indexer is not None and title:
>              self.indexer.feed(pagename, title, doctree)
> 
> -    def _get_local_toctree(self, docname, collapse=True):
> +    def _get_local_toctree(self, docname, **tmplKw):
>          return self.render_partial(self.env.get_toctree_for(
> -            docname, self, collapse))['fragment']
> +            docname, self, **tmplKw))['fragment']
> 
>      def get_outfilename(self, pagename):
>          return path.join(self.outdir, os_path(pagename) +
> self.out_suffix)
> 
> Any chance this could be included in next release? Thanks,

Good suggestion!  Implemented in tip, rev 8476c2390d62.

Georg
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.15 (GNU/Linux)

iEYEARECAAYFAkwCSRUACgkQN9GcIYhpnLBILwCeLOdZQtR4KXzvVEaA2JtG/mjf
pa0Anj5dVvb9XYrSiBWYAellL9NGClpI
=1Q/g
-----END PGP SIGNATURE-----

-- 
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