Commits

Takayuki Shimizukawa  committed 2d56486 Merge

Merged in rolmei/sphinx-epub (pull request #123)

epub_use_index instead of html_use_index for epub builder (Issue #1106)

  • Participants
  • Parent commits 2f5ccd5, 2875621

Comments (0)

Files changed (7)

 epub_fix_images = False
 epub_max_image_width = 0
 epub_show_urls = 'inline'
+epub_use_index = False
 
 latex_documents = [('contents', 'sphinx.tex', 'Sphinx Documentation',
                     'Georg Brandl', 'manual', 1)]

File doc/config.rst

 
    .. versionadded:: 1.2
 
+.. confval:: epub_use_index
+
+   If true, add an index to the epub document.  It defaults to the
+   :confval:`html_use_index` option but can be set independently for epub
+   creation.
 
 .. _latex-options:
 

File sphinx/builders/__init__.py

         """
         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'),

File sphinx/builders/epub.py

             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))
             })

File sphinx/builders/html.py

         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
                 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

File sphinx/config.py

         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,

File sphinx/quickstart.py

 
 # 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'''