Registering a transform that always runs, without attaching it to a custom component
Clément Pit-Claudel <[email protected]> Thu, 14 Jan 2021 16:17:29 -0500
| Newsgroups | gmane.text.docutils.user |
|---|---|
| Message-ID | <[email protected]> |
Hi there,
I have a custom directive FooDirective. It creates a custom pending node to run FooTransform. FooTransform gathers all pending foo nodes and applies a transformation.
The results are cached in a file, because the transformation runs costly computations.
At the moment, users of the directive just call docutils.directives.register_directive('foo', FooDirective). There's one problem: I don't have any 'foo's in the document, the cache should be cleared. But, with no 'foo's, no pending node is added and the transform isn't executed; hence, the cache isn't cleared.
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.
In Sphinx I'd use app.add_transform; is there a Docutils equivalent?
Or is there a better way to do this?
Thanks!