Re: Registering a transform that always runs, without attaching it to a custom component

Guenter Milde via Docutils-users <[email protected]> Fri, 15 Jan 2021 21:37:48 -0000 (UTC)
Newsgroups gmane.text.docutils.user
Message-ID <[email protected]>
On 2021-01-15, Clément Pit-Claudel wrote:
> On 1/15/21 6:18 AM, Guenter Milde via Docutils-users wrote:
>>> At the moment, users of the directive just call
>>> docutils.directives.register_directive('foo', FooDirective). 

>> Where is this done? A custom front-end?

> Exactly.

>>> How can I register a directive that always runs?

>>> I'm aware of the get_transform method on components, but I don't have a
>>> custom component; I'm just writing a directive.

>> I have never done this, but I'd try to get inspiration from the function
>> that processes the list returned by component.get_transform(). This is
>> transforms.Transformer.populate_from_components() where you will find::

>> So, maybe calling ::

>>   document.transformer.add_transform(FooTransform)

> This looks good, but how would I get a handle on the `document` object?

Here, you may have to re-create the working of the `publish_*()` function.
It may turn out that a custom component may be easier...
... or a post-processing step that removes not-required cache files.

Günter



_______________________________________________
Docutils-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/docutils-users

Please use "Reply All" to reply to the list.