I have a Python package that defines custom Docutils directives and roles. It does not need a custom reader, writer, or parser: it just uses directives.register_directive
or roles.register_canonical_role
. Then, it runs transforms registered using nodes.pending
nodes.
These transforms take settings. What is the proper way to register them? One issue I'm running into is that although custom components can declare a settings_spec
, transforms cannot.
When I'm calling docutils myself, it's easy to use the settings_spec
provided by docutils.core.publish_*
.
But when I'm calling docutils through Sphinx, Pelican, Nikola, etc, I don't have control on that parameter. So, what is the recommended way to tell Docutils about these additional settings? Should I override the settings_spec
of the default OptionsParser
?
The "clean" way would be a custom parser component.
Sub-classing
docutils.parsers.rst.Parser
is easy,specifying the custom parser to the generic
docutils
CLI is easy, too,the tricky part may be to convince Sphinx, Pelican, Nikola, etc. to use it.