-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Select Extensions on Build Type #3740
Comments
I think this contains two proposal. The first one is switching math extension for builders. The another is switching whole of extensions for builders. I think the first proposal is understandable and easy to improve. Because math extensions (imgmath, jsmath and mathjax) are used only to represent equations on HTML builders. The common part of the extensions (nodes, directives, representations for other builders and so on) is implemented as a library module named On the other hand, switching extensions by builders is hard. We have many types of extensions; builders, directives, transforms and so on. Some might work on reading phase, and some might on both reading and writing phase. But, in sphinx, the builder is determined at resolving phase. In addition, now we don't have to way to unload extensions. Anyway, we have to consider the advantage of switching. If it is worthy enough, we should do it. Any ideas? |
I have similar problems as well. However, my problem is not just formulas.
It is a common problem that all Sphinx extensions that generate diagrams have. The easiest way is to pass the 'buildername' to the Specifically, change here as follows. Conf_globals = confoverrides or {}.
Conf_globals ['__ buildername__'] = buildername
Self.config = Config (confdir, CONFIG_FILENAME,
Conf_globals, self.tags) This method is not elegant, but it is simple, easy and powerful. |
maybe exposing the builder in general to |
I'm sorry, I made a mistake in correcting it. If sphinx can pass if __buildername__ == "epub":
extensions += ['sphinx.ext.imgmath']
else:
extensions += ['sphinx.ext.mathjax'] Prepare PR if necessary. |
Hmm? Is that real problem of yours?
I'm worry about it breaks the incremental build feature of Sphinx. On the other hand, I still don't understand the advantages. |
I apologize for being confused by my poor English ability. Mermaid will output graphics in JavaScript as standard. I'd like to write like this in 'conf.py'.
I also want to separate the output for each builder with other extensions. appreciate the reply. |
a workaround I'm using for this is checking if 'epub' in sys.argv:
# configuration for epub |
@tk0miya just a ping: did you add something for math extension switching to the 1.7 release and I missed it? :) |
Sorry, nothing has changed yet because we determined to postpone this. New target release is 1.8. |
Ah sorry, I missed the modified milestone. Thanks for the heads-up! |
I just finished migration of math notations to sphinx-core in #4988. Thanks, |
This is great news, thank you! ✨ 🚀 |
Following #1570, there is currently no way to easily control enabling or disabling a sphinx extension based on the build type in
conf.py
.The concrete example I would like is building math via
sphinx.ext.imgmath
for epub but usingsphinx.ext.mathjax
for html. The rst macros/"interfaces" are compatible but the output is build-type specific.This is also troublesome when building on RTD since one can not switch extensions on and off depending on the build type (but can build HTML, pdf and epub on RTD).
The text was updated successfully, but these errors were encountered: