Re: publish_parts and table of contents?

Guenter Milde via Docutils-users <[email protected]>
Newsgroups gmane.text.docutils.user
Message-ID <[email protected]>
On 2017-07-19, Tony Narlock wrote:

> I’m getting there,

> I’ve overrides the Writer and added a new visitor attribute for “toc”.

> visitor_attributes = Writer.visitor_attributes + ('toc', )

> So “toc” should be collected during assemble_parts.

> From here, I want to inject the TOC the document into “toc”.

> There’s transforms.parts.Content(), but I’m not sure where and how I’d put
> it into play.

The transform generates the TOC by travelling the document tree after
parsing is complete.

A good representation of its output can be gained, if you create a
`minimal example` sample document, translate it to pseudoxml and examine
the result.

If the toc represents the logical structure you want to show in your output
document, fine. You can leave the transform as-is.
If not, explain the changes you think are necessary.

> There is also a directive for parsers.rst.directives.parts.Contents. I’m
> curious how I would go about injecting that.

This should be the class triggered by the ``.. contents::`` directive. It
will ensure the transform is called at the right time and does the right
thing.

> So how do you think I can go about that? Could you give me a code example
> to how I could get the equivalent of .. contents:: showing up in a “toc”
> part of writer?

Rather, you should provide a minimal working example showing what you want
to achieve (+ a diff between current and desired output).

Günter


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Docutils-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/docutils-users

Please use "Reply All" to reply to the list.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.