From d91fd33de5aabc8ba3257cbf061a1d62ceb1f625 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Wed, 2 Mar 2016 22:58:17 +0900 Subject: [PATCH] Rename ``\internalreference`` to ``\crossref`` --- CHANGES | 2 +- sphinx/texinputs/sphinx.sty | 2 +- sphinx/writers/latex.py | 2 +- tests/test_build_latex.py | 30 +++++++++++++----------------- 4 files changed, 16 insertions(+), 20 deletions(-) diff --git a/CHANGES b/CHANGES index 91d3caf01..4bbe2ea01 100644 --- a/CHANGES +++ b/CHANGES @@ -15,7 +15,7 @@ Features added * #2340: Math extension: support alignment of multiple equations for MathJAX. * #2338: Define ``\titlereference`` macro to redefine the style of ``title-reference`` roles. * Define ``\menuselection`` and ``\accelerator`` macros to redefine the style of `menuselection` roles. -* Define ``\internalreference`` macro to redefine the style of references +* Define ``\crossref`` macro to redefine the style of references * #2301: Texts in the classic html theme should be hyphenated. * #2355: Define ``\termref`` macro to redefine the style of ``term`` roles. diff --git a/sphinx/texinputs/sphinx.sty b/sphinx/texinputs/sphinx.sty index 12c35dd58..565f62924 100644 --- a/sphinx/texinputs/sphinx.sty +++ b/sphinx/texinputs/sphinx.sty @@ -149,7 +149,7 @@ \newcommand{\titlereference}[1]{\emph{#1}} \newcommand{\menuselection}[1]{\emph{#1}} \newcommand{\accelerator}[1]{\underline{#1}} -\newcommand{\internalreference}[1]{\emph{#1}} +\newcommand{\crossref}[1]{\emph{#1}} \newcommand{\termref}[1]{\emph{#1}} % Redefine the Verbatim environment to allow border and background colors. diff --git a/sphinx/writers/latex.py b/sphinx/writers/latex.py index 21152a545..3f04bf83d 100644 --- a/sphinx/writers/latex.py +++ b/sphinx/writers/latex.py @@ -1624,7 +1624,7 @@ class LaTeXTranslator(nodes.NodeVisitor): # mark up as termreference self.body.append(r'\termref{') else: - self.body.append(r'\internalreference{') + self.body.append(r'\crossref{') if self.builder.config.latex_show_pagerefs and not \ self.in_production_list: self.context.append('}}} (%s)' % self.hyperpageref(id)) diff --git a/tests/test_build_latex.py b/tests/test_build_latex.py index ea1468c2e..f8ba47c1b 100644 --- a/tests/test_build_latex.py +++ b/tests/test_build_latex.py @@ -397,7 +397,7 @@ def test_footnote(app, status, warning): assert '\\footnote[1]{\nnumbered\n}' in result assert '\\footnote[2]{\nauto numbered\n}' in result assert '\\footnote[3]{\nnamed\n}' in result - assert '{\\hyperref[footnote:bar]{\\internalreference{{[}bar{]}}}}' in result + assert '{\\hyperref[footnote:bar]{\\crossref{{[}bar{]}}}}' in result assert '\\bibitem[bar]{bar}{\\phantomsection\\label{footnote:bar} ' in result assert '\\bibitem[bar]{bar}{\\phantomsection\\label{footnote:bar} \ncite' in result assert '\\bibitem[bar]{bar}{\\phantomsection\\label{footnote:bar} \ncite\n}' in result @@ -416,8 +416,7 @@ def test_reference_in_caption(app, status, warning): print(status.getvalue()) print(warning.getvalue()) assert ('\\caption{This is the figure caption with a reference to \\label{index:id2}' - '{\\hyperref[index:authoryear]{\\internalreference{{[}AuthorYear{]}}}}.}' - in result) + '{\\hyperref[index:authoryear]{\\crossref{{[}AuthorYear{]}}}}.}' in result) assert '\\chapter{The section with a reference to {[}AuthorYear{]}}' in result assert '\\caption{The table title with a reference to {[}AuthorYear{]}}' in result assert '\\paragraph{The rubric title with a reference to {[}AuthorYear{]}}' in result @@ -446,12 +445,11 @@ def test_latex_show_urls_is_inline(app, status, warning): assert 'Auto footnote number \\footnote[1]{\nfootnote in baz\n} in baz.rst' in result assert ('\\phantomsection\\label{index:id26}{\\hyperref[index:the\\string-section' '\\string-with\\string-a\\string-reference\\string-to\\string-authoryear]' - '{\\internalreference{The section with a reference to \\phantomsection' - '\\label{index:id1}{\\hyperref[index:authoryear]{\\internalreference' - '{{[}AuthorYear{]}}}}}}}' in result) + '{\\crossref{The section with a reference to \\phantomsection\\label{index:id1}' + '{\\hyperref[index:authoryear]{\\crossref{{[}AuthorYear{]}}}}}}}' in result) assert ('\\phantomsection\\label{index:id27}{\\hyperref[index:the\\string-section' '\\string-with\\string-a\\string-reference\\string-to]' - '{\\internalreference{The section with a reference to }}}' in result) + '{\\crossref{The section with a reference to }}}' in result) assert 'First footnote: \\footnote[2]{\nFirst\n}' in result assert 'Second footnote: \\footnote[1]{\nSecond\n}' in result assert '\\href{http://sphinx-doc.org/}{Sphinx} (http://sphinx-doc.org/)' in result @@ -482,12 +480,11 @@ def test_latex_show_urls_is_footnote(app, status, warning): assert 'Auto footnote number \\footnote[2]{\nfootnote in baz\n} in baz.rst' in result assert ('\\phantomsection\\label{index:id26}{\\hyperref[index:the\\string-section' '\\string-with\\string-a\\string-reference\\string-to\\string-authoryear]' - '{\\internalreference{The section with a reference to \\phantomsection' - '\\label{index:id1}{\\hyperref[index:authoryear]{\\internalreference' - '{{[}AuthorYear{]}}}}}}}' in result) + '{\\crossref{The section with a reference to \\phantomsection\\label{index:id1}' + '{\\hyperref[index:authoryear]{\\crossref{{[}AuthorYear{]}}}}}}}' in result) assert ('\\phantomsection\\label{index:id27}{\\hyperref[index:the\\string-section' - '\\string-with\\string-a\\string-reference\\string-to]{\\internalreference' - '{The section with a reference to }}}' in result) + '\\string-with\\string-a\\string-reference\\string-to]' + '{\\crossref{The section with a reference to }}}' in result) assert 'First footnote: \\footnote[3]{\nFirst\n}' in result assert 'Second footnote: \\footnote[1]{\nSecond\n}' in result assert ('\\href{http://sphinx-doc.org/}{Sphinx}' @@ -520,12 +517,11 @@ def test_latex_show_urls_is_no(app, status, warning): assert 'Auto footnote number \\footnote[1]{\nfootnote in baz\n} in baz.rst' in result assert ('\\phantomsection\\label{index:id26}{\\hyperref[index:the\\string-section' '\\string-with\\string-a\\string-reference\\string-to\\string-authoryear]' - '{\\internalreference{The section with a reference to \\phantomsection' - '\\label{index:id1}{\\hyperref[index:authoryear]{\\internalreference' - '{{[}AuthorYear{]}}}}}}}' in result) + '{\\crossref{The section with a reference to \\phantomsection\\label{index:id1}' + '{\\hyperref[index:authoryear]{\\crossref{{[}AuthorYear{]}}}}}}}' in result) assert ('\\phantomsection\\label{index:id27}{\\hyperref[index:the\\string-section' - '\\string-with\\string-a\\string-reference\\string-to]{\\internalreference' - '{The section with a reference to }}}' in result) + '\\string-with\\string-a\\string-reference\\string-to]' + '{\\crossref{The section with a reference to }}}' in result) assert 'First footnote: \\footnote[2]{\nFirst\n}' in result assert 'Second footnote: \\footnote[1]{\nSecond\n}' in result assert '\\href{http://sphinx-doc.org/}{Sphinx}' in result