How .. contents:: works

15 views
Skip to first unread message

Lisa Scheuplein

unread,
Jul 26, 2023, 11:20:19 AM7/26/23
to sphinx-users
I have looked at directives and this one is not listed in the documentation. The previous writer used it for a table of contents at the top of the page.

From what I can figure out, it pulls from the heading style, H1, and it puts a little TOC at the top of the page. 

Can someone confirm this is what I am seeing? Not sure why it is not in the documentation. I am a newbie to all this and figuring it out as I go along. 

.. contents::
   :local:
   :backlinks: none
   :depth: 1

Thank you.

Lisa

Doug Livezey

unread,
Jul 26, 2023, 2:01:29 PM7/26/23
to sphinx-users
i've always used the .. toc:: directive to build the table of contents. it grabs each of the H1, H2, H3 as far as your depth tells it to go. following the .. toc:: line there is a "contents" line which is the title for your table of contents. 

Lisa Scheuplein

unread,
Jul 26, 2023, 2:03:43 PM7/26/23
to sphinx...@googlegroups.com
Yeah, this is not the major left nav TOC, just one at the top of the page.

Just cannot find documentation on it.

--
You received this message because you are subscribed to the Google Groups "sphinx-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sphinx-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sphinx-users/7487d94b-3910-4976-9fb2-6125612b0975n%40googlegroups.com.

Slavko

unread,
Jul 26, 2023, 3:53:07 PM7/26/23
to sphinx...@googlegroups.com
Dňa 26. júla 2023 15:20:19 UTC používateľ Lisa Scheuplein <n1i...@gmail.com> napísal:
>I have looked at directives and this one is not listed in the
>documentation. The previous writer used it for a table of contents at the
>top of the page.

https://www.sphinx-doc.org/en/master/usage/restructuredtext/directives.html

regards


--
Slavko
https://www.slavino.sk/

Slavko

unread,
Jul 26, 2023, 4:01:01 PM7/26/23
to sphinx...@googlegroups.com
Dňa 26. júla 2023 19:53:04 UTC používateľ Slavko <li...@slavino.sk> napísal:
>Dňa 26. júla 2023 15:20:19 UTC používateľ Lisa Scheuplein <n1i...@gmail.com> napísal:
>>I have looked at directives and this one is not listed in the
>>documentation. The previous writer used it for a table of contents at the
>>top of the page.
>
>https://www.sphinx-doc.org/en/master/usage/restructuredtext/directives.html

Send too soon ;-)

https://docutils.sourceforge.io/docs/ref/rst/directives.html

Steevie

unread,
Jul 27, 2023, 2:38:58 AM7/27/23
to sphinx...@googlegroups.com
Hi,

On Wed, 26 Jul 2023 08:20:19 -0700 (PDT), Lisa Scheuplein wrote:

> I have looked at directives and this one is not listed in the
> documentation. The previous writer used it for a table of contents at
> the top of the page.
>
> From what I can figure out, it pulls from the heading style, H1, and it
> puts a little TOC at the top of the page.
>
> Can someone confirm this is what I am seeing? Not sure why it is not in
> the documentation. I am a newbie to all this and figuring it out as I go
> along.
There is a mention of contents:: in a note, the second you find in [1],
which explains its purpose:

"""To create table of contents for current document (.rst file), use the
standard reST contents directive."""

HTH,
Stefano
[1] https://www.sphinx-doc.org/en/master/usage/restructuredtext/
directives.html#table-of-contents

Lisa Scheuplein

unread,
Jul 27, 2023, 7:45:33 AM7/27/23
to sphinx...@googlegroups.com
Thank you. I am so visual, I searched for it via the format. Another issue I find with rst docs, is that the documentation does not speak much to required line spacing. So far, I refer to existing documents vs. The documentation to get formatting just right. I would love more tutorials in rst but have not located them. Lots out there on markdown, but not mush for rst.

Lisa

--
You received this message because you are subscribed to the Google Groups "sphinx-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sphinx-users...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages