Starting to look at updating to the upcoming Sphinx v1.6, and I have a question about using a custom builder.--
We have a builder that is, effectively, a simple wrapper around the basic HTML builder. It would be nice to have the ability to provide this custom builder as an override to the built-in HTML builder. Is there a way in 1.6 to allow one to overload a built-in builder?I can do this:class MyBuilder(StandaloneHtmlBuilder):name = 'mybuilder'## the stuff I'm overriding on the standalone html builderdef setup(app):app.add_builder(MyBuilder)But I thought I could have done something like this, but Sphinx complains that the app 'Sphinx' has no registry attribute (which seems odd to me):class MyBuilder(StandaloneHtmlBuilder):name = 'html'## the stuff I'm overriding on the standalone html builderdef setup(app):app.registry.builder['html'] = MyBuilderIs there a reasonable way to override a built-in builder that re-uses the builder name, but uses the inheriting local class as the builder class? (The reason I'd like to re-use the builder name is that the Makefile support for sphinx understands the default builder names and makes decisions about where to put the output directory and so on, based on the builder name.)--Viktor Haag
You received this message because you are subscribed to the Google Groups "sphinx-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sphinx-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
- Because I want _nearly_ all the functionality in the HTML builder, but I want to make one tiny change, because of the way our local docs source works.
- Because we don't ever really want to build HTML stuff that does not use this tiny change, and our workflow scripts that do publishing of our docs know where the output for a build actually goes (into an "html" directory -- they would have to change if we had a different builder name; not a big change at all, but still, a change in the overall workflow).
class MyHtmlBuilder(StandaloneHtmlBuilder):name = 'html'# override get_doc_contextdef get_doc_context(self, docname, body, metatags):# local adjustments to the doc context for our own purposesdef setup(app):app.registry.builders['html'] = MyHtmlBuilder
Hi Viktor,
there are no way to override built-in builder. We just provide the way
to add new one.
In the first case you shown, you can build HTML with `sphinx-build -b
mybuilder ...` command.
How about rewriting your Makefile?
Thanks,
Takeshi KOMIYA