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

Am 02.04.2010 20:50, schrieb Nikolaus Rath:
> TP <[email protected]> writes:
>> On Fri, Apr 2, 2010 at 9:46 AM, Nikolaus Rath <[email protected]> wrote:
>>> Hello,
>>>
>>> I am using
>>>
>>>          {%- if display_toc %}
>>>            <h3><a href="{{ pathto(master_doc) }}">{{ _('Table Of Contents') 
>>> }}</a></h3>
>>>            {{ toctree() }}
>>>          {%- endif %}
>>>
>>> to display a table of contents in the sidebar. This works nicely in most
>>> cases. However, if a document has only one section, the tree is missing
>>> entirely.
>>>
>>
>> I ran into this also (with latest development version). Seems this is
>> the designed behavior. Looking at sphinx/builders/html.py I see the
>> following in def get_doc_context(self, docname, body, metatags):
> 
>>      # only display a TOC if there's more than one item to show
>>      display_toc = (self.env.toc_num_entries[docname] > 1),
>>
>> So, all I did was remove the surrounding
>>
>>   {%- if display_toc %}
>>   {%- endif %}
>>
> 
> That works for me too, thanks!
> 
> 
> But can anyone tell me the motivation behind this design? Why would I
> want a page without TOC just because there is only one section in it?

That is because by default, the TOC is a local TOC, and there it doesn't
make sense to display it if there's only one entry.

That said, the same error was in the "globaltoc" template for the sidebar
in sphinx trunk, so I've fixed that now.

cheers,
Georg

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

iEYEARECAAYFAku5m14ACgkQN9GcIYhpnLAp3QCdFG9eXqMmYUPpDebW0uBLvmPG
w+MAnjCLI5gZugol0/yUYzLGo73PQnWy
=an1O
-----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