Commits

WAKAYAMA shirou committed f2e09ad

add epub_show_urls option. This option is almost same as latex_show_urls.

Comments (0)

Files changed (3)

 
    .. versionadded:: 1.2
 
+.. confval:: epub_show_urls
+
+   Control whether to display URL addresses.  This is very useful for printed
+   copies of the manual.  The setting can have the following values:
+
+   * ``'no'`` -- do not display URLs (default)
+   * ``'inline'`` -- display URLs inline in parentheses
+
 
 .. _latex-options:
 

sphinx/builders/epub.py

                 newids.append(self.fix_fragment('', id))
             node.attributes['ids'] = newids
 
-    def add_visible_links(self, tree):
-        """Append visible link targets after external links."""
+    def add_visible_links(self, tree, show_urls='no'):
+        """Append visible link targets after external links"""
+        if not show_urls or show_urls == 'no':
+            return
+
         for node in tree.traverse(nodes.reference):
             uri = node.get('refuri', '')
             if (uri.startswith('http:') or uri.startswith('https:') or
                 uri = _link_target_template % {'uri': uri}
                 if uri:
                     idx = node.parent.index(node) + 1
-                    link = nodes.inline(uri, uri)
-                    link['classes'].append(_css_link_target_class)
-                    node.parent.insert(idx, link)
+                    if show_urls == 'inline':
+                        link = nodes.inline(uri, uri)
+                        link['classes'].append(_css_link_target_class)
+                        node.parent.insert(idx, link)
 
     def write_doc(self, docname, doctree):
         """Write one document file.
         and to add visible external links.
         """
         self.fix_ids(doctree)
-        self.add_visible_links(doctree)
+        self.add_visible_links(doctree, self.config.epub_show_urls)
         return StandaloneHTMLBuilder.write_doc(self, docname, doctree)
 
     def fix_genindex(self, tree):
         epub_tocdup = (True, 'env'),
         epub_fix_images = (False, 'env'),
         epub_max_image_width = (0, 'env'),
+        epub_show_urls = ('no', None),
 
         # LaTeX options
         latex_documents = (lambda self: [(self.master_doc,