mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge with http://bitbucket.org/chrism/sphinx/, add latex_show_pagrefs/latex_show_urls config values.
This commit is contained in:
1
CHANGES
1
CHANGES
@@ -72,6 +72,7 @@ Features added
|
|||||||
- Added the ``trim_doctest_flags`` config value, which is true by
|
- Added the ``trim_doctest_flags`` config value, which is true by
|
||||||
default.
|
default.
|
||||||
- Added ``html_show_copyright`` config value.
|
- Added ``html_show_copyright`` config value.
|
||||||
|
- Added ``latex_show_pagerefs`` and ``latex_show_urls`` config values.
|
||||||
|
|
||||||
* New builders:
|
* New builders:
|
||||||
|
|
||||||
|
|||||||
@@ -852,6 +852,20 @@ These options influence LaTeX output.
|
|||||||
.. deprecated:: 1.0
|
.. deprecated:: 1.0
|
||||||
Use :confval:`latex_domain_indices`.
|
Use :confval:`latex_domain_indices`.
|
||||||
|
|
||||||
|
.. confval:: latex_show_pagerefs
|
||||||
|
|
||||||
|
If true, add page references after internal references. This is very useful
|
||||||
|
for printed copies of the manual. Default is ``False``.
|
||||||
|
|
||||||
|
.. versionadded:: 1.0
|
||||||
|
|
||||||
|
.. confval:: latex_show_urls
|
||||||
|
|
||||||
|
If true, add URL addresses after links. This is very useful for printed
|
||||||
|
copies of the manual. Default is ``False``.
|
||||||
|
|
||||||
|
.. versionadded:: 1.0
|
||||||
|
|
||||||
.. confval:: latex_elements
|
.. confval:: latex_elements
|
||||||
|
|
||||||
.. versionadded:: 0.5
|
.. versionadded:: 0.5
|
||||||
|
|||||||
@@ -132,6 +132,8 @@ class Config(object):
|
|||||||
latex_use_parts = (False, None),
|
latex_use_parts = (False, None),
|
||||||
latex_use_modindex = (True, None), # deprecated
|
latex_use_modindex = (True, None), # deprecated
|
||||||
latex_domain_indices = (True, None),
|
latex_domain_indices = (True, None),
|
||||||
|
latex_show_urls = (False, None),
|
||||||
|
latex_show_pagerefs = (False, None),
|
||||||
# paper_size and font_size are still separate values
|
# paper_size and font_size are still separate values
|
||||||
# so that you can give them easily on the command line
|
# so that you can give them easily on the command line
|
||||||
latex_paper_size = ('letter', None),
|
latex_paper_size = ('letter', None),
|
||||||
|
|||||||
@@ -216,6 +216,12 @@ latex_documents = [
|
|||||||
# not chapters.
|
# not chapters.
|
||||||
#latex_use_parts = False
|
#latex_use_parts = False
|
||||||
|
|
||||||
|
# If true, show page references after internal links.
|
||||||
|
#latex_show_pagerefs = False
|
||||||
|
|
||||||
|
# If true, show URL addresses after external links.
|
||||||
|
#latex_show_urls = False
|
||||||
|
|
||||||
# Additional stuff for the LaTeX preamble.
|
# Additional stuff for the LaTeX preamble.
|
||||||
#latex_preamble = ''
|
#latex_preamble = ''
|
||||||
|
|
||||||
|
|||||||
@@ -252,6 +252,9 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
|||||||
def hyperlink(self, id):
|
def hyperlink(self, id):
|
||||||
return '\\hyperref[%s]{' % (self.idescape(id))
|
return '\\hyperref[%s]{' % (self.idescape(id))
|
||||||
|
|
||||||
|
def hyperpageref(self, id):
|
||||||
|
return '\\autopageref*{%s}' % (self.idescape(id))
|
||||||
|
|
||||||
def idescape(self, id):
|
def idescape(self, id):
|
||||||
return str(unicode(id).translate(tex_replace_map))
|
return str(unicode(id).translate(tex_replace_map))
|
||||||
|
|
||||||
@@ -1027,14 +1030,24 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
|||||||
if self.in_title or not uri:
|
if self.in_title or not uri:
|
||||||
self.context.append('')
|
self.context.append('')
|
||||||
elif uri.startswith('mailto:') or uri.startswith('http:') or \
|
elif uri.startswith('mailto:') or uri.startswith('http:') or \
|
||||||
uri.startswith('https:') or uri.startswith('ftp:'):
|
uri.startswith('https:') or uri.startswith('ftp:'):
|
||||||
self.body.append('\\href{%s}{' % self.encode_uri(uri))
|
self.body.append('\\href{%s}{' % self.encode_uri(uri))
|
||||||
self.context.append('}')
|
# if configured, put the URL after the link
|
||||||
|
if self.builder.config.latex_show_urls and \
|
||||||
|
node.astext() != uri:
|
||||||
|
if uri.startswith('mailto:'):
|
||||||
|
uri = uri[7:]
|
||||||
|
self.context.append('} (%s)' % self.encode_uri(uri))
|
||||||
|
else:
|
||||||
|
self.context.append('}')
|
||||||
elif uri.startswith('#'):
|
elif uri.startswith('#'):
|
||||||
# references to labels in the same document
|
# references to labels in the same document
|
||||||
self.body.append(self.hyperlink(self.curfilestack[-1] +
|
id = self.curfilestack[-1] + ':' + uri[1:]
|
||||||
':' + uri[1:]))
|
self.body.append(self.hyperlink(id))
|
||||||
self.context.append('}')
|
if self.builder.config.latex_show_pagerefs:
|
||||||
|
self.context.append('} (%s)' % self.hyperpageref(id))
|
||||||
|
else:
|
||||||
|
self.context.append('}')
|
||||||
elif uri.startswith('%'):
|
elif uri.startswith('%'):
|
||||||
# references to documents or labels inside documents
|
# references to documents or labels inside documents
|
||||||
hashindex = uri.find('#')
|
hashindex = uri.find('#')
|
||||||
@@ -1045,7 +1058,14 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
|||||||
# reference to a label
|
# reference to a label
|
||||||
id = uri[1:].replace('#', ':')
|
id = uri[1:].replace('#', ':')
|
||||||
self.body.append(self.hyperlink(id))
|
self.body.append(self.hyperlink(id))
|
||||||
self.context.append('}')
|
if len(node) and 'std-term' in node[0].get('classes', []):
|
||||||
|
# don't add a pageref for glossary terms
|
||||||
|
self.context.append('}')
|
||||||
|
else:
|
||||||
|
if self.builder.config.latex_show_pagerefs:
|
||||||
|
self.context.append('} (%s)' % self.hyperpageref(id))
|
||||||
|
else:
|
||||||
|
self.context.append('}')
|
||||||
elif uri.startswith('@token'):
|
elif uri.startswith('@token'):
|
||||||
if self.in_production_list:
|
if self.in_production_list:
|
||||||
self.body.append('\\token{')
|
self.body.append('\\token{')
|
||||||
|
|||||||
Reference in New Issue
Block a user