summaryrefslogtreecommitdiff
path: root/sphinx
diff options
context:
space:
mode:
authorRoland Meister <devnull@localhost>2013-03-06 18:43:21 +0100
committerRoland Meister <devnull@localhost>2013-03-06 18:43:21 +0100
commitd08df2a099199517de3ab333af86d30d2b7b4d38 (patch)
tree3b731c5d31a7f1e708a43744d639fd4868538212 /sphinx
parentd61c077fbcacedf0e2ec0940f28a4808cd8d6d02 (diff)
downloadsphinx-d08df2a099199517de3ab333af86d30d2b7b4d38.tar.gz
epub_use_index instead of html_use_index for epub builder (Issue #1106)
The change adds the method get_builder_config. This allows use of the option epub_use_index instead of html_use_index for epub output.
Diffstat (limited to 'sphinx')
-rw-r--r--sphinx/builders/__init__.py15
-rw-r--r--sphinx/builders/epub.py2
-rw-r--r--sphinx/builders/html.py4
-rw-r--r--sphinx/config.py1
-rw-r--r--sphinx/quickstart.py3
5 files changed, 22 insertions, 3 deletions
diff --git a/sphinx/builders/__init__.py b/sphinx/builders/__init__.py
index 97932c4c..58c338a0 100644
--- a/sphinx/builders/__init__.py
+++ b/sphinx/builders/__init__.py
@@ -318,6 +318,21 @@ class Builder(object):
"""
pass
+ def get_builder_config(self, option, default):
+ """Return a builder specific option.
+
+ This method allows customization of common builder settings by
+ inserting the name of the current builder in the option key.
+ If the key does not exist, use default as builder name.
+ """
+ # At the moment, only XXX_use_index is looked up this way.
+ # Every new builder variant must be registered in Config.config_values.
+ try:
+ optname = '%s_%s' % (self.name, option)
+ return getattr(self.config, optname)
+ except AttributeError:
+ optname = '%s_%s' % (default, option)
+ return getattr(self.config, optname)
BUILTIN_BUILDERS = {
'html': ('html', 'StandaloneHTMLBuilder'),
diff --git a/sphinx/builders/epub.py b/sphinx/builders/epub.py
index 6803753b..389f29a4 100644
--- a/sphinx/builders/epub.py
+++ b/sphinx/builders/epub.py
@@ -489,7 +489,7 @@ class EpubBuilder(StandaloneHTMLBuilder):
spine.append(_spine_template % {
'idref': self.esc(self.make_id(info[0] + self.out_suffix))
})
- if self.config.html_use_index:
+ if self.get_builder_config('use_index', 'epub'):
spine.append(_spine_template % {
'idref': self.esc(self.make_id('genindex' + self.out_suffix))
})
diff --git a/sphinx/builders/html.py b/sphinx/builders/html.py
index 1d1dfa79..198824ee 100644
--- a/sphinx/builders/html.py
+++ b/sphinx/builders/html.py
@@ -308,7 +308,7 @@ class StandaloneHTMLBuilder(Builder):
self.relations = self.env.collect_relations()
rellinks = []
- if self.config.html_use_index:
+ if self.get_builder_config('use_index', 'html'):
rellinks.append(('genindex', _('General Index'), 'I', _('index')))
for indexname, indexcls, content, collapse in self.domain_indices:
# if it has a short name
@@ -451,7 +451,7 @@ class StandaloneHTMLBuilder(Builder):
self.handle_page(pagename, context, template)
# the global general index
- if self.config.html_use_index:
+ if self.get_builder_config('use_index', 'html'):
self.write_genindex()
# the global domain-specific indices
diff --git a/sphinx/config.py b/sphinx/config.py
index 2e548986..496ce77f 100644
--- a/sphinx/config.py
+++ b/sphinx/config.py
@@ -143,6 +143,7 @@ class Config(object):
epub_fix_images = (False, 'env'),
epub_max_image_width = (0, 'env'),
epub_show_urls = ('inline', 'html'),
+ epub_use_index = (lambda self: self.html_use_index, 'html'),
# LaTeX options
latex_documents = (lambda self: [(self.master_doc,
diff --git a/sphinx/quickstart.py b/sphinx/quickstart.py
index 2184ba61..bfc6d723 100644
--- a/sphinx/quickstart.py
+++ b/sphinx/quickstart.py
@@ -343,6 +343,9 @@ epub_copyright = u'%(copyright_str)s'
# If 'no', URL addresses will not be shown.
#epub_show_urls = 'inline'
+
+# If false, no index is generated.
+#epub_use_index = True
'''
INTERSPHINX_CONFIG = u'''