File tree Expand file tree Collapse file tree 1 file changed +24
-2
lines changed Expand file tree Collapse file tree 1 file changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -58,6 +58,25 @@ def get_override_language_or_en() -> str:
5858 return get_override_language () or "en"
5959
6060
61+ @functools .lru_cache (maxsize = None )
62+ def get_is_building_epub () -> bool :
63+ """Tries to detect the output format from `argv`."""
64+ # override_lang = None
65+ target_builder = None
66+ args = deque (sys .argv )
67+ args .popleft ()
68+ while len (args ) > 0 :
69+ # if args.popleft() != '-M':
70+ # continue
71+ thisarg = args .popleft ()
72+ if thisarg != '-M' and thisarg != '-b' :
73+ continue
74+ if target_builder :
75+ raise ValueError ("Target builder arg found more than once, don't know how to handle this!" )
76+ target_builder = args .popleft ()
77+ return target_builder == "epub"
78+
79+
6180# Get the git description if possible, to put it in the footer.
6281
6382try :
@@ -96,8 +115,11 @@ def get_override_language_or_en() -> str:
96115 'sphinx.ext.githubpages' ,
97116]
98117
99- # Add any paths that contain templates here, relative to this directory.
100- templates_path = [ 'theme' ]
118+ if get_is_building_epub ():
119+ templates_path = []
120+ else :
121+ # Add any paths that contain templates here, relative to this directory.
122+ templates_path = [ 'theme' ]
101123
102124# The suffix(es) of source filenames.
103125# You can specify multiple suffix as a list of string:
You can’t perform that action at this time.
0 commit comments