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

ClĂ©ment Pit-Claudel <[email protected]> Fri, 15 Jan 2021 13:00:51 -0500
Newsgroups gmane.text.docutils.user
Message-ID <[email protected]>
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?