WAKAYAMA shirou avatar WAKAYAMA shirou committed f2e09ad

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

Comments (1)

  1. Roland Meister

    Also change sphinx/quickstart.py and add the new option (and maybe also doc/conf.py).

    Please change the default to 'inline'. The main target for the epub builder are imo standalone specialised ebook readers with cannot display the linked URL. This also keeps the current behaviour.

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:
  1. Roland Meister

    What about:

    Control whether to display URL addresses. This is very useful for readers that have no other means to display the linked URL. The settings 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,
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.