mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge pull request #9578 from marxin/texinfo-add-texinfo_emit_document_references
texinfo: simplify reference emission.
This commit is contained in:
commit
18328981a1
4
doc/_static/conf.py.txt
vendored
4
doc/_static/conf.py.txt
vendored
@ -319,6 +319,10 @@ texinfo_documents = [
|
||||
#
|
||||
# texinfo_no_detailmenu = False
|
||||
|
||||
# If false, do not generate in manual @ref nodes.
|
||||
#
|
||||
# texinfo_cross_references = False
|
||||
|
||||
# -- A random example -----------------------------------------------------
|
||||
|
||||
import sys, os
|
||||
|
@ -299,6 +299,10 @@ appear in the source. Emacs, on the other-hand, will by default replace
|
||||
|
||||
:ref:`texinfo-links`
|
||||
|
||||
One can disable generation of the inline references in a document
|
||||
with :confval:`texinfo_cross_references`. That makes
|
||||
an info file more readable with stand-alone reader (``info``).
|
||||
|
||||
The exact behavior of how Emacs displays references is dependent on the variable
|
||||
``Info-hide-note-references``. If set to the value of ``hide``, Emacs will hide
|
||||
both the ``*note:`` part and the ``target-id``. This is generally the best way
|
||||
|
@ -2499,6 +2499,13 @@ These options influence Texinfo output.
|
||||
|
||||
.. versionadded:: 1.1
|
||||
|
||||
.. confval:: texinfo_cross_references
|
||||
|
||||
If false, do not generate inline references in a document. That makes
|
||||
an info file more readable with stand-alone reader (``info``).
|
||||
Default is ``True``.
|
||||
|
||||
.. versionadded:: 4.4
|
||||
|
||||
.. _qthelp-options:
|
||||
|
||||
|
@ -211,6 +211,7 @@ def setup(app: Sphinx) -> Dict[str, Any]:
|
||||
app.add_config_value('texinfo_domain_indices', True, None, [list])
|
||||
app.add_config_value('texinfo_show_urls', 'footnote', None)
|
||||
app.add_config_value('texinfo_no_detailmenu', False, None)
|
||||
app.add_config_value('texinfo_cross_references', True, None)
|
||||
|
||||
return {
|
||||
'version': 'builtin',
|
||||
|
@ -546,9 +546,12 @@ class TexinfoTranslator(SphinxTranslator):
|
||||
def add_xref(self, id: str, name: str, node: Node) -> None:
|
||||
name = self.escape_menu(name)
|
||||
sid = self.get_short_id(id)
|
||||
self.body.append('@ref{%s,,%s}' % (sid, name))
|
||||
self.referenced_ids.add(sid)
|
||||
self.referenced_ids.add(self.escape_id(id))
|
||||
if self.config.texinfo_cross_references:
|
||||
self.body.append('@ref{%s,,%s}' % (sid, name))
|
||||
self.referenced_ids.add(sid)
|
||||
self.referenced_ids.add(self.escape_id(id))
|
||||
else:
|
||||
self.body.append(name)
|
||||
|
||||
# -- Visiting
|
||||
|
||||
|
@ -114,6 +114,20 @@ def test_texinfo_escape_id(app, status, warning):
|
||||
assert translator.escape_id('.') == '.'
|
||||
|
||||
|
||||
@pytest.mark.sphinx('texinfo')
|
||||
def test_texinfo_xrefs(app, status, warning):
|
||||
app.builder.build_all()
|
||||
output = (app.outdir / 'sphinxtests.texi').read_text()
|
||||
assert re.search(r'@ref{\w+,,--plugin\.option}', output)
|
||||
|
||||
# Now rebuild it without xrefs
|
||||
app.config.texinfo_cross_references = False
|
||||
app.builder.build_all()
|
||||
output = (app.outdir / 'sphinxtests.texi').read_text()
|
||||
assert not re.search(r'@ref{\w+,,--plugin\.option}', output)
|
||||
assert 'Link to perl +p, --ObjC++, --plugin.option, create-auth-token, arg and -j' in output
|
||||
|
||||
|
||||
@pytest.mark.sphinx('texinfo', testroot='root')
|
||||
def test_texinfo_samp_with_variable(app, status, warning):
|
||||
app.build()
|
||||
|
Loading…
Reference in New Issue
Block a user