From: Guenter M. <mi...@us...> - 2017-07-19 16:33:38
|
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 |