Commits

Georg Brandl committed 8476c23

The ``toctree`` callable in templates now accepts a ``titles_only`` keyword argument.

Comments (0)

Files changed (5)

   - Added new theme ``scrolls``, created by Armin Ronacher.
   - #193: Added a ``visitedlinkcolor`` theme option to the default
     theme.
+  - The ``toctree`` callable in templates now accepts a ``titles_only``
+    keyword argument.
 
 * Extension API:
 

doc/templating.rst

 
    * ``maxdepth`` (defaults to the max depth selected in the toctree directive):
      the maximum depth of the tree; set it to ``-1`` to allow unlimited depth
+
+   * ``titles_only`` (false by default): if true, put only toplevel document
+     titles in the tree

sphinx/builders/html.py

         if self.indexer is not None and title:
             self.indexer.feed(pagename, title, doctree)
 
-    def _get_local_toctree(self, docname, collapse=True, maxdepth=0):
+    def _get_local_toctree(self, docname, collapse=True, **kwds):
         return self.render_partial(self.env.get_toctree_for(
-            docname, self, collapse))['fragment']
+            docname, self, collapse, **kwds))['fragment']
 
     def get_outfilename(self, pagename):
         return path.join(self.outdir, os_path(pagename) + self.out_suffix)

sphinx/environment.py

             node['refuri'] = node['anchorname'] or '#'
         return toc
 
-    def get_toctree_for(self, docname, builder, collapse, maxdepth=0):
+    def get_toctree_for(self, docname, builder, collapse, **kwds):
         """Return the global TOC nodetree."""
         doctree = self.get_doctree(self.config.master_doc)
         toctrees = []
+        if 'includehidden' not in kwds:
+            kwds['includehidden'] = True
+        if 'maxdepth' not in kwds:
+            kwds['maxdepth'] = 0
+        kwds['collapse'] = collapse
         for toctreenode in doctree.traverse(addnodes.toctree):
             toctree = self.resolve_toctree(docname, builder, toctreenode,
-                                           prune=True, collapse=collapse,
-                                           maxdepth=maxdepth,
-                                           includehidden=True)
+                                           prune=True, **kwds)
             toctrees.append(toctree)
         if not toctrees:
             return None

tests/root/_templates/customsb.html

 {# custom sidebar template #}
 <h4>Custom sidebar</h4>
+
+{{ toctree(titles_only=True, maxdepth=1) }}