From 07cc02a512923610eac65ff5cb23c8b6a9fc44ed Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sun, 27 Dec 2015 16:29:07 +0900 Subject: [PATCH 01/48] Fix #2178: Unparseable C++ cross-reference when referencing a function with :cpp:any: --- CHANGES | 1 + sphinx/domains/cpp.py | 12 ++++++ tests/roots/test-domain-cpp/any-role.rst | 10 +++++ tests/roots/test-domain-cpp/conf.py | 4 ++ tests/roots/test-domain-cpp/index.rst | 37 ++++++++++++++++++ tests/roots/test-domain-cpp/roles.rst | 10 +++++ tests/test_domain_cpp.py | 50 +++++++++++++++++++++++- 7 files changed, 123 insertions(+), 1 deletion(-) create mode 100644 tests/roots/test-domain-cpp/any-role.rst create mode 100644 tests/roots/test-domain-cpp/conf.py create mode 100644 tests/roots/test-domain-cpp/index.rst create mode 100644 tests/roots/test-domain-cpp/roles.rst diff --git a/CHANGES b/CHANGES index 561d0f45c..5e3fbc71b 100644 --- a/CHANGES +++ b/CHANGES @@ -21,6 +21,7 @@ Bugs fixed * #2071: Fix same footnote in more than two section titles => LaTeX/PDF Bug * #2040: Fix UnicodeDecodeError in sphinx-apidoc when author contains non-ascii characters * #2193: Fix shutil.SameFileError if source directory and destination directory are same +* #2178: Fix unparseable C++ cross-reference when referencing a function with :cpp:any: Release 1.3.3 (released Dec 2, 2015) diff --git a/sphinx/domains/cpp.py b/sphinx/domains/cpp.py index 09c2204d5..69b99d269 100644 --- a/sphinx/domains/cpp.py +++ b/sphinx/domains/cpp.py @@ -2659,6 +2659,9 @@ class CPPXRefRole(XRefRole): parent = env.ref_context.get('cpp:parent') if parent: refnode['cpp:parent'] = parent[:] + if refnode['reftype'] == 'any': + # Remove parentheses from the target (not from title) + title, target = self._fix_parens(env, True, title, target) if not has_explicit_title: target = target.lstrip('~') # only has a meaning for the title # if the first character is a tilde, don't display the module/class @@ -2731,6 +2734,15 @@ class CPPDomain(Domain): if name not in self.data['objects']: return None, None docname, ast = self.data['objects'][name] + if node['reftype'] == 'any' and ast.objectType == 'function': + title = contnode.pop(0).astext() + if title.endswith('()'): + # remove parentheses + title = title[:-2] + if env.config.add_function_parentheses: + # add them back to all occurrences if configured + title += '()' + contnode.insert(0, nodes.Text(title)) return make_refnode(builder, fromdocname, docname, ast.newestId, contnode, name), ast.objectType diff --git a/tests/roots/test-domain-cpp/any-role.rst b/tests/roots/test-domain-cpp/any-role.rst new file mode 100644 index 000000000..dacd2f600 --- /dev/null +++ b/tests/roots/test-domain-cpp/any-role.rst @@ -0,0 +1,10 @@ +any role +-------- + +* :cpp:any:`Sphinx` +* ref function without parens :cpp:any:`hello`. +* ref function with parens :cpp:any:`hello()`. +* :cpp:any:`Sphinx::version` +* :cpp:any:`version` +* :cpp:any:`List` +* :cpp:any:`MyEnum` diff --git a/tests/roots/test-domain-cpp/conf.py b/tests/roots/test-domain-cpp/conf.py new file mode 100644 index 000000000..cf05c9b5c --- /dev/null +++ b/tests/roots/test-domain-cpp/conf.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- + +master_doc = 'index' +html_theme = 'classic' diff --git a/tests/roots/test-domain-cpp/index.rst b/tests/roots/test-domain-cpp/index.rst new file mode 100644 index 000000000..9be739f1e --- /dev/null +++ b/tests/roots/test-domain-cpp/index.rst @@ -0,0 +1,37 @@ +test-domain-cpp +=============== + +directives +---------- + +.. cpp:class:: public Sphinx + + The description of Sphinx class. + +.. cpp:function:: int hello(char *name) + + The description of hello function. + +.. cpp:member:: float Sphinx::version + + The description of Sphinx::version. + +.. cpp:var:: int version + + The description of version. + +.. cpp:type:: std::vector List + + The description of List type. + +.. cpp:enum:: MyEnum + + An unscoped enum. + +.. cpp:enum-class:: MyScopedEnum + + A scoped enum. + +.. cpp:enum-struct:: protected MyScopedVisibilityEnum : std::underlying_type::type + + A scoped enum with non-default visibility, and with a specified underlying type. diff --git a/tests/roots/test-domain-cpp/roles.rst b/tests/roots/test-domain-cpp/roles.rst new file mode 100644 index 000000000..8baf29b4c --- /dev/null +++ b/tests/roots/test-domain-cpp/roles.rst @@ -0,0 +1,10 @@ +roles +----- + +* :cpp:class:`Sphinx` +* ref function without parens :cpp:func:`hello`. +* ref function with parens :cpp:func:`hello()`. +* :cpp:member:`Sphinx::version` +* :cpp:var:`version` +* :cpp:type:`List` +* :cpp:enum:`MyEnum` diff --git a/tests/test_domain_cpp.py b/tests/test_domain_cpp.py index 886fe8031..6975d7ab2 100644 --- a/tests/test_domain_cpp.py +++ b/tests/test_domain_cpp.py @@ -9,9 +9,11 @@ :license: BSD, see LICENSE for details. """ +import re + from six import text_type -from util import raises +from util import raises, with_app from sphinx.domains.cpp import DefinitionParser, DefinitionError, NoOldIdError @@ -262,3 +264,49 @@ def test_operators(): # for a in ids: # print(a) # raise DefinitionError("") + + +@with_app(testroot='domain-cpp') +def test_build_domain_cpp(app, status, warning): + app.builder.build_all() + + roles = (app.outdir / 'roles.html').text() + assert re.search('
  • Sphinx
  • ', roles) + assert re.search(('
  • ref function without parens ' + 'hello\(\)\.
  • '), roles) + assert re.search(('
  • ref function with parens ' + 'hello\(\)\.
  • '), roles) + assert re.search('
  • Sphinx::version
  • ', + roles) + assert re.search('
  • version
  • ', roles) + assert re.search('
  • List
  • ', roles) + assert re.search('
  • MyEnum
  • ', roles) + + any_role = (app.outdir / 'any-role.html').text() + assert re.search('
  • Sphinx
  • ', any_role) + assert re.search(('
  • ref function without parens ' + 'hello\(\)\.
  • '), any_role) + assert re.search(('
  • ref function with parens ' + 'hello\(\)\.
  • '), any_role) + assert re.search('
  • Sphinx::version
  • ', + any_role) + assert re.search('
  • version
  • ', any_role) + assert re.search('
  • List
  • ', any_role) + assert re.search('
  • MyEnum
  • ', any_role) + + +@with_app(testroot='domain-cpp', confoverrides={'add_function_parentheses': False}) +def test_build_domain_cpp_with_add_function_parentheses_is_False(app, status, warning): + app.builder.build_all() + + roles = (app.outdir / 'roles.html').text() + assert re.search(('
  • ref function without parens ' + 'hello\.
  • '), roles) + assert re.search(('
  • ref function with parens ' + 'hello\.
  • '), roles) + + any_role = (app.outdir / 'any-role.html').text() + assert re.search(('
  • ref function without parens ' + 'hello\.
  • '), any_role) + assert re.search(('
  • ref function with parens ' + 'hello\.
  • '), any_role) From 584f05154bdce3c5c4eef3105b50fb9d5c28cc68 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Fri, 1 Jan 2016 17:28:22 +0900 Subject: [PATCH 02/48] Fix #2206: Sphinx latex doc build failed if footnotes in caption of figure At same time, refactored around pending footnotes (tables, terms and figures). They are all controled as ``pending_footnotes``. --- CHANGES | 1 + sphinx/writers/latex.py | 45 +++++++++++++++------------- tests/roots/test-footnotes/index.rst | 6 ++++ tests/test_build_latex.py | 13 ++++---- 4 files changed, 39 insertions(+), 26 deletions(-) diff --git a/CHANGES b/CHANGES index 5e3fbc71b..169e17de0 100644 --- a/CHANGES +++ b/CHANGES @@ -22,6 +22,7 @@ Bugs fixed * #2040: Fix UnicodeDecodeError in sphinx-apidoc when author contains non-ascii characters * #2193: Fix shutil.SameFileError if source directory and destination directory are same * #2178: Fix unparseable C++ cross-reference when referencing a function with :cpp:any: +* #2206: Fix Sphinx latex doc build failed due to a footnotes Release 1.3.3 (released Dec 2, 2015) diff --git a/sphinx/writers/latex.py b/sphinx/writers/latex.py index f5f3b64b2..42acdd820 100644 --- a/sphinx/writers/latex.py +++ b/sphinx/writers/latex.py @@ -234,7 +234,6 @@ class Table(object): self.has_verbatim = False self.caption = None self.longtable = False - self.footnotes = [] class LaTeXTranslator(nodes.NodeVisitor): @@ -375,7 +374,8 @@ class LaTeXTranslator(nodes.NodeVisitor): sys.maxsize]] self.bodystack = [] self.footnotestack = [] - self.termfootnotestack = [] + self.footnote_restricted = False + self.pending_footnotes = [] self.curfilestack = [] self.handled_abbrs = set() if document.settings.docclass == 'howto': @@ -414,6 +414,20 @@ class LaTeXTranslator(nodes.NodeVisitor): self.body = self.bodystack.pop() return body + def restrict_footnote(self, node): + if self.footnote_restricted is False: + self.footnote_restricted = node + self.pending_footnotes = [] + + def unrestrict_footnote(self, node): + print self.footnote_restricted, self.pending_footnotes + if self.footnote_restricted == node: + self.footnote_restricted = False + for footnode in self.pending_footnotes: + footnode['footnotetext'] = True + footnode.walkabout(self) + self.pending_footnotes = [] + def format_docclass(self, docclass): """ prepends prefix to sphinx document classes """ @@ -891,6 +905,7 @@ class LaTeXTranslator(nodes.NodeVisitor): self.tableheaders = [] # Redirect body output until table is finished. self.pushbody(self.tablebody) + self.restrict_footnote(node) def depart_table(self, node): if self.table.rowcount > 30: @@ -961,10 +976,7 @@ class LaTeXTranslator(nodes.NodeVisitor): self.body.append(endmacro) if not self.table.longtable and self.table.caption is not None: self.body.append('\\end{threeparttable}\n\n') - if self.table.footnotes: - for footnode in self.table.footnotes: - footnode['footnotetext'] = True - footnode.walkabout(self) + self.unrestrict_footnote(node) self.table = None self.tablebody = None @@ -1138,16 +1150,12 @@ class LaTeXTranslator(nodes.NodeVisitor): if node.get('ids'): ctx += self.hypertarget(node['ids'][0]) self.body.append('\\item[{') - self.termfootnotestack.append([]) + self.restrict_footnote(node) self.context.append(ctx) def depart_term(self, node): self.body.append(self.context.pop()) - footnotes = self.termfootnotestack.pop() - for footnode in footnotes: - footnode['footnotetext'] = True - footnode.walkabout(self) - + self.unrestrict_footnote(node) self.in_term -= 1 def visit_termsep(self, node): @@ -1304,6 +1312,7 @@ class LaTeXTranslator(nodes.NodeVisitor): for id in self.next_figure_ids: ids += self.hypertarget(id, anchor=False) self.next_figure_ids.clear() + self.restrict_footnote(node) if (len(node.children) and isinstance(node.children[0], nodes.image) and node.children[0]['ids']): @@ -1331,6 +1340,7 @@ class LaTeXTranslator(nodes.NodeVisitor): def depart_figure(self, node): self.body.append(self.context.pop()) + self.unrestrict_footnote(node) def visit_caption(self, node): self.in_caption += 1 @@ -1666,18 +1676,11 @@ class LaTeXTranslator(nodes.NodeVisitor): self.body.append('\\protect\\footnotemark[%s]' % num) else: self.body.append('\\footnotemark[%s]' % num) - elif self.table: + elif self.footnote_restricted: self.footnotestack[-1][num][1] = True self.body.append('\\protect\\footnotemark[%s]' % num) - self.table.footnotes.append(footnode) - elif self.in_term: - self.body.append('\\footnotemark[%s]' % num) - self.termfootnotestack[-1].append(footnode) + self.pending_footnotes.append(footnode) else: - if self.in_caption: - raise UnsupportedError('%s:%s: footnotes in float captions ' - 'are not supported by LaTeX' % - (self.curfilestack[-1], node.line)) self.footnotestack[-1][num][1] = True footnode.walkabout(self) raise nodes.SkipChildren diff --git a/tests/roots/test-footnotes/index.rst b/tests/roots/test-footnotes/index.rst index e8137da71..ba830dab3 100644 --- a/tests/roots/test-footnotes/index.rst +++ b/tests/roots/test-footnotes/index.rst @@ -46,3 +46,9 @@ Footnote in term [#]_ Description2 .. [#] Footnote in term + +.. figure:: rimg.png + + This is the figure caption with a footnote to [#]_. + +.. [#] Footnote in caption diff --git a/tests/test_build_latex.py b/tests/test_build_latex.py index 3b2fdaaaa..bed636ec8 100644 --- a/tests/test_build_latex.py +++ b/tests/test_build_latex.py @@ -332,6 +332,9 @@ def test_reference_in_caption(app, status, warning): assert '\\caption{The table title with a reference to {[}AuthorYear{]}}' in result assert '\\paragraph{The rubric title with a reference to {[}AuthorYear{]}}' in result assert '\\chapter{The section with a reference to \\protect\\footnotemark[1]}' in result + assert ('\\caption{This is the figure caption with a footnote to ' + '\\protect\\footnotemark[5].}\end{figure}\n' + '\\footnotetext[5]{\nFootnote in caption\n}')in result @with_app(buildername='latex', testroot='footnotes', @@ -350,7 +353,7 @@ def test_latex_show_urls_is_inline(app, status, warning): '(http://sphinx-doc.org/\\textasciitilde{}test/)' in result) assert ('\\item[{\\href{http://sphinx-doc.org/}{URL in term} (http://sphinx-doc.org/)}] ' '\\leavevmode\nDescription' in result) - assert ('\\item[{Footnote in term \\footnotemark[4]}] ' + assert ('\\item[{Footnote in term \\protect\\footnotemark[4]}] ' '\\leavevmode\\footnotetext[4]{\nFootnote in term\n}\nDescription' in result) assert ('\\item[{\\href{http://sphinx-doc.org/}{Term in deflist} ' '(http://sphinx-doc.org/)}] \\leavevmode\nDescription' in result) @@ -375,11 +378,11 @@ def test_latex_show_urls_is_footnote(app, status, warning): assert 'Third footnote: \\footnote[5]{\nThird\n}' in result assert ('\\href{http://sphinx-doc.org/~test/}{URL including tilde}' '\\footnote[4]{\nhttp://sphinx-doc.org/\\textasciitilde{}test/\n}' in result) - assert ('\\item[{\\href{http://sphinx-doc.org/}{URL in term}\\footnotemark[6]}] ' + assert ('\\item[{\\href{http://sphinx-doc.org/}{URL in term}\\protect\\footnotemark[6]}] ' '\\leavevmode\\footnotetext[6]{\nhttp://sphinx-doc.org/\n}\nDescription' in result) - assert ('\\item[{Footnote in term \\footnotemark[8]}] ' + assert ('\\item[{Footnote in term \\protect\\footnotemark[8]}] ' '\\leavevmode\\footnotetext[8]{\nFootnote in term\n}\nDescription' in result) - assert ('\\item[{\\href{http://sphinx-doc.org/}{Term in deflist}\\footnotemark[7]}] ' + assert ('\\item[{\\href{http://sphinx-doc.org/}{Term in deflist}\\protect\\footnotemark[7]}] ' '\\leavevmode\\footnotetext[7]{\nhttp://sphinx-doc.org/\n}\nDescription' in result) assert ('\\href{https://github.com/sphinx-doc/sphinx}' '{https://github.com/sphinx-doc/sphinx}\n' in result) @@ -402,7 +405,7 @@ def test_latex_show_urls_is_no(app, status, warning): assert '\\href{http://sphinx-doc.org/~test/}{URL including tilde}' in result assert ('\\item[{\\href{http://sphinx-doc.org/}{URL in term}}] ' '\\leavevmode\nDescription' in result) - assert ('\\item[{Footnote in term \\footnotemark[4]}] ' + assert ('\\item[{Footnote in term \\protect\\footnotemark[4]}] ' '\\leavevmode\\footnotetext[4]{\nFootnote in term\n}\nDescription' in result) assert ('\\item[{\\href{http://sphinx-doc.org/}{Term in deflist}}] ' '\\leavevmode\nDescription' in result) From 532dec6076065bcdee931f4645dabb2363b193e4 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Fri, 1 Jan 2016 19:20:28 +0900 Subject: [PATCH 03/48] Remove debug print --- sphinx/writers/latex.py | 1 - 1 file changed, 1 deletion(-) diff --git a/sphinx/writers/latex.py b/sphinx/writers/latex.py index 42acdd820..5ff721803 100644 --- a/sphinx/writers/latex.py +++ b/sphinx/writers/latex.py @@ -420,7 +420,6 @@ class LaTeXTranslator(nodes.NodeVisitor): self.pending_footnotes = [] def unrestrict_footnote(self, node): - print self.footnote_restricted, self.pending_footnotes if self.footnote_restricted == node: self.footnote_restricted = False for footnode in self.pending_footnotes: From b0f376fdb8946ae476027019e3e335f5a60ee0ed Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Fri, 1 Jan 2016 19:31:36 +0900 Subject: [PATCH 04/48] Fix #2201: wrong table caption for tables with over 30 rows --- CHANGES | 1 + sphinx/writers/latex.py | 5 +- tests/roots/test-footnotes/index.rst | 86 ++++++++++++++++++++++++++++ tests/test_build_latex.py | 5 ++ 4 files changed, 96 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 169e17de0..e9bdda0d4 100644 --- a/CHANGES +++ b/CHANGES @@ -23,6 +23,7 @@ Bugs fixed * #2193: Fix shutil.SameFileError if source directory and destination directory are same * #2178: Fix unparseable C++ cross-reference when referencing a function with :cpp:any: * #2206: Fix Sphinx latex doc build failed due to a footnotes +* #2201: Fix wrong table caption for tables with over 30 rows Release 1.3.3 (released Dec 2, 2015) diff --git a/sphinx/writers/latex.py b/sphinx/writers/latex.py index 5ff721803..a4b42e1e4 100644 --- a/sphinx/writers/latex.py +++ b/sphinx/writers/latex.py @@ -948,7 +948,10 @@ class LaTeXTranslator(nodes.NodeVisitor): else: self.body.append('{|' + ('L|' * self.table.colcount) + '}\n') if self.table.longtable and self.table.caption is not None: - self.body.append(u'\\caption{%s}' % self.table.caption) + self.body.append(u'\\caption{') + for caption in self.table.caption: + self.body.append(caption) + self.body.append('}') for id in self.next_table_ids: self.body.append(self.hypertarget(id, anchor=False)) self.next_table_ids.clear() diff --git a/tests/roots/test-footnotes/index.rst b/tests/roots/test-footnotes/index.rst index ba830dab3..0c0e29b39 100644 --- a/tests/roots/test-footnotes/index.rst +++ b/tests/roots/test-footnotes/index.rst @@ -52,3 +52,89 @@ Footnote in term [#]_ This is the figure caption with a footnote to [#]_. .. [#] Footnote in caption + +.. list-table:: footnote [#]_ in caption of normal table + :widths: 1 1 + :header-rows: 1 + + * - name + - desc + * - a + - b + * - a + - b + +.. [#] Foot note in table + +.. list-table:: footnote [#]_ in caption of longtable + :widths: 1 1 + :header-rows: 1 + + * - name + - desc + * - a + - b + * - a + - b + * - a + - b + * - a + - b + * - a + - b + * - a + - b + * - a + - b + * - a + - b + * - a + - b + * - a + - b + * - a + - b + * - a + - b + * - a + - b + * - a + - b + * - a + - b + * - a + - b + * - a + - b + * - a + - b + * - a + - b + * - a + - b + * - a + - b + * - a + - b + * - a + - b + * - a + - b + * - a + - b + * - a + - b + * - a + - b + * - a + - b + * - a + - b + * - a + - b + * - a + - b + * - a + - b + +.. [#] Foot note in longtable diff --git a/tests/test_build_latex.py b/tests/test_build_latex.py index bed636ec8..36f55923f 100644 --- a/tests/test_build_latex.py +++ b/tests/test_build_latex.py @@ -335,6 +335,11 @@ def test_reference_in_caption(app, status, warning): assert ('\\caption{This is the figure caption with a footnote to ' '\\protect\\footnotemark[5].}\end{figure}\n' '\\footnotetext[5]{\nFootnote in caption\n}')in result + assert ('\\caption{footnote \\protect\\footnotemark[6] ' + 'in caption of normal table}') in result + assert '\\end{threeparttable}\n\n\\footnotetext[6]{\nFoot note in table\n}' in result + assert '\\caption{footnote \\protect\\footnotemark[7] in caption of longtable}' in result + assert '\end{longtable}\n\n\\footnotetext[7]{\nFoot note in longtable\n}' in result @with_app(buildername='latex', testroot='footnotes', From 3db02ede82708f512402ced631934696b4a6f399 Mon Sep 17 00:00:00 2001 From: Hong Xu Date: Fri, 1 Jan 2016 12:21:24 -0800 Subject: [PATCH 05/48] Set
    in the classic theme to fit with

    . A blockquote looks better if its text style is close to

    . --- sphinx/themes/classic/static/classic.css_t | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sphinx/themes/classic/static/classic.css_t b/sphinx/themes/classic/static/classic.css_t index 15d072954..3f3274ec3 100644 --- a/sphinx/themes/classic/static/classic.css_t +++ b/sphinx/themes/classic/static/classic.css_t @@ -223,7 +223,7 @@ a.headerlink:hover { color: white; } -div.body p, div.body dd, div.body li { +div.body p, div.body dd, div.body li, div.body blockquote { text-align: justify; line-height: 130%; } From 01a526793d2a5ad980b7333c5707fc622ace8058 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sat, 2 Jan 2016 11:17:59 +0900 Subject: [PATCH 06/48] Fix typos #2122 (cherry-picked by hand) --- doc/config.rst | 2 +- doc/domains.rst | 2 +- doc/extdev/appapi.rst | 2 +- doc/web/quickstart.rst | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/config.rst b/doc/config.rst index b48d59616..3fd1df658 100644 --- a/doc/config.rst +++ b/doc/config.rst @@ -453,7 +453,7 @@ documentation on :ref:`intl` for details. this path are searched by the standard :mod:`gettext` module. Internal messages are fetched from a text domain of ``sphinx``; so if you - add the directory :file:`./locale` to this settting, the message catalogs + add the directory :file:`./locale` to this setting, the message catalogs (compiled from ``.po`` format using :program:`msgfmt`) must be in :file:`./locale/{language}/LC_MESSAGES/sphinx.mo`. The text domain of individual documents depends on :confval:`gettext_compact`. diff --git a/doc/domains.rst b/doc/domains.rst index 2e85841e6..f2e437b06 100644 --- a/doc/domains.rst +++ b/doc/domains.rst @@ -561,7 +561,7 @@ a visibility statement (``public``, ``private`` or ``protected``). .. rst:directive:: .. cpp:member:: (member-)variable declaration .. cpp:var:: (member-)variable declaration - Describe a varible or member variable, e.g.,:: + Describe a variable or member variable, e.g.,:: .. cpp:member:: std::string theclass::name diff --git a/doc/extdev/appapi.rst b/doc/extdev/appapi.rst index c2ee4cc86..d1912676a 100644 --- a/doc/extdev/appapi.rst +++ b/doc/extdev/appapi.rst @@ -155,7 +155,7 @@ package. add_directive('literalinclude', literalinclude_directive, content = 0, arguments = (1, 0, 0), linenos = directives.flag, - language = direcitves.unchanged, + language = directives.unchanged, encoding = directives.encoding) .. versionchanged:: 0.6 diff --git a/doc/web/quickstart.rst b/doc/web/quickstart.rst index 996942db6..1611774c1 100644 --- a/doc/web/quickstart.rst +++ b/doc/web/quickstart.rst @@ -135,7 +135,7 @@ add this data to the ``COMMENT_OPTIONS`` that are used in the template. .. note:: - This only works works if your documentation is served from your + This only works if your documentation is served from your document root. If it is served from another directory, you will need to prefix the url route with that directory, and give the `docroot` keyword argument when creating the web support object:: From 6d0a74b689f9851be1e7f84cdc9d265d5cfe0599 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sat, 2 Jan 2016 11:42:06 +0900 Subject: [PATCH 07/48] Update CHANGES for PR #2213 --- CHANGES | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index e9bdda0d4..9dce4c1b4 100644 --- a/CHANGES +++ b/CHANGES @@ -24,7 +24,7 @@ Bugs fixed * #2178: Fix unparseable C++ cross-reference when referencing a function with :cpp:any: * #2206: Fix Sphinx latex doc build failed due to a footnotes * #2201: Fix wrong table caption for tables with over 30 rows - +* #2213: Set

    in the classic theme to fit with

    Release 1.3.3 (released Dec 2, 2015) ==================================== From b6efc7327f38d5aa96075fe37b8ba65874f359bd Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sat, 2 Jan 2016 16:01:52 +0900 Subject: [PATCH 08/48] Make ``conf.py`` less flake8 warnings (ref #1817, #2077) --- sphinx/quickstart.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/sphinx/quickstart.py b/sphinx/quickstart.py index d70725ae6..9cb1fd589 100644 --- a/sphinx/quickstart.py +++ b/sphinx/quickstart.py @@ -87,7 +87,6 @@ QUICKSTART_CONF += u'''\ import sys import os -import shlex # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the @@ -295,8 +294,8 @@ latex_elements = { # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ - (master_doc, '%(project_fn)s.tex', u'%(project_doc_texescaped_str)s', - u'%(author_texescaped_str)s', 'manual'), + (master_doc, '%(project_fn)s.tex', u'%(project_doc_texescaped_str)s', + u'%(author_texescaped_str)s', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of @@ -339,9 +338,9 @@ man_pages = [ # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - (master_doc, '%(project_fn)s', u'%(project_doc_str)s', - author, '%(project_fn)s', 'One line description of project.', - 'Miscellaneous'), + (master_doc, '%(project_fn)s', u'%(project_doc_str)s', + author, '%(project_fn)s', 'One line description of project.', + 'Miscellaneous'), ] # Documents to append as an appendix to all manuals. @@ -370,10 +369,10 @@ epub_copyright = copyright # The basename for the epub file. It defaults to the project name. #epub_basename = project -# The HTML theme for the epub output. Since the default themes are not optimized -# for small screen space, using the same theme for HTML and epub output is -# usually not wise. This defaults to 'epub', a theme designed to save visual -# space. +# The HTML theme for the epub output. Since the default themes are not +# optimized for small screen space, using the same theme for HTML and epub +# output is usually not wise. This defaults to 'epub', a theme designed to save +# visual space. #epub_theme = 'epub' # The language of the text. It defaults to the language option From c305f30ae408bed3a754a497709411085ab6197f Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sat, 2 Jan 2016 22:42:16 +0900 Subject: [PATCH 09/48] Add .swp to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 298a9c370..be28908ec 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ *.pyc *.egg *.so +*.swp .dir-locals.el .ropeproject/ From 2bcf92dfb0837f3be804662770fb4d45b767c284 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sun, 3 Jan 2016 20:12:33 +0900 Subject: [PATCH 10/48] Fix #1815: linkcheck does not raise an exception if warniserror set to true and link is broken --- CHANGES | 1 + sphinx/builders/linkcheck.py | 5 +++-- sphinx/ext/doctest.py | 5 +++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CHANGES b/CHANGES index 9dce4c1b4..51d22aa76 100644 --- a/CHANGES +++ b/CHANGES @@ -25,6 +25,7 @@ Bugs fixed * #2206: Fix Sphinx latex doc build failed due to a footnotes * #2201: Fix wrong table caption for tables with over 30 rows * #2213: Set

    in the classic theme to fit with

    +* #1815: Fix linkcheck does not raise an exception if warniserror set to true and link is broken Release 1.3.3 (released Dec 2, 2015) ==================================== diff --git a/sphinx/builders/linkcheck.py b/sphinx/builders/linkcheck.py index 5dac89e2f..72010113a 100644 --- a/sphinx/builders/linkcheck.py +++ b/sphinx/builders/linkcheck.py @@ -243,11 +243,12 @@ class CheckExternalLinksBuilder(Builder): elif status == 'working': self.info(darkgreen('ok ') + uri + info) elif status == 'broken': - self.info(red('broken ') + uri + red(' - ' + info)) self.write_entry('broken', docname, lineno, uri + ': ' + info) - if self.app.quiet: + if self.app.quiet or self.app.warningiserror: self.warn('broken link: %s' % uri, '%s:%s' % (self.env.doc2path(docname), lineno)) + else: + self.info(red('broken ') + uri + red(' - ' + info)) elif status == 'redirected': text, color = { 301: ('permanently', darkred), diff --git a/sphinx/ext/doctest.py b/sphinx/ext/doctest.py index e22024d42..5877be2eb 100644 --- a/sphinx/ext/doctest.py +++ b/sphinx/ext/doctest.py @@ -262,9 +262,10 @@ Results of doctest builder run on %s self.outfile.write(text) def _warn_out(self, text): - self.info(text, nonl=True) - if self.app.quiet: + if self.app.quiet or self.app.warningiserror: self.warn(text) + else: + self.info(text, nonl=True) if isinstance(text, binary_type): text = force_decode(text, None) self.outfile.write(text) From 7bb685bbe97824bc2c65bf8cb1d7ac38e5f91cd4 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sun, 3 Jan 2016 20:26:38 +0900 Subject: [PATCH 11/48] Fix #2197: Slightly cryptic error message for missing index.rst file --- CHANGES | 1 + sphinx/environment.py | 4 ++-- tests/test_build.py | 11 +++++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index 51d22aa76..66464bd3b 100644 --- a/CHANGES +++ b/CHANGES @@ -26,6 +26,7 @@ Bugs fixed * #2201: Fix wrong table caption for tables with over 30 rows * #2213: Set

    in the classic theme to fit with

    * #1815: Fix linkcheck does not raise an exception if warniserror set to true and link is broken +* #2197: Fix slightly cryptic error message for missing index.rst file Release 1.3.3 (released Dec 2, 2015) ==================================== diff --git a/sphinx/environment.py b/sphinx/environment.py index 371b3a6c4..5d2107299 100644 --- a/sphinx/environment.py +++ b/sphinx/environment.py @@ -618,8 +618,8 @@ class BuildEnvironment: self._read_serial(docnames, app) if config.master_doc not in self.all_docs: - self.warn(None, 'master file %s not found' % - self.doc2path(config.master_doc)) + raise SphinxError('master file %s not found' % + self.doc2path(config.master_doc)) self.app = None diff --git a/tests/test_build.py b/tests/test_build.py index 5b9d7a756..aa5d72ce9 100644 --- a/tests/test_build.py +++ b/tests/test_build.py @@ -12,6 +12,7 @@ from six import BytesIO from textwrap import dedent +from sphinx.errors import SphinxError from util import with_app, rootdir, tempdir, SkipTest, TestApp @@ -73,6 +74,16 @@ def test_build_all(): yield verify_build, buildername, srcdir +@with_app(buildername='text') +def test_master_doc_not_found(app, status, warning): + (app.srcdir / 'contents.txt').unlink() + try: + app.builder.build_all() + assert False # SphinxError not raised + except Exception as exc: + assert isinstance(exc, SphinxError) + + @with_app(buildername='text', testroot='circular') def test_circular_toctree(app, status, warning): app.builder.build_all() From 26c43643d349553c1acb45884ac5f73a359f16db Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sun, 3 Jan 2016 20:52:39 +0900 Subject: [PATCH 12/48] Fix broken tests by 7bb685bbe97824bc2c65bf8cb1d7ac38e5f91cd4 --- tests/roots/test-doctest/conf.py | 2 +- tests/test_build.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/roots/test-doctest/conf.py b/tests/roots/test-doctest/conf.py index f6a12edb9..2e721fb57 100644 --- a/tests/roots/test-doctest/conf.py +++ b/tests/roots/test-doctest/conf.py @@ -1,5 +1,5 @@ extensions = ['sphinx.ext.doctest'] project = 'test project for doctest' -master_doc = 'doctest.txt' +master_doc = 'doctest' source_suffix = '.txt' diff --git a/tests/test_build.py b/tests/test_build.py index aa5d72ce9..97ef651a6 100644 --- a/tests/test_build.py +++ b/tests/test_build.py @@ -76,12 +76,14 @@ def test_build_all(): @with_app(buildername='text') def test_master_doc_not_found(app, status, warning): - (app.srcdir / 'contents.txt').unlink() + (app.srcdir / 'contents.txt').move(app.srcdir / 'contents.txt.bak') try: app.builder.build_all() assert False # SphinxError not raised except Exception as exc: assert isinstance(exc, SphinxError) + finally: + (app.srcdir / 'contents.txt.bak').move(app.srcdir / 'contents.txt') @with_app(buildername='text', testroot='circular') From e8e5391e611b13e0939abb4b9ad50cf959214254 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Mon, 4 Jan 2016 11:19:50 +0900 Subject: [PATCH 13/48] Fix #1894: Unlisted phony targets in quickstart Makefile --- CHANGES | 1 + sphinx/quickstart.py | 29 ++++++++++++++++++++++++++--- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/CHANGES b/CHANGES index 66464bd3b..1ec247ec2 100644 --- a/CHANGES +++ b/CHANGES @@ -27,6 +27,7 @@ Bugs fixed * #2213: Set

    in the classic theme to fit with

    * #1815: Fix linkcheck does not raise an exception if warniserror set to true and link is broken * #2197: Fix slightly cryptic error message for missing index.rst file +* #1894: Unlisted phony targets in quickstart Makefile Release 1.3.3 (released Dec 2, 2015) ==================================== diff --git a/sphinx/quickstart.py b/sphinx/quickstart.py index 9cb1fd589..e785ab207 100644 --- a/sphinx/quickstart.py +++ b/sphinx/quickstart.py @@ -487,9 +487,7 @@ $(SPHINXOPTS) %(rsrcdir)s # the i18n builder cannot share the environment and doctrees with the others I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) %(rsrcdir)s -.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp \ -epub latex latexpdf text man changes linkcheck doctest coverage gettext - +.PHONY: help help: \t@echo "Please use \\`make ' where is one of" \t@echo " html to make standalone HTML files" @@ -518,40 +516,48 @@ help: (if enabled)" \t@echo " coverage to run coverage check of the documentation (if enabled)" +.PHONY: clean clean: \trm -rf $(BUILDDIR)/* +.PHONY: html html: \t$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html \t@echo \t@echo "Build finished. The HTML pages are in $(BUILDDIR)/html." +.PHONY: dirhtml dirhtml: \t$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml \t@echo \t@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." +.PHONY: singlehtml singlehtml: \t$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml \t@echo \t@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." +.PHONY: pickle pickle: \t$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle \t@echo \t@echo "Build finished; now you can process the pickle files." +.PHONY: json json: \t$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json \t@echo \t@echo "Build finished; now you can process the JSON files." +.PHONY: htmlhelp htmlhelp: \t$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp \t@echo \t@echo "Build finished; now you can run HTML Help Workshop with the" \\ \t ".hhp project file in $(BUILDDIR)/htmlhelp." +.PHONY: qthelp qthelp: \t$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp \t@echo @@ -561,6 +567,7 @@ qthelp: \t@echo "To view the help file:" \t@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/%(project_fn)s.qhc" +.PHONY: applehelp applehelp: \t$(SPHINXBUILD) -b applehelp $(ALLSPHINXOPTS) $(BUILDDIR)/applehelp \t@echo @@ -569,6 +576,7 @@ applehelp: \t "~/Library/Documentation/Help or install it in your application" \\ \t "bundle." +.PHONY: devhelp devhelp: \t$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp \t@echo @@ -579,11 +587,13 @@ devhelp: $$HOME/.local/share/devhelp/%(project_fn)s" \t@echo "# devhelp" +.PHONY: epub epub: \t$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub \t@echo \t@echo "Build finished. The epub file is in $(BUILDDIR)/epub." +.PHONY: latex latex: \t$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex \t@echo @@ -591,28 +601,33 @@ latex: \t@echo "Run \\`make' in that directory to run these through (pdf)latex" \\ \t "(use \\`make latexpdf' here to do that automatically)." +.PHONY: latexpdf latexpdf: \t$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex \t@echo "Running LaTeX files through pdflatex..." \t$(MAKE) -C $(BUILDDIR)/latex all-pdf \t@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." +.PHONY: latexpdfja latexpdfja: \t$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex \t@echo "Running LaTeX files through platex and dvipdfmx..." \t$(MAKE) -C $(BUILDDIR)/latex all-pdf-ja \t@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." +.PHONY: text text: \t$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text \t@echo \t@echo "Build finished. The text files are in $(BUILDDIR)/text." +.PHONY: man man: \t$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man \t@echo \t@echo "Build finished. The manual pages are in $(BUILDDIR)/man." +.PHONY: texinfo texinfo: \t$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo \t@echo @@ -620,43 +635,51 @@ texinfo: \t@echo "Run \\`make' in that directory to run these through makeinfo" \\ \t "(use \\`make info' here to do that automatically)." +.PHONY: info info: \t$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo \t@echo "Running Texinfo files through makeinfo..." \tmake -C $(BUILDDIR)/texinfo info \t@echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." +.PHONY: gettext gettext: \t$(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale \t@echo \t@echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." +.PHONY: changes changes: \t$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes \t@echo \t@echo "The overview file is in $(BUILDDIR)/changes." +.PHONY: linkcheck linkcheck: \t$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck \t@echo \t@echo "Link check complete; look for any errors in the above output " \\ \t "or in $(BUILDDIR)/linkcheck/output.txt." +.PHONY: doctest doctest: \t$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest \t@echo "Testing of doctests in the sources finished, look at the " \\ \t "results in $(BUILDDIR)/doctest/output.txt." +.PHONY: coverage coverage: \t$(SPHINXBUILD) -b coverage $(ALLSPHINXOPTS) $(BUILDDIR)/coverage \t@echo "Testing of coverage in the sources finished, look at the " \\ \t "results in $(BUILDDIR)/coverage/python.txt." +.PHONY: xml xml: \t$(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml \t@echo \t@echo "Build finished. The XML files are in $(BUILDDIR)/xml." +.PHONY: pseudoxml pseudoxml: \t$(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml \t@echo From af5edc31ee5598f35365c9cb15f4786b84877218 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20K=C3=B6hl?= Date: Fri, 20 Nov 2015 21:40:20 +0100 Subject: [PATCH 14/48] beautify collapsed grouped field --- sphinx/util/docfields.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/sphinx/util/docfields.py b/sphinx/util/docfields.py index d503ac58b..4c566390b 100644 --- a/sphinx/util/docfields.py +++ b/sphinx/util/docfields.py @@ -107,7 +107,14 @@ class GroupedField(Field): fieldname = nodes.field_name('', self.label) listnode = self.list_type() if len(items) == 1 and self.can_collapse: - return Field.make_field(self, types, domain, items[0]) + fieldarg, content = items[0] + par = nodes.paragraph() + par += self.make_xref(self.rolename, domain, fieldarg, + addnodes.literal_strong) + par += nodes.Text(' -- ') + par += content + fieldbody = nodes.field_body('', par) + return nodes.field('', fieldname, fieldbody) for fieldarg, content in items: par = nodes.paragraph() par += self.make_xref(self.rolename, domain, fieldarg, From 65ad78daece1b1a895936c895aca85fe3e8f0bfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20K=C3=B6hl?= Date: Fri, 20 Nov 2015 22:07:39 +0100 Subject: [PATCH 15/48] [tests] beautify collapsed grouped field --- tests/test_intl.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_intl.py b/tests/test_intl.py index dabb2a3f5..0086b63f2 100644 --- a/tests/test_intl.py +++ b/tests/test_intl.py @@ -280,8 +280,8 @@ def test_text_builder(app, status, warning): u"\n * **foo** -- DESCRIPTION OF PARAMETER foo\n" u"\n * **bar** -- DESCRIPTION OF PARAMETER bar\n" u"\nclass Cls3(values)\n" - u"\n Raises ValueError:" - u"\n IF THE VALUES ARE OUT OF RANGE\n" + u"\n Raises:" + u"\n **ValueError** -- IF THE VALUES ARE OUT OF RANGE\n" u"\nclass Cls4(values)\n" u"\n Raises:" u"\n * **TypeError** -- IF THE VALUES ARE NOT VALID\n" From 1ac571cd7e9c9a90d6c3c2e9d63a69777871a5f1 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Tue, 5 Jan 2016 00:25:53 +0900 Subject: [PATCH 16/48] Fix #2125: unifies behavior of collapsed fields (`GroupedField` and `TypedField`) --- CHANGES | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES b/CHANGES index 1ec247ec2..54647a909 100644 --- a/CHANGES +++ b/CHANGES @@ -28,6 +28,7 @@ Bugs fixed * #1815: Fix linkcheck does not raise an exception if warniserror set to true and link is broken * #2197: Fix slightly cryptic error message for missing index.rst file * #1894: Unlisted phony targets in quickstart Makefile +* #2125: Fix unifies behavior of collapsed fields (`GroupedField` and `TypedField`) Release 1.3.3 (released Dec 2, 2015) ==================================== From 51b101f0067a340bc948f9e66480d265c9444146 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Tue, 5 Jan 2016 00:26:31 +0900 Subject: [PATCH 17/48] Refactor GroupedField.make_field() --- sphinx/util/docfields.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/sphinx/util/docfields.py b/sphinx/util/docfields.py index 4c566390b..f556f302f 100644 --- a/sphinx/util/docfields.py +++ b/sphinx/util/docfields.py @@ -106,15 +106,6 @@ class GroupedField(Field): def make_field(self, types, domain, items): fieldname = nodes.field_name('', self.label) listnode = self.list_type() - if len(items) == 1 and self.can_collapse: - fieldarg, content = items[0] - par = nodes.paragraph() - par += self.make_xref(self.rolename, domain, fieldarg, - addnodes.literal_strong) - par += nodes.Text(' -- ') - par += content - fieldbody = nodes.field_body('', par) - return nodes.field('', fieldname, fieldbody) for fieldarg, content in items: par = nodes.paragraph() par += self.make_xref(self.rolename, domain, fieldarg, @@ -122,6 +113,9 @@ class GroupedField(Field): par += nodes.Text(' -- ') par += content listnode += nodes.list_item('', par) + if len(items) == 1 and self.can_collapse: + fieldbody = nodes.field_body('', listnode[0][0]) + return nodes.field('', fieldname, fieldbody) fieldbody = nodes.field_body('', listnode) return nodes.field('', fieldname, fieldbody) From ec4a1ae8636fb70eaf34b4f7892824babfed917b Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Tue, 5 Jan 2016 16:47:52 +0900 Subject: [PATCH 18/48] Fix typo in README --- CHANGES | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 54647a909..28abeb45f 100644 --- a/CHANGES +++ b/CHANGES @@ -28,7 +28,7 @@ Bugs fixed * #1815: Fix linkcheck does not raise an exception if warniserror set to true and link is broken * #2197: Fix slightly cryptic error message for missing index.rst file * #1894: Unlisted phony targets in quickstart Makefile -* #2125: Fix unifies behavior of collapsed fields (`GroupedField` and `TypedField`) +* #2125: Fix unifies behavior of collapsed fields (``GroupedField`` and ``TypedField``) Release 1.3.3 (released Dec 2, 2015) ==================================== From d0576cd01212b57699cbf7d8e9d8375baecf665c Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Tue, 5 Jan 2016 16:48:22 +0900 Subject: [PATCH 19/48] Fix #1408: Check latex_logo validity before copying --- CHANGES | 1 + sphinx/builders/latex.py | 8 ++++++-- tests/test_build_latex.py | 10 ++++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index 28abeb45f..7d56602bc 100644 --- a/CHANGES +++ b/CHANGES @@ -29,6 +29,7 @@ Bugs fixed * #2197: Fix slightly cryptic error message for missing index.rst file * #1894: Unlisted phony targets in quickstart Makefile * #2125: Fix unifies behavior of collapsed fields (``GroupedField`` and ``TypedField``) +* #1408: Check latex_logo validity before copying Release 1.3.3 (released Dec 2, 2015) ==================================== diff --git a/sphinx/builders/latex.py b/sphinx/builders/latex.py index 1eef58d66..f98d2153e 100644 --- a/sphinx/builders/latex.py +++ b/sphinx/builders/latex.py @@ -20,6 +20,7 @@ from docutils.frontend import OptionParser from sphinx import package_dir, addnodes from sphinx.util import texescape +from sphinx.errors import SphinxError from sphinx.locale import _ from sphinx.builders import Builder from sphinx.environment import NoUri @@ -191,6 +192,9 @@ class LaTeXBuilder(Builder): # the logo is handled differently if self.config.latex_logo: logobase = path.basename(self.config.latex_logo) - copyfile(path.join(self.confdir, self.config.latex_logo), - path.join(self.outdir, logobase)) + logotarget = path.join(self.outdir, logobase) + if not path.isfile(path.join(self.confdir, self.config.latex_logo)): + raise SphinxError('logo file %r does not exist' % self.config.latex_logo) + elif not path.isfile(logotarget): + copyfile(path.join(self.confdir, self.config.latex_logo), logotarget) self.info('done') diff --git a/tests/test_build_latex.py b/tests/test_build_latex.py index 36f55923f..9177ecb94 100644 --- a/tests/test_build_latex.py +++ b/tests/test_build_latex.py @@ -16,6 +16,7 @@ from subprocess import Popen, PIPE from six import PY3 +from sphinx.errors import SphinxError from sphinx.writers.latex import LaTeXTranslator from util import SkipTest, remove_unicode_literals, with_app @@ -418,3 +419,12 @@ def test_latex_show_urls_is_no(app, status, warning): '{https://github.com/sphinx-doc/sphinx}\n' in result) assert ('\\href{mailto:sphinx-dev@googlegroups.com}' '{sphinx-dev@googlegroups.com}\n' in result) + + +@with_app(buildername='latex', confoverrides={'latex_logo': 'notfound.jpg'}) +def test_latex_logo_if_not_found(app, status, warning): + try: + app.builder.build_all() + assert False # SphinxError not raised + except Exception as exc: + assert isinstance(exc, SphinxError) From b0a5a1339ecddf46dac96e594309eb5fa85ebe11 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Wed, 6 Jan 2016 01:34:29 +0900 Subject: [PATCH 20/48] Fix #771: latex output doesn't set tocdepth --- CHANGES | 2 +- sphinx/builders/latex.py | 9 +++++++++ sphinx/writers/latex.py | 9 +++++++++ tests/roots/test-tocdepth/index.rst | 1 + tests/test_build_latex.py | 28 ++++++++++++++++++++++++++++ 5 files changed, 48 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 7d56602bc..6bd03e17e 100644 --- a/CHANGES +++ b/CHANGES @@ -30,7 +30,7 @@ Bugs fixed * #1894: Unlisted phony targets in quickstart Makefile * #2125: Fix unifies behavior of collapsed fields (``GroupedField`` and ``TypedField``) * #1408: Check latex_logo validity before copying - +* #771: Fix latex output doesn't set tocdepth Release 1.3.3 (released Dec 2, 2015) ==================================== diff --git a/sphinx/builders/latex.py b/sphinx/builders/latex.py index f98d2153e..85b71b578 100644 --- a/sphinx/builders/latex.py +++ b/sphinx/builders/latex.py @@ -95,6 +95,14 @@ class LaTeXBuilder(Builder): destination_path=path.join(self.outdir, targetname), encoding='utf-8') self.info("processing " + targetname + "... ", nonl=1) + toctrees = self.env.get_doctree(docname).traverse(addnodes.toctree) + if toctrees: + if toctrees[0].get('maxdepth'): + tocdepth = int(toctrees[0].get('maxdepth')) + else: + tocdepth = None + else: + tocdepth = None doctree = self.assemble_doctree( docname, toctree_only, appendices=((docclass != 'howto') and self.config.latex_appendices or [])) @@ -106,6 +114,7 @@ class LaTeXBuilder(Builder): doctree.settings.contentsname = self.get_contentsname(docname) doctree.settings.docname = docname doctree.settings.docclass = docclass + doctree.settings.tocdepth = tocdepth docwriter.write(doctree, destination) self.info("done") diff --git a/sphinx/writers/latex.py b/sphinx/writers/latex.py index a4b42e1e4..c381bf823 100644 --- a/sphinx/writers/latex.py +++ b/sphinx/writers/latex.py @@ -53,6 +53,7 @@ HEADER = r'''%% Generated by Sphinx. \author{%(author)s} \newcommand{\sphinxlogo}{%(logo)s} \renewcommand{\releasename}{%(releasename)s} +%(tocdepth)s %(makeindex)s ''' @@ -273,6 +274,7 @@ class LaTeXTranslator(nodes.NodeVisitor): 'printindex': '\\printindex', 'transition': '\n\n\\bigskip\\hrule{}\\bigskip\n\n', 'figure_align': 'htbp', + 'tocdepth': '', } # sphinx specific document classes @@ -357,6 +359,13 @@ class LaTeXTranslator(nodes.NodeVisitor): if self.elements['extraclassoptions']: self.elements['classoptions'] += ',' + \ self.elements['extraclassoptions'] + if document.settings.tocdepth: + if document.settings.docclass == 'howto': + self.elements['tocdepth'] = ('\\setcounter{tocdepth}{%d}' % + document.settings.tocdepth) + else: + self.elements['tocdepth'] = ('\\setcounter{tocdepth}{%d}' % + (document.settings.tocdepth - 1)) self.highlighter = highlighting.PygmentsBridge( 'latex', diff --git a/tests/roots/test-tocdepth/index.rst b/tests/roots/test-tocdepth/index.rst index 0b651d483..a702cb88b 100644 --- a/tests/roots/test-tocdepth/index.rst +++ b/tests/roots/test-tocdepth/index.rst @@ -3,6 +3,7 @@ test-tocdepth .. toctree:: :numbered: + :maxdepth: 2 foo bar diff --git a/tests/test_build_latex.py b/tests/test_build_latex.py index 9177ecb94..81f436c3a 100644 --- a/tests/test_build_latex.py +++ b/tests/test_build_latex.py @@ -428,3 +428,31 @@ def test_latex_logo_if_not_found(app, status, warning): assert False # SphinxError not raised except Exception as exc: assert isinstance(exc, SphinxError) + + +@with_app(buildername='latex', testroot='tocdepth', + confoverrides={'latex_documents': [ + ('index', 'SphinxTests.tex', 'Sphinx Tests Documentation', + 'Georg Brandl', 'manual'), + ]}) +def test_toctree_maxdepth_manual(app, status, warning): + app.builder.build_all() + result = (app.outdir / 'SphinxTests.tex').text(encoding='utf8') + print(result) + print(status.getvalue()) + print(warning.getvalue()) + assert '\\setcounter{tocdepth}{1}' in result + + +@with_app(buildername='latex', testroot='tocdepth', + confoverrides={'latex_documents': [ + ('index', 'SphinxTests.tex', 'Sphinx Tests Documentation', + 'Georg Brandl', 'howto'), + ]}) +def test_toctree_maxdepth_howto(app, status, warning): + app.builder.build_all() + result = (app.outdir / 'SphinxTests.tex').text(encoding='utf8') + print(result) + print(status.getvalue()) + print(warning.getvalue()) + assert '\\setcounter{tocdepth}{2}' in result From dc0873adf63b9097ea4705f7186158de373d17c3 Mon Sep 17 00:00:00 2001 From: shimizukawa Date: Wed, 6 Jan 2016 07:27:34 +0900 Subject: [PATCH 21/48] Fix #1820: On Windows, console coloring is broken with colorama version 0.3.3. Now sphinx use colorama>=0.3.5 to avoid this problem. --- CHANGES | 3 +++ setup.py | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index 6bd03e17e..87c8530d8 100644 --- a/CHANGES +++ b/CHANGES @@ -31,6 +31,9 @@ Bugs fixed * #2125: Fix unifies behavior of collapsed fields (``GroupedField`` and ``TypedField``) * #1408: Check latex_logo validity before copying * #771: Fix latex output doesn't set tocdepth +* #1820: On Windows, console coloring is broken with colorama version 0.3.3. + Now sphinx use colorama>=0.3.5 to avoid this problem. + Release 1.3.3 (released Dec 2, 2015) ==================================== diff --git a/setup.py b/setup.py index 6bc288757..4ff63150d 100644 --- a/setup.py +++ b/setup.py @@ -58,7 +58,7 @@ requires = [ extras_require = { # Environment Marker works for wheel 0.24 or later ':sys_platform=="win32"': [ - 'colorama', + 'colorama>=0.3.5', ], 'websupport': [ 'sqlalchemy>=0.9', @@ -73,7 +73,7 @@ extras_require = { # for sdist installation with pip-1.5.6 if sys.platform == 'win32': - requires.append('colorama') + requires.append('colorama>=0.3.5') # Provide a "compile_catalog" command that also creates the translated # JavaScript files if Babel is available. From acea9900b5a6dd5cd2063f1515652ab6fc6af401 Mon Sep 17 00:00:00 2001 From: shimizukawa Date: Wed, 6 Jan 2016 07:28:19 +0900 Subject: [PATCH 22/48] fix over 90 columns --- CHANGES | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index 87c8530d8..de0e01bfa 100644 --- a/CHANGES +++ b/CHANGES @@ -14,7 +14,8 @@ Bugs fixed * #2168: Fix raw directive does not work for text writer * #2171: Fix cannot linkcheck url with unicode * #2182: LaTeX: support image file names with more than 1 dots -* #2189: Fix previous sibling link for first file in subdirectory uses last file, not intended previous from root toctree +* #2189: Fix previous sibling link for first file in subdirectory uses last file, not + intended previous from root toctree * #2003: Fix decode error under python2 (only) when ``make linkcheck`` is run * #2186: Fix LaTeX output of \mathbb in math * #1480, #2188: LaTeX: Support math in section titles @@ -25,7 +26,8 @@ Bugs fixed * #2206: Fix Sphinx latex doc build failed due to a footnotes * #2201: Fix wrong table caption for tables with over 30 rows * #2213: Set

    in the classic theme to fit with

    -* #1815: Fix linkcheck does not raise an exception if warniserror set to true and link is broken +* #1815: Fix linkcheck does not raise an exception if warniserror set to true and link is + broken * #2197: Fix slightly cryptic error message for missing index.rst file * #1894: Unlisted phony targets in quickstart Makefile * #2125: Fix unifies behavior of collapsed fields (``GroupedField`` and ``TypedField``) From 924f65d737d008338db83118e9cd86ab58e1c69f Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Wed, 6 Jan 2016 09:45:19 +0900 Subject: [PATCH 23/48] Use document['tocdepth'] instead of document.setting.tocdepth --- sphinx/builders/latex.py | 2 +- sphinx/writers/latex.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sphinx/builders/latex.py b/sphinx/builders/latex.py index 85b71b578..18041eae3 100644 --- a/sphinx/builders/latex.py +++ b/sphinx/builders/latex.py @@ -106,6 +106,7 @@ class LaTeXBuilder(Builder): doctree = self.assemble_doctree( docname, toctree_only, appendices=((docclass != 'howto') and self.config.latex_appendices or [])) + doctree['tocdepth'] = tocdepth self.post_process_images(doctree) self.info("writing... ", nonl=1) doctree.settings = docsettings @@ -114,7 +115,6 @@ class LaTeXBuilder(Builder): doctree.settings.contentsname = self.get_contentsname(docname) doctree.settings.docname = docname doctree.settings.docclass = docclass - doctree.settings.tocdepth = tocdepth docwriter.write(doctree, destination) self.info("done") diff --git a/sphinx/writers/latex.py b/sphinx/writers/latex.py index c381bf823..478d50318 100644 --- a/sphinx/writers/latex.py +++ b/sphinx/writers/latex.py @@ -359,13 +359,13 @@ class LaTeXTranslator(nodes.NodeVisitor): if self.elements['extraclassoptions']: self.elements['classoptions'] += ',' + \ self.elements['extraclassoptions'] - if document.settings.tocdepth: + if document.get('tocdepth'): if document.settings.docclass == 'howto': self.elements['tocdepth'] = ('\\setcounter{tocdepth}{%d}' % - document.settings.tocdepth) + document['tocdepth']) else: self.elements['tocdepth'] = ('\\setcounter{tocdepth}{%d}' % - (document.settings.tocdepth - 1)) + (document['tocdepth'] - 1)) self.highlighter = highlighting.PygmentsBridge( 'latex', From 26e29de9045103f4a23be59ff7ab964c974ab3e1 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Wed, 6 Jan 2016 09:51:34 +0900 Subject: [PATCH 24/48] Fix broken testcase; Split test-toctree-maxdepth from test-tocdepth --- tests/roots/test-tocdepth/index.rst | 1 - tests/roots/test-toctree-maxdepth/bar.rst | 27 +++++++++++++++++++++ tests/roots/test-toctree-maxdepth/baz.rst | 5 ++++ tests/roots/test-toctree-maxdepth/conf.py | 4 +++ tests/roots/test-toctree-maxdepth/foo.rst | 26 ++++++++++++++++++++ tests/roots/test-toctree-maxdepth/index.rst | 9 +++++++ tests/test_build_latex.py | 4 +-- 7 files changed, 73 insertions(+), 3 deletions(-) create mode 100644 tests/roots/test-toctree-maxdepth/bar.rst create mode 100644 tests/roots/test-toctree-maxdepth/baz.rst create mode 100644 tests/roots/test-toctree-maxdepth/conf.py create mode 100644 tests/roots/test-toctree-maxdepth/foo.rst create mode 100644 tests/roots/test-toctree-maxdepth/index.rst diff --git a/tests/roots/test-tocdepth/index.rst b/tests/roots/test-tocdepth/index.rst index a702cb88b..0b651d483 100644 --- a/tests/roots/test-tocdepth/index.rst +++ b/tests/roots/test-tocdepth/index.rst @@ -3,7 +3,6 @@ test-tocdepth .. toctree:: :numbered: - :maxdepth: 2 foo bar diff --git a/tests/roots/test-toctree-maxdepth/bar.rst b/tests/roots/test-toctree-maxdepth/bar.rst new file mode 100644 index 000000000..d70dec90d --- /dev/null +++ b/tests/roots/test-toctree-maxdepth/bar.rst @@ -0,0 +1,27 @@ +:tocdepth: 2 + +=== +Bar +=== + +should be 2 + +Bar A +===== + +should be 2.1 + +.. toctree:: + + baz + +Bar B +===== + +should be 2.2 + +Bar B1 +------ + +should be 2.2.1 + diff --git a/tests/roots/test-toctree-maxdepth/baz.rst b/tests/roots/test-toctree-maxdepth/baz.rst new file mode 100644 index 000000000..b07fa0507 --- /dev/null +++ b/tests/roots/test-toctree-maxdepth/baz.rst @@ -0,0 +1,5 @@ +Baz A +----- + +should be 2.1.1 + diff --git a/tests/roots/test-toctree-maxdepth/conf.py b/tests/roots/test-toctree-maxdepth/conf.py new file mode 100644 index 000000000..cf05c9b5c --- /dev/null +++ b/tests/roots/test-toctree-maxdepth/conf.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- + +master_doc = 'index' +html_theme = 'classic' diff --git a/tests/roots/test-toctree-maxdepth/foo.rst b/tests/roots/test-toctree-maxdepth/foo.rst new file mode 100644 index 000000000..61fd539ff --- /dev/null +++ b/tests/roots/test-toctree-maxdepth/foo.rst @@ -0,0 +1,26 @@ +=== +Foo +=== + +should be 1 + +Foo A +===== + +should be 1.1 + +Foo A1 +------ + +should be 1.1.1 + +Foo B +===== + +should be 1.2 + +Foo B1 +------ + +should be 1.2.1 + diff --git a/tests/roots/test-toctree-maxdepth/index.rst b/tests/roots/test-toctree-maxdepth/index.rst new file mode 100644 index 000000000..30dc61c8b --- /dev/null +++ b/tests/roots/test-toctree-maxdepth/index.rst @@ -0,0 +1,9 @@ +test-toctree-max-depth +====================== + +.. toctree:: + :numbered: + :maxdepth: 2 + + foo + bar diff --git a/tests/test_build_latex.py b/tests/test_build_latex.py index 81f436c3a..9b58a6746 100644 --- a/tests/test_build_latex.py +++ b/tests/test_build_latex.py @@ -430,7 +430,7 @@ def test_latex_logo_if_not_found(app, status, warning): assert isinstance(exc, SphinxError) -@with_app(buildername='latex', testroot='tocdepth', +@with_app(buildername='latex', testroot='toctree-maxdepth', confoverrides={'latex_documents': [ ('index', 'SphinxTests.tex', 'Sphinx Tests Documentation', 'Georg Brandl', 'manual'), @@ -444,7 +444,7 @@ def test_toctree_maxdepth_manual(app, status, warning): assert '\\setcounter{tocdepth}{1}' in result -@with_app(buildername='latex', testroot='tocdepth', +@with_app(buildername='latex', testroot='toctree-maxdepth', confoverrides={'latex_documents': [ ('index', 'SphinxTests.tex', 'Sphinx Tests Documentation', 'Georg Brandl', 'howto'), From e03dc8d27e7eeecea6801cf18d4360c37e877376 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Wed, 6 Jan 2016 11:13:30 +0900 Subject: [PATCH 25/48] Fix #2072: Footnotes in chapter-titles do not appear in PDF output --- CHANGES | 1 + sphinx/writers/latex.py | 2 ++ tests/roots/test-footnotes/index.rst | 4 +++- tests/test_build_latex.py | 34 +++++++++++++++------------- 4 files changed, 24 insertions(+), 17 deletions(-) diff --git a/CHANGES b/CHANGES index de0e01bfa..a3b950e64 100644 --- a/CHANGES +++ b/CHANGES @@ -35,6 +35,7 @@ Bugs fixed * #771: Fix latex output doesn't set tocdepth * #1820: On Windows, console coloring is broken with colorama version 0.3.3. Now sphinx use colorama>=0.3.5 to avoid this problem. +* #2072: Fix footnotes in chapter-titles do not appear in PDF output Release 1.3.3 (released Dec 2, 2015) ==================================== diff --git a/sphinx/writers/latex.py b/sphinx/writers/latex.py index 478d50318..784c58c21 100644 --- a/sphinx/writers/latex.py +++ b/sphinx/writers/latex.py @@ -724,6 +724,7 @@ class LaTeXTranslator(nodes.NodeVisitor): self.body.append(r'\%s{' % self.sectionnames[-1]) self.context.append('}\n') + self.restrict_footnote(node) if self.next_section_ids: for id in self.next_section_ids: self.context[-1] += self.hypertarget(id, anchor=False) @@ -753,6 +754,7 @@ class LaTeXTranslator(nodes.NodeVisitor): self.table.caption = self.popbody() else: self.body.append(self.context.pop()) + self.unrestrict_footnote(node) def visit_subtitle(self, node): if isinstance(node.parent, nodes.sidebar): diff --git a/tests/roots/test-footnotes/index.rst b/tests/roots/test-footnotes/index.rst index 0c0e29b39..a20052037 100644 --- a/tests/roots/test-footnotes/index.rst +++ b/tests/roots/test-footnotes/index.rst @@ -33,9 +33,11 @@ The section with a reference to [AuthorYear]_ .. [1] Second .. [#] Third -The section with a reference to [1]_ +The section with a reference to [#]_ ===================================== +.. [#] Footnote in section + `URL in term `_ Description Description Description ... diff --git a/tests/test_build_latex.py b/tests/test_build_latex.py index 9b58a6746..e86a794fa 100644 --- a/tests/test_build_latex.py +++ b/tests/test_build_latex.py @@ -332,15 +332,17 @@ def test_reference_in_caption(app, status, warning): 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 - assert '\\chapter{The section with a reference to \\protect\\footnotemark[1]}' in result + assert ('\\chapter{The section with a reference to \\protect\\footnotemark[4]}\n' + '\\label{index:the-section-with-a-reference-to}' + '\\footnotetext[4]{\nFootnote in section\n}' in result) assert ('\\caption{This is the figure caption with a footnote to ' - '\\protect\\footnotemark[5].}\end{figure}\n' - '\\footnotetext[5]{\nFootnote in caption\n}')in result - assert ('\\caption{footnote \\protect\\footnotemark[6] ' + '\\protect\\footnotemark[6].}\end{figure}\n' + '\\footnotetext[6]{\nFootnote in caption\n}')in result + assert ('\\caption{footnote \\protect\\footnotemark[7] ' 'in caption of normal table}') in result - assert '\\end{threeparttable}\n\n\\footnotetext[6]{\nFoot note in table\n}' in result - assert '\\caption{footnote \\protect\\footnotemark[7] in caption of longtable}' in result - assert '\end{longtable}\n\n\\footnotetext[7]{\nFoot note in longtable\n}' in result + assert '\\end{threeparttable}\n\n\\footnotetext[7]{\nFoot note in table\n}' in result + assert '\\caption{footnote \\protect\\footnotemark[8] in caption of longtable}' in result + assert '\end{longtable}\n\n\\footnotetext[8]{\nFoot note in longtable\n}' in result @with_app(buildername='latex', testroot='footnotes', @@ -359,8 +361,8 @@ def test_latex_show_urls_is_inline(app, status, warning): '(http://sphinx-doc.org/\\textasciitilde{}test/)' in result) assert ('\\item[{\\href{http://sphinx-doc.org/}{URL in term} (http://sphinx-doc.org/)}] ' '\\leavevmode\nDescription' in result) - assert ('\\item[{Footnote in term \\protect\\footnotemark[4]}] ' - '\\leavevmode\\footnotetext[4]{\nFootnote in term\n}\nDescription' in result) + assert ('\\item[{Footnote in term \\protect\\footnotemark[5]}] ' + '\\leavevmode\\footnotetext[5]{\nFootnote in term\n}\nDescription' in result) assert ('\\item[{\\href{http://sphinx-doc.org/}{Term in deflist} ' '(http://sphinx-doc.org/)}] \\leavevmode\nDescription' in result) assert ('\\href{https://github.com/sphinx-doc/sphinx}' @@ -384,12 +386,12 @@ def test_latex_show_urls_is_footnote(app, status, warning): assert 'Third footnote: \\footnote[5]{\nThird\n}' in result assert ('\\href{http://sphinx-doc.org/~test/}{URL including tilde}' '\\footnote[4]{\nhttp://sphinx-doc.org/\\textasciitilde{}test/\n}' in result) - assert ('\\item[{\\href{http://sphinx-doc.org/}{URL in term}\\protect\\footnotemark[6]}] ' - '\\leavevmode\\footnotetext[6]{\nhttp://sphinx-doc.org/\n}\nDescription' in result) - assert ('\\item[{Footnote in term \\protect\\footnotemark[8]}] ' - '\\leavevmode\\footnotetext[8]{\nFootnote in term\n}\nDescription' in result) - assert ('\\item[{\\href{http://sphinx-doc.org/}{Term in deflist}\\protect\\footnotemark[7]}] ' + assert ('\\item[{\\href{http://sphinx-doc.org/}{URL in term}\\protect\\footnotemark[7]}] ' '\\leavevmode\\footnotetext[7]{\nhttp://sphinx-doc.org/\n}\nDescription' in result) + assert ('\\item[{Footnote in term \\protect\\footnotemark[9]}] ' + '\\leavevmode\\footnotetext[9]{\nFootnote in term\n}\nDescription' in result) + assert ('\\item[{\\href{http://sphinx-doc.org/}{Term in deflist}\\protect\\footnotemark[8]}] ' + '\\leavevmode\\footnotetext[8]{\nhttp://sphinx-doc.org/\n}\nDescription' in result) assert ('\\href{https://github.com/sphinx-doc/sphinx}' '{https://github.com/sphinx-doc/sphinx}\n' in result) assert ('\\href{mailto:sphinx-dev@googlegroups.com}' @@ -411,8 +413,8 @@ def test_latex_show_urls_is_no(app, status, warning): assert '\\href{http://sphinx-doc.org/~test/}{URL including tilde}' in result assert ('\\item[{\\href{http://sphinx-doc.org/}{URL in term}}] ' '\\leavevmode\nDescription' in result) - assert ('\\item[{Footnote in term \\protect\\footnotemark[4]}] ' - '\\leavevmode\\footnotetext[4]{\nFootnote in term\n}\nDescription' in result) + assert ('\\item[{Footnote in term \\protect\\footnotemark[5]}] ' + '\\leavevmode\\footnotetext[5]{\nFootnote in term\n}\nDescription' in result) assert ('\\item[{\\href{http://sphinx-doc.org/}{Term in deflist}}] ' '\\leavevmode\nDescription' in result) assert ('\\href{https://github.com/sphinx-doc/sphinx}' From c100089334acccf9ed29a409ac7821ee75359ad6 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Fri, 1 Jan 2016 04:55:33 -0500 Subject: [PATCH 26/48] Sort attributes in inheritance diagrams. This ensures that the graphviz script is always the same and thus the filename (which is the hash of the script and other things) remains consistent. --- sphinx/ext/inheritance_diagram.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sphinx/ext/inheritance_diagram.py b/sphinx/ext/inheritance_diagram.py index 0f4a18c63..24af6f168 100644 --- a/sphinx/ext/inheritance_diagram.py +++ b/sphinx/ext/inheritance_diagram.py @@ -227,10 +227,10 @@ class InheritanceGraph(object): } def _format_node_attrs(self, attrs): - return ','.join(['%s=%s' % x for x in attrs.items()]) + return ','.join(['%s=%s' % x for x in sorted(attrs.items())]) def _format_graph_attrs(self, attrs): - return ''.join(['%s=%s;\n' % x for x in attrs.items()]) + return ''.join(['%s=%s;\n' % x for x in sorted(attrs.items())]) def generate_dot(self, name, urls={}, env=None, graph_attrs={}, node_attrs={}, edge_attrs={}): From 2be21e340e2e5b2d22ec069a9c3d5549d2b78c6b Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Thu, 7 Jan 2016 14:15:34 +0900 Subject: [PATCH 27/48] Fix #1580: Paragraphs in longtable don't work in Latex output --- CHANGES | 1 + sphinx/writers/latex.py | 2 ++ 2 files changed, 3 insertions(+) diff --git a/CHANGES b/CHANGES index a3b950e64..bff398d76 100644 --- a/CHANGES +++ b/CHANGES @@ -36,6 +36,7 @@ Bugs fixed * #1820: On Windows, console coloring is broken with colorama version 0.3.3. Now sphinx use colorama>=0.3.5 to avoid this problem. * #2072: Fix footnotes in chapter-titles do not appear in PDF output +* #1580: Fix paragraphs in longtable don't work in Latex output Release 1.3.3 (released Dec 2, 2015) ==================================== diff --git a/sphinx/writers/latex.py b/sphinx/writers/latex.py index 784c58c21..38a2a8459 100644 --- a/sphinx/writers/latex.py +++ b/sphinx/writers/latex.py @@ -1209,6 +1209,8 @@ class LaTeXTranslator(nodes.NodeVisitor): def visit_paragraph(self, node): self.body.append('\n') + if self.table: + self.table.has_problematic = True def depart_paragraph(self, node): self.body.append('\n') From bef3025c3c668fff60dfdf26c22c3d38a7b05ee8 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Thu, 7 Jan 2016 14:18:40 +0900 Subject: [PATCH 28/48] Fix #1900: BuildEnvironment.srcdir documentation gives false information --- doc/extdev/envapi.rst | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/doc/extdev/envapi.rst b/doc/extdev/envapi.rst index 84ad3e0d9..729725fc5 100644 --- a/doc/extdev/envapi.rst +++ b/doc/extdev/envapi.rst @@ -17,7 +17,11 @@ Build environment API .. attribute:: srcdir - Source directory (the directory containing ``conf.py``). + Source directory. + + .. attribute:: confdir + + Directory containing ``conf.py``. .. attribute:: doctreedir From eea055dfb262f3d50235e6e245e0c250299b6c42 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Thu, 7 Jan 2016 17:08:54 +0900 Subject: [PATCH 29/48] Fix #1366: centered image not centered in latex --- CHANGES | 1 + sphinx/writers/latex.py | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGES b/CHANGES index bff398d76..8e77f1099 100644 --- a/CHANGES +++ b/CHANGES @@ -37,6 +37,7 @@ Bugs fixed Now sphinx use colorama>=0.3.5 to avoid this problem. * #2072: Fix footnotes in chapter-titles do not appear in PDF output * #1580: Fix paragraphs in longtable don't work in Latex output +* #1366: Fix centered image not centered in latex Release 1.3.3 (released Dec 2, 2015) ==================================== diff --git a/sphinx/writers/latex.py b/sphinx/writers/latex.py index 38a2a8459..ce27dd07b 100644 --- a/sphinx/writers/latex.py +++ b/sphinx/writers/latex.py @@ -1285,12 +1285,12 @@ class LaTeXTranslator(nodes.NodeVisitor): (1, 'top'): ('', ''), (1, 'middle'): ('\\raisebox{-0.5\\height}{', '}'), (1, 'bottom'): ('\\raisebox{-\\height}{', '}'), - (0, 'center'): ('{\\hfill', '\\hfill}'), + (0, 'center'): ('{\\hspace*{\\fill}', '\\hspace*{\\fill}}'), # These 2 don't exactly do the right thing. The image should # be floated alongside the paragraph. See # http://www.w3.org/TR/html4/struct/objects.html#adef-align-IMG - (0, 'left'): ('{', '\\hfill}'), - (0, 'right'): ('{\\hfill', '}'), + (0, 'left'): ('{', '\\hspace*{\\fill}}'), + (0, 'right'): ('{\\hspace*{\\fill}', '}'), } try: pre.append(align_prepost[is_inline, attrs['align']][0]) From c6c9c5c26438853ae20ae40e3b29d030f8b7fd31 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Fri, 8 Jan 2016 00:37:33 +0900 Subject: [PATCH 30/48] Fix #1860: Man page using :samp: with braces - font doesn't reset --- CHANGES | 1 + sphinx/writers/manpage.py | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/CHANGES b/CHANGES index 8e77f1099..a5d6dc2e5 100644 --- a/CHANGES +++ b/CHANGES @@ -38,6 +38,7 @@ Bugs fixed * #2072: Fix footnotes in chapter-titles do not appear in PDF output * #1580: Fix paragraphs in longtable don't work in Latex output * #1366: Fix centered image not centered in latex +* #1860: Fix man page using ``:samp:`` with braces - font doesn't reset Release 1.3.3 (released Dec 2, 2015) ==================================== diff --git a/sphinx/writers/manpage.py b/sphinx/writers/manpage.py index 4343f6a33..30e77165f 100644 --- a/sphinx/writers/manpage.py +++ b/sphinx/writers/manpage.py @@ -30,12 +30,42 @@ class ManualPageWriter(Writer): self.builder.translator_class or ManualPageTranslator) def translate(self): + transform = NestedInlineTransform(self.document) + transform.apply() visitor = self.translator_class(self.builder, self.document) self.visitor = visitor self.document.walkabout(visitor) self.output = visitor.astext() +class NestedInlineTransform(object): + """ + Flatten nested inline nodes: + + Before: + foo=1&bar=2 + After: + foo=var&bar=2 + """ + def __init__(self, document): + self.document = document + + def apply(self): + def is_inline(node): + return isinstance(node, (nodes.literal, nodes.emphasis, nodes.strong)) + + for node in self.document.traverse(is_inline): + if any(is_inline(subnode) for subnode in node): + pos = node.parent.index(node) + for subnode in reversed(node[1:]): + node.remove(subnode) + if is_inline(subnode): + node.parent.insert(pos + 1, subnode) + else: + newnode = node.__class__('', subnode, **node.attributes) + node.parent.insert(pos + 1, newnode) + + class ManualPageTranslator(BaseTranslator): """ Custom translator. From 23eb0e24fcd3020611a8dddcc4bb31db83a9f193 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Fri, 8 Jan 2016 16:00:26 +0900 Subject: [PATCH 31/48] Add testcase for #1860 --- sphinx/search/ja.py | 5 +++++ tests/test_build_manpage.py | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 tests/test_build_manpage.py diff --git a/sphinx/search/ja.py b/sphinx/search/ja.py index 23de74d37..7c8e2ea97 100644 --- a/sphinx/search/ja.py +++ b/sphinx/search/ja.py @@ -29,6 +29,7 @@ try: except ImportError: native_module = False +from sphinx.errors import SphinxError from sphinx.search import SearchLanguage @@ -49,10 +50,14 @@ class MecabBinder(object): else: result = self.ctypes_libmecab.mecab_sparse_tostr( self.ctypes_mecab, input.encode(self.dict_encode)) + if result is None: + raise SphinxError('Failed to tokenize text:\nMecab: %s\nInput:\n%s' % + (self.ctypes_mecab, input)) if PY3: return result.split(' ') else: return result.decode(self.dict_encode).split(' ') + return result.decode(self.dict_encode).split(' ') def init_native(self, options): param = '-Owakati' diff --git a/tests/test_build_manpage.py b/tests/test_build_manpage.py new file mode 100644 index 000000000..85ae5be44 --- /dev/null +++ b/tests/test_build_manpage.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +""" + test_build_manpage + ~~~~~~~~~~~~~~~~~~ + + Test the build process with manpage builder with the test root. + + :copyright: Copyright 2007-2015 by the Sphinx team, see AUTHORS. + :license: BSD, see LICENSE for details. +""" +from __future__ import print_function + +from util import with_app + + +@with_app(buildername='man') +def test_all(app, status, warning): + app.builder.build_all() + assert (app.outdir / 'SphinxTests.1').exists() + + content = (app.outdir / 'SphinxTests.1').text() + assert r'\fBprint \fP\fIi\fP\fB\en\fP' in content From 24c42817ed2524415c1a0d11f374a020d7ca8828 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Fri, 8 Jan 2016 16:27:30 +0900 Subject: [PATCH 32/48] Revert search/ja.py It is not a part of 'testcase for #1860'. It's my miss commit. Sorry. --- sphinx/search/ja.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/sphinx/search/ja.py b/sphinx/search/ja.py index 7c8e2ea97..23de74d37 100644 --- a/sphinx/search/ja.py +++ b/sphinx/search/ja.py @@ -29,7 +29,6 @@ try: except ImportError: native_module = False -from sphinx.errors import SphinxError from sphinx.search import SearchLanguage @@ -50,14 +49,10 @@ class MecabBinder(object): else: result = self.ctypes_libmecab.mecab_sparse_tostr( self.ctypes_mecab, input.encode(self.dict_encode)) - if result is None: - raise SphinxError('Failed to tokenize text:\nMecab: %s\nInput:\n%s' % - (self.ctypes_mecab, input)) if PY3: return result.split(' ') else: return result.decode(self.dict_encode).split(' ') - return result.decode(self.dict_encode).split(' ') def init_native(self, options): param = '-Owakati' From 62c49763f8e17c8c8835a88ecd19a0ed7ca5a162 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Klitzing?= Date: Wed, 16 Sep 2015 12:08:12 +0200 Subject: [PATCH 33/48] Fix broken TOC of PDFs if section includes an image If someone adds an image to a section it will be added to the sidebar TOC of a PDF, too. A PDF viewer will show the "width and height" data instead of an image. So we need to filter out images for this with the optional "short title" of latex sections. --- sphinx/writers/latex.py | 9 +++++++-- tests/roots/test-image-in-section/conf.py | 11 +++++++++++ tests/roots/test-image-in-section/index.rst | 18 ++++++++++++++++++ tests/roots/test-image-in-section/pic.png | Bin 0 -> 218 bytes tests/test_build_latex.py | 13 +++++++++++++ 5 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 tests/roots/test-image-in-section/conf.py create mode 100644 tests/roots/test-image-in-section/index.rst create mode 100644 tests/roots/test-image-in-section/pic.png diff --git a/sphinx/writers/latex.py b/sphinx/writers/latex.py index 784c58c21..f9dc620c5 100644 --- a/sphinx/writers/latex.py +++ b/sphinx/writers/latex.py @@ -25,6 +25,7 @@ from sphinx import highlighting from sphinx.errors import SphinxError from sphinx.locale import admonitionlabels, _ from sphinx.util import split_into +from sphinx.util.nodes import clean_astext from sphinx.util.osutil import ustrftime from sphinx.util.texescape import tex_escape_map, tex_replace_map from sphinx.util.smartypants import educate_quotes_latex @@ -717,11 +718,15 @@ class LaTeXTranslator(nodes.NodeVisitor): self.this_is_the_title = 0 raise nodes.SkipNode elif isinstance(parent, nodes.section): + short = '' + if node.traverse(nodes.image): + short = '[%s]' % ' '.join(clean_astext(node).split()).translate(tex_escape_map) + try: - self.body.append(r'\%s{' % self.sectionnames[self.sectionlevel]) + self.body.append(r'\%s%s{' % (self.sectionnames[self.sectionlevel], short)) except IndexError: # just use "subparagraph", it's not numbered anyway - self.body.append(r'\%s{' % self.sectionnames[-1]) + self.body.append(r'\%s%s{' % (self.sectionnames[-1], short)) self.context.append('}\n') self.restrict_footnote(node) diff --git a/tests/roots/test-image-in-section/conf.py b/tests/roots/test-image-in-section/conf.py new file mode 100644 index 000000000..255345e45 --- /dev/null +++ b/tests/roots/test-image-in-section/conf.py @@ -0,0 +1,11 @@ +# -*- coding: utf-8 -*- + +master_doc = 'index' + +rst_epilog = ''' +.. |picture| image:: pic.png + :width: 15pt + :height: 15pt + :alt: alternative_text +''' + diff --git a/tests/roots/test-image-in-section/index.rst b/tests/roots/test-image-in-section/index.rst new file mode 100644 index 000000000..a69db0a77 --- /dev/null +++ b/tests/roots/test-image-in-section/index.rst @@ -0,0 +1,18 @@ +test-image-in-section +===================== +this is dummy content + + +|picture| Test section +---------------------- +blah blah blah + + +Another section +--------------- +another blah + + +Other [blah] |picture| section +------------------------------ +other blah diff --git a/tests/roots/test-image-in-section/pic.png b/tests/roots/test-image-in-section/pic.png new file mode 100644 index 0000000000000000000000000000000000000000..1081dc1439fb984dfa7ef627afe3c7dc476fdbce GIT binary patch literal 218 zcmeAS@N?(olHy`uVBq!ia0vp^j6iI|!3HFkf4uMuBv2gW?!>U}oXkrghqJ&VvY3H^ zTNs2H8D`Cq01C2~c>21s-(chw7$R|bZ|_0D0|q>YSbqDzW^|HYIk%*-&O)* Date: Wed, 25 Mar 2015 23:20:12 +0900 Subject: [PATCH 34/48] Fix #1807: Sphinx crashes in japanese indexing in some systems. Modified to specify the C type, if directly using the libmecab. --- CHANGES | 1 + sphinx/search/ja.py | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index a5d6dc2e5..70c1e9fa8 100644 --- a/CHANGES +++ b/CHANGES @@ -39,6 +39,7 @@ Bugs fixed * #1580: Fix paragraphs in longtable don't work in Latex output * #1366: Fix centered image not centered in latex * #1860: Fix man page using ``:samp:`` with braces - font doesn't reset +* #1610 Sphinx crashes in japanese indexing in some systems. Release 1.3.3 (released Dec 2, 2015) ==================================== diff --git a/sphinx/search/ja.py b/sphinx/search/ja.py index 23de74d37..8536173ff 100644 --- a/sphinx/search/ja.py +++ b/sphinx/search/ja.py @@ -85,10 +85,15 @@ class MecabBinder(object): dict = options.get('dict') if dict: param += ' -d %s' % dict + + fs_enc = sys.getfilesystemencoding() or sys.getdefaultencoding() self.ctypes_libmecab = ctypes.CDLL(libpath) + self.ctypes_libmecab.mecab_new2.argtypes = (ctypes.c_char_p,) + self.ctypes_libmecab.mecab_new2.restype = ctypes.c_void_p + self.ctypes_libmecab.mecab_sparse_tostr.argtypes = (ctypes.c_void_p, ctypes.c_char_p) self.ctypes_libmecab.mecab_sparse_tostr.restype = ctypes.c_char_p - self.ctypes_mecab = self.ctypes_libmecab.mecab_new2(param) + self.ctypes_mecab = ctypes.c_void_p(self.ctypes_libmecab.mecab_new2(param.encode(fs_enc))) def __del__(self): if self.ctypes_libmecab: From fe101177c365471ef466143b30854f92d38db23b Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Fri, 8 Jan 2016 21:27:10 +0900 Subject: [PATCH 35/48] Fix indentation --- sphinx/search/ja.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sphinx/search/ja.py b/sphinx/search/ja.py index 8536173ff..5ccff34b6 100644 --- a/sphinx/search/ja.py +++ b/sphinx/search/ja.py @@ -85,7 +85,7 @@ class MecabBinder(object): dict = options.get('dict') if dict: param += ' -d %s' % dict - + fs_enc = sys.getfilesystemencoding() or sys.getdefaultencoding() self.ctypes_libmecab = ctypes.CDLL(libpath) From 85a9e820dc94d4bf44414fb2caea894fc9c95480 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Fri, 8 Jan 2016 21:36:42 +0900 Subject: [PATCH 36/48] Fix Sphinx crashes if mecab initialization failed --- CHANGES | 3 ++- sphinx/search/ja.py | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index 70c1e9fa8..8979c4049 100644 --- a/CHANGES +++ b/CHANGES @@ -39,7 +39,8 @@ Bugs fixed * #1580: Fix paragraphs in longtable don't work in Latex output * #1366: Fix centered image not centered in latex * #1860: Fix man page using ``:samp:`` with braces - font doesn't reset -* #1610 Sphinx crashes in japanese indexing in some systems. +* #1610: Sphinx crashes in japanese indexing in some systems +* Fix Sphinx crashes if mecab initialization failed Release 1.3.3 (released Dec 2, 2015) ==================================== diff --git a/sphinx/search/ja.py b/sphinx/search/ja.py index 5ccff34b6..3acbb649a 100644 --- a/sphinx/search/ja.py +++ b/sphinx/search/ja.py @@ -29,6 +29,7 @@ try: except ImportError: native_module = False +from sphinx.errors import SphinxError from sphinx.search import SearchLanguage @@ -93,7 +94,9 @@ class MecabBinder(object): self.ctypes_libmecab.mecab_new2.restype = ctypes.c_void_p self.ctypes_libmecab.mecab_sparse_tostr.argtypes = (ctypes.c_void_p, ctypes.c_char_p) self.ctypes_libmecab.mecab_sparse_tostr.restype = ctypes.c_char_p - self.ctypes_mecab = ctypes.c_void_p(self.ctypes_libmecab.mecab_new2(param.encode(fs_enc))) + self.ctypes_mecab = self.ctypes_libmecab.mecab_new2(param.encode(fs_enc)) + if self.ctypes_mecab is None: + raise SphinxError('mecab initialization failed') def __del__(self): if self.ctypes_libmecab: From 386a74a0ee91865f8479c6275d4e38e0392d32b3 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Fri, 8 Jan 2016 21:41:52 +0900 Subject: [PATCH 37/48] Update CHANGES for PR #2160 --- CHANGES | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES b/CHANGES index 8979c4049..f38349088 100644 --- a/CHANGES +++ b/CHANGES @@ -41,6 +41,7 @@ Bugs fixed * #1860: Fix man page using ``:samp:`` with braces - font doesn't reset * #1610: Sphinx crashes in japanese indexing in some systems * Fix Sphinx crashes if mecab initialization failed +* #2160: Fix broken TOC of PDFs if section includes an image Release 1.3.3 (released Dec 2, 2015) ==================================== From 119790cffb2e8e191d9eb69432bcef6b1e53871b Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sat, 9 Jan 2016 09:45:32 +0900 Subject: [PATCH 38/48] Fix #2172: Dysfunctional admonition \py@lightbox in sphinx.sty --- CHANGES | 1 + sphinx/texinputs/sphinx.sty | 19 +++++++++---------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/CHANGES b/CHANGES index f38349088..07b0dcaab 100644 --- a/CHANGES +++ b/CHANGES @@ -42,6 +42,7 @@ Bugs fixed * #1610: Sphinx crashes in japanese indexing in some systems * Fix Sphinx crashes if mecab initialization failed * #2160: Fix broken TOC of PDFs if section includes an image +* #2172: Fix dysfunctional admonition \py@lightbox in sphinx.sty Release 1.3.3 (released Dec 2, 2015) ==================================== diff --git a/sphinx/texinputs/sphinx.sty b/sphinx/texinputs/sphinx.sty index 03525faec..a5425e542 100644 --- a/sphinx/texinputs/sphinx.sty +++ b/sphinx/texinputs/sphinx.sty @@ -269,16 +269,15 @@ \fbox{\TheSbox} } -\newcommand{\py@lightbox}{{% - \setlength\parskip{0pt}\par - \noindent\rule[0ex]{\linewidth}{0.5pt}% - \par\noindent\vspace{-0.5ex}% - }} -\newcommand{\py@endlightbox}{{% - \setlength{\parskip}{0pt}% - \par\noindent\rule[0.5ex]{\linewidth}{0.5pt}% - \par\vspace{-0.5ex}% - }} +\newcommand{\py@lightbox}{% + \par\allowbreak + \noindent\rule{\linewidth}{0.5pt}\par\nobreak + {\parskip\z@skip\noindent}% + } +\newcommand{\py@endlightbox}{% + \par\nobreak + {\parskip\z@skip\noindent\rule[.4\baselineskip]{\linewidth}{0.5pt}}\par + } % Some are quite plain: \newcommand{\py@noticestart@note}{\py@lightbox} From 2ebf9d64561a7812a6649940c09da5b07516729c Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sat, 9 Jan 2016 09:49:11 +0900 Subject: [PATCH 39/48] Update CHANGES for #2172 --- CHANGES | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 07b0dcaab..3b347ba5a 100644 --- a/CHANGES +++ b/CHANGES @@ -42,7 +42,7 @@ Bugs fixed * #1610: Sphinx crashes in japanese indexing in some systems * Fix Sphinx crashes if mecab initialization failed * #2160: Fix broken TOC of PDFs if section includes an image -* #2172: Fix dysfunctional admonition \py@lightbox in sphinx.sty +* #2172: Fix dysfunctional admonition \py@lightbox in sphinx.sty. Thanks to jfbu. Release 1.3.3 (released Dec 2, 2015) ==================================== From e7fa8a6c2b39b15ef08c30b9ac536cf33ab900af Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sat, 9 Jan 2016 10:03:21 +0900 Subject: [PATCH 40/48] Fix ``p`` is always used for table spec (refs #1580) --- sphinx/writers/latex.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sphinx/writers/latex.py b/sphinx/writers/latex.py index 49e4b5101..9d94f28a6 100644 --- a/sphinx/writers/latex.py +++ b/sphinx/writers/latex.py @@ -1106,6 +1106,8 @@ class LaTeXTranslator(nodes.NodeVisitor): context += str(extracols + 1) context += '}{l|}{}' self.table.col += extracols + if len(node.traverse(nodes.paragraph)) >= 2: + self.table.has_problematic = True self.context.append(context) def depart_entry(self, node): @@ -1214,8 +1216,6 @@ class LaTeXTranslator(nodes.NodeVisitor): def visit_paragraph(self, node): self.body.append('\n') - if self.table: - self.table.has_problematic = True def depart_paragraph(self, node): self.body.append('\n') From ac28f9b27125d866f3fe1ff67ed051f27e7d3771 Mon Sep 17 00:00:00 2001 From: shimizukawa Date: Sat, 9 Jan 2016 15:33:43 +0900 Subject: [PATCH 41/48] Fix #2198,#2205: ``make gettext`` generate broken msgid for definition lists. It's a regression by #1855. --- CHANGES | 1 + sphinx/util/nodes.py | 6 ++-- tests/roots/test-intl/definition_terms.po | 8 +++--- tests/roots/test-intl/definition_terms.txt | 4 +-- tests/test_intl.py | 32 ++++++++++++++++++++-- 5 files changed, 40 insertions(+), 11 deletions(-) diff --git a/CHANGES b/CHANGES index 3b347ba5a..8c0a33dde 100644 --- a/CHANGES +++ b/CHANGES @@ -43,6 +43,7 @@ Bugs fixed * Fix Sphinx crashes if mecab initialization failed * #2160: Fix broken TOC of PDFs if section includes an image * #2172: Fix dysfunctional admonition \py@lightbox in sphinx.sty. Thanks to jfbu. +* #2198,#2205: ``make gettext`` generate broken msgid for definition lists. Release 1.3.3 (released Dec 2, 2015) ==================================== diff --git a/sphinx/util/nodes.py b/sphinx/util/nodes.py index 2b0fff81d..d35f45265 100644 --- a/sphinx/util/nodes.py +++ b/sphinx/util/nodes.py @@ -47,8 +47,10 @@ def apply_source_workaround(node): node.line = definition_list_item.line - 1 node.rawsource = node.astext() # set 'classifier1' (or 'classifier2') if isinstance(node, nodes.term): - # overwrite: ``term : classifier1 : classifier2`` -> ``term text`` - node.rawsource = node.astext() + # strip classifier from rawsource of term + for classifier in reversed(node.parent.traverse(nodes.classifier)): + node.rawsource = re.sub( + '\s*:\s*%s' % classifier.astext(), '', node.rawsource) # workaround: recommonmark-0.2.0 doesn't set rawsource attribute if not node.rawsource: diff --git a/tests/roots/test-intl/definition_terms.po b/tests/roots/test-intl/definition_terms.po index 6de1d1c42..8a8199378 100644 --- a/tests/roots/test-intl/definition_terms.po +++ b/tests/roots/test-intl/definition_terms.po @@ -25,14 +25,14 @@ msgstr "SOME TERM" msgid "The corresponding definition" msgstr "THE CORRESPONDING DEFINITION" -msgid "Some other term" -msgstr "SOME OTHER TERM" +msgid "Some *term* `with link `__" +msgstr "SOME *TERM* `WITH LINK `__" msgid "The corresponding definition #2" msgstr "THE CORRESPONDING DEFINITION #2" -msgid "Some term with" -msgstr "SOME TERM WITH" +msgid "Some **term** with" +msgstr "SOME **TERM** WITH" msgid "classifier1" msgstr "CLASSIFIER1" diff --git a/tests/roots/test-intl/definition_terms.txt b/tests/roots/test-intl/definition_terms.txt index 66230f98f..e85953024 100644 --- a/tests/roots/test-intl/definition_terms.txt +++ b/tests/roots/test-intl/definition_terms.txt @@ -6,9 +6,9 @@ i18n with definition terms Some term The corresponding definition -Some other term +Some *term* `with link `__ The corresponding definition #2 -Some term with : classifier1 : classifier2 +Some **term** with : classifier1 : classifier2 The corresponding definition diff --git a/tests/test_intl.py b/tests/test_intl.py index 0086b63f2..35c18b1e6 100644 --- a/tests/test_intl.py +++ b/tests/test_intl.py @@ -16,6 +16,7 @@ import re from subprocess import Popen, PIPE from xml.etree import ElementTree +from babel.messages import pofile from nose.tools import assert_equal from six import string_types @@ -175,16 +176,16 @@ def test_text_builder(app, status, warning): u'WARNING: Literal block expected; none found.' yield assert_re_search, expected_warning_expr, warnings - # --- definition terms: regression test for #975 + # --- definition terms: regression test for #975, #2198, #2205 result = (app.outdir / 'definition_terms.txt').text(encoding='utf-8') expect = (u"\nI18N WITH DEFINITION TERMS" u"\n**************************\n" u"\nSOME TERM" u"\n THE CORRESPONDING DEFINITION\n" - u"\nSOME OTHER TERM" + u"\nSOME *TERM* WITH LINK" u"\n THE CORRESPONDING DEFINITION #2\n" - u"\nSOME TERM WITH : CLASSIFIER1 : CLASSIFIER2" + u"\nSOME **TERM** WITH : CLASSIFIER1 : CLASSIFIER2" u"\n THE CORRESPONDING DEFINITION\n" ) yield assert_equal, result, expect @@ -304,6 +305,31 @@ def test_text_builder(app, status, warning): yield assert_in, d.upper() + " BODY", result +@gen_with_intl_app('gettext', freshenv=True) +def test_gettext_builder(app, status, warning): + app.builder.build_all() + + # --- definition terms: regression test for #2198, #2205 + expect = pofile.read_po((app.srcdir / 'definition_terms.po').open()) + actual = pofile.read_po((app.outdir / 'definition_terms.pot').open()) + for expect_msg in [m for m in expect if m.id]: + yield assert_in, expect_msg.id, [m.id for m in actual if m.id] + + # --- glossary terms: regression test for #1090 + expect = pofile.read_po((app.srcdir / 'glossary_terms.po').open()) + actual = pofile.read_po((app.outdir / 'glossary_terms.pot').open()) + for expect_msg in [m for m in expect if m.id]: + yield assert_in, expect_msg.id, [m.id for m in actual if m.id] + warnings = warning.getvalue().replace(os.sep, '/') + yield assert_not_in, 'term not in glossary', warnings + + # --- glossary term inconsistencies: regression test for #1090 + expect = pofile.read_po((app.srcdir / 'glossary_terms_inconsistency.po').open()) + actual = pofile.read_po((app.outdir / 'glossary_terms_inconsistency.pot').open()) + for expect_msg in [m for m in expect if m.id]: + yield assert_in, expect_msg.id, [m.id for m in actual if m.id] + + @gen_with_intl_app('html', freshenv=True) def test_html_builder(app, status, warning): app.builder.build_all() From 39e403b8ac134fb0dc5b733d5b7ac7ebc38825e0 Mon Sep 17 00:00:00 2001 From: shimizukawa Date: Sat, 9 Jan 2016 15:35:56 +0900 Subject: [PATCH 42/48] fix testing for text builder that generate _build/text/_build/text/_build/... recursive directories because *.txt in _build/text previously generated was detected as source file. --- tests/roots/test-autosummary/conf.py | 2 ++ tests/roots/test-build-text/conf.py | 1 + tests/roots/test-circular/conf.py | 1 + tests/roots/test-contentsname/conf.py | 1 + tests/roots/test-directive-code/conf.py | 1 + tests/roots/test-directive-only/conf.py | 1 + tests/roots/test-doctest/conf.py | 1 + tests/roots/test-docutilsconf/conf.py | 1 + tests/roots/test-domain-cpp/conf.py | 1 + tests/roots/test-double-inheriting-theme/conf.py | 1 + tests/roots/test-ext-graphviz/conf.py | 1 + tests/roots/test-ext-ifconfig/conf.py | 1 + tests/roots/test-ext-viewcode/conf.py | 1 + tests/roots/test-footnotes/conf.py | 1 + tests/roots/test-image-in-section/conf.py | 1 + tests/roots/test-intl/conf.py | 1 + tests/roots/test-numbered-circular/conf.py | 1 + tests/roots/test-numfig/conf.py | 1 + tests/roots/test-setup/doc/conf.py | 1 + tests/roots/test-templating/conf.py | 1 + tests/roots/test-theming/conf.py | 1 + tests/roots/test-tocdepth/conf.py | 1 + tests/roots/test-toctree-glob/conf.py | 1 + tests/roots/test-toctree-maxdepth/conf.py | 1 + tests/roots/test-versioning/conf.py | 1 + 25 files changed, 26 insertions(+) diff --git a/tests/roots/test-autosummary/conf.py b/tests/roots/test-autosummary/conf.py index d9a447480..5cb589cda 100644 --- a/tests/roots/test-autosummary/conf.py +++ b/tests/roots/test-autosummary/conf.py @@ -7,3 +7,5 @@ extensions = ['sphinx.ext.autosummary'] # The suffix of source filenames. source_suffix = '.rst' autosummary_generate = True + +exclude_patterns = ['_build'] diff --git a/tests/roots/test-build-text/conf.py b/tests/roots/test-build-text/conf.py index 1ba342a65..23d0ae840 100644 --- a/tests/roots/test-build-text/conf.py +++ b/tests/roots/test-build-text/conf.py @@ -1,2 +1,3 @@ master_doc = 'contents' source_suffix = '.txt' +exclude_patterns = ['_build'] diff --git a/tests/roots/test-circular/conf.py b/tests/roots/test-circular/conf.py index e69de29bb..027d21cda 100644 --- a/tests/roots/test-circular/conf.py +++ b/tests/roots/test-circular/conf.py @@ -0,0 +1 @@ +exclude_patterns = ['_build'] diff --git a/tests/roots/test-contentsname/conf.py b/tests/roots/test-contentsname/conf.py index cf05c9b5c..c46e40773 100644 --- a/tests/roots/test-contentsname/conf.py +++ b/tests/roots/test-contentsname/conf.py @@ -2,3 +2,4 @@ master_doc = 'index' html_theme = 'classic' +exclude_patterns = ['_build'] diff --git a/tests/roots/test-directive-code/conf.py b/tests/roots/test-directive-code/conf.py index f81c30bc4..e10f5e5fb 100644 --- a/tests/roots/test-directive-code/conf.py +++ b/tests/roots/test-directive-code/conf.py @@ -1,3 +1,4 @@ # -*- coding: utf-8 -*- master_doc = 'index' +exclude_patterns = ['_build'] diff --git a/tests/roots/test-directive-only/conf.py b/tests/roots/test-directive-only/conf.py index eb3a3d0d2..b9209f08b 100644 --- a/tests/roots/test-directive-only/conf.py +++ b/tests/roots/test-directive-only/conf.py @@ -1,2 +1,3 @@ project = 'test-directive-only' +exclude_patterns = ['_build'] diff --git a/tests/roots/test-doctest/conf.py b/tests/roots/test-doctest/conf.py index 2e721fb57..fcf6a6cda 100644 --- a/tests/roots/test-doctest/conf.py +++ b/tests/roots/test-doctest/conf.py @@ -3,3 +3,4 @@ extensions = ['sphinx.ext.doctest'] project = 'test project for doctest' master_doc = 'doctest' source_suffix = '.txt' +exclude_patterns = ['_build'] diff --git a/tests/roots/test-docutilsconf/conf.py b/tests/roots/test-docutilsconf/conf.py index 67074ec64..0a88a65fd 100644 --- a/tests/roots/test-docutilsconf/conf.py +++ b/tests/roots/test-docutilsconf/conf.py @@ -3,3 +3,4 @@ project = 'Sphinx docutils conf ' source_suffix = '.txt' keep_warnings = True +exclude_patterns = ['_build'] diff --git a/tests/roots/test-domain-cpp/conf.py b/tests/roots/test-domain-cpp/conf.py index cf05c9b5c..c46e40773 100644 --- a/tests/roots/test-domain-cpp/conf.py +++ b/tests/roots/test-domain-cpp/conf.py @@ -2,3 +2,4 @@ master_doc = 'index' html_theme = 'classic' +exclude_patterns = ['_build'] diff --git a/tests/roots/test-double-inheriting-theme/conf.py b/tests/roots/test-double-inheriting-theme/conf.py index dfdccc49b..c2f8db3b0 100644 --- a/tests/roots/test-double-inheriting-theme/conf.py +++ b/tests/roots/test-double-inheriting-theme/conf.py @@ -5,3 +5,4 @@ import sys, os templates_path = ['_templates'] master_doc = 'index' html_theme = 'base_theme2' +exclude_patterns = ['_build'] diff --git a/tests/roots/test-ext-graphviz/conf.py b/tests/roots/test-ext-graphviz/conf.py index cecd53668..6dce9d0c6 100644 --- a/tests/roots/test-ext-graphviz/conf.py +++ b/tests/roots/test-ext-graphviz/conf.py @@ -2,3 +2,4 @@ extensions = ['sphinx.ext.graphviz'] master_doc = 'index' +exclude_patterns = ['_build'] diff --git a/tests/roots/test-ext-ifconfig/conf.py b/tests/roots/test-ext-ifconfig/conf.py index 327bd126d..d205fe9f5 100644 --- a/tests/roots/test-ext-ifconfig/conf.py +++ b/tests/roots/test-ext-ifconfig/conf.py @@ -2,6 +2,7 @@ extensions = ['sphinx.ext.ifconfig'] master_doc = 'index' +exclude_patterns = ['_build'] confval1 = True diff --git a/tests/roots/test-ext-viewcode/conf.py b/tests/roots/test-ext-viewcode/conf.py index a99a72bbc..c2b358fb5 100644 --- a/tests/roots/test-ext-viewcode/conf.py +++ b/tests/roots/test-ext-viewcode/conf.py @@ -6,6 +6,7 @@ import os sys.path.insert(0, os.path.abspath('.')) extensions = ['sphinx.ext.autodoc', 'sphinx.ext.viewcode'] master_doc = 'index' +exclude_patterns = ['_build'] if 'test_linkcode' in tags: diff --git a/tests/roots/test-footnotes/conf.py b/tests/roots/test-footnotes/conf.py index cf05c9b5c..c46e40773 100644 --- a/tests/roots/test-footnotes/conf.py +++ b/tests/roots/test-footnotes/conf.py @@ -2,3 +2,4 @@ master_doc = 'index' html_theme = 'classic' +exclude_patterns = ['_build'] diff --git a/tests/roots/test-image-in-section/conf.py b/tests/roots/test-image-in-section/conf.py index 255345e45..7da44fdae 100644 --- a/tests/roots/test-image-in-section/conf.py +++ b/tests/roots/test-image-in-section/conf.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- master_doc = 'index' +exclude_patterns = ['_build'] rst_epilog = ''' .. |picture| image:: pic.png diff --git a/tests/roots/test-intl/conf.py b/tests/roots/test-intl/conf.py index 74446a143..aafd9ba79 100644 --- a/tests/roots/test-intl/conf.py +++ b/tests/roots/test-intl/conf.py @@ -7,3 +7,4 @@ templates_path = ['_templates'] html_additional_pages = {'index': 'index.html'} release = version = '2013.120' gettext_additional_targets = ['index'] +exclude_patterns = ['_build'] diff --git a/tests/roots/test-numbered-circular/conf.py b/tests/roots/test-numbered-circular/conf.py index e69de29bb..027d21cda 100644 --- a/tests/roots/test-numbered-circular/conf.py +++ b/tests/roots/test-numbered-circular/conf.py @@ -0,0 +1 @@ +exclude_patterns = ['_build'] diff --git a/tests/roots/test-numfig/conf.py b/tests/roots/test-numfig/conf.py index cf05c9b5c..c46e40773 100644 --- a/tests/roots/test-numfig/conf.py +++ b/tests/roots/test-numfig/conf.py @@ -2,3 +2,4 @@ master_doc = 'index' html_theme = 'classic' +exclude_patterns = ['_build'] diff --git a/tests/roots/test-setup/doc/conf.py b/tests/roots/test-setup/doc/conf.py index a55679a4b..b1c9acf46 100644 --- a/tests/roots/test-setup/doc/conf.py +++ b/tests/roots/test-setup/doc/conf.py @@ -3,3 +3,4 @@ project = 'Sphinx smallest project' source_suffix = '.txt' keep_warnings = True +exclude_patterns = ['_build'] diff --git a/tests/roots/test-templating/conf.py b/tests/roots/test-templating/conf.py index 225da82e7..ff8207454 100644 --- a/tests/roots/test-templating/conf.py +++ b/tests/roots/test-templating/conf.py @@ -5,6 +5,7 @@ source_suffix = '.txt' keep_warnings = True templates_path = ['_templates'] release = version = '2013.120' +exclude_patterns = ['_build'] extensions = ['sphinx.ext.autosummary'] autosummary_generate = ['autosummary_templating'] diff --git a/tests/roots/test-theming/conf.py b/tests/roots/test-theming/conf.py index 2717087d1..608afcfcd 100644 --- a/tests/roots/test-theming/conf.py +++ b/tests/roots/test-theming/conf.py @@ -2,4 +2,5 @@ html_theme = 'test-theme' master_doc = 'index' +exclude_patterns = ['_build'] diff --git a/tests/roots/test-tocdepth/conf.py b/tests/roots/test-tocdepth/conf.py index cf05c9b5c..c46e40773 100644 --- a/tests/roots/test-tocdepth/conf.py +++ b/tests/roots/test-tocdepth/conf.py @@ -2,3 +2,4 @@ master_doc = 'index' html_theme = 'classic' +exclude_patterns = ['_build'] diff --git a/tests/roots/test-toctree-glob/conf.py b/tests/roots/test-toctree-glob/conf.py index cf05c9b5c..c46e40773 100644 --- a/tests/roots/test-toctree-glob/conf.py +++ b/tests/roots/test-toctree-glob/conf.py @@ -2,3 +2,4 @@ master_doc = 'index' html_theme = 'classic' +exclude_patterns = ['_build'] diff --git a/tests/roots/test-toctree-maxdepth/conf.py b/tests/roots/test-toctree-maxdepth/conf.py index cf05c9b5c..c46e40773 100644 --- a/tests/roots/test-toctree-maxdepth/conf.py +++ b/tests/roots/test-toctree-maxdepth/conf.py @@ -2,3 +2,4 @@ master_doc = 'index' html_theme = 'classic' +exclude_patterns = ['_build'] diff --git a/tests/roots/test-versioning/conf.py b/tests/roots/test-versioning/conf.py index edcf92951..fb54e7972 100644 --- a/tests/roots/test-versioning/conf.py +++ b/tests/roots/test-versioning/conf.py @@ -1,3 +1,4 @@ project = 'versioning test root' master_doc = 'index' source_suffix = '.txt' +exclude_patterns = ['_build'] From e85ea7ed83b019bb8d7433f127e81b7e062f2de4 Mon Sep 17 00:00:00 2001 From: shimizukawa Date: Sat, 9 Jan 2016 17:22:30 +0900 Subject: [PATCH 43/48] Fix #2062: Escape characters in doctests are treated incorrectly with Python 2 In my current environment with Win10+Py2.7.10, SpoofOut result string doesn't necessary to decode. This commit might cause regression in older python versions.... --- CHANGES | 1 + sphinx/ext/doctest.py | 13 ------------- tests/roots/test-doctest/doctest.txt | 11 +++++++++++ 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/CHANGES b/CHANGES index 8c0a33dde..d062fb417 100644 --- a/CHANGES +++ b/CHANGES @@ -44,6 +44,7 @@ Bugs fixed * #2160: Fix broken TOC of PDFs if section includes an image * #2172: Fix dysfunctional admonition \py@lightbox in sphinx.sty. Thanks to jfbu. * #2198,#2205: ``make gettext`` generate broken msgid for definition lists. +* #2062: Escape characters in doctests are treated incorrectly with Python 2. Release 1.3.3 (released Dec 2, 2015) ==================================== diff --git a/sphinx/ext/doctest.py b/sphinx/ext/doctest.py index 5877be2eb..72ee9f85d 100644 --- a/sphinx/ext/doctest.py +++ b/sphinx/ext/doctest.py @@ -45,14 +45,6 @@ else: return text -class _SpoofOutSphinx(doctest._SpoofOut): - # override: convert console encoding to unicode - if PY2: - def getvalue(self): - result = doctest._SpoofOut.getvalue(self) - return result.decode('string_escape') - - # set up the necessary directives class TestDirective(Directive): @@ -184,11 +176,6 @@ class TestCode(object): class SphinxDocTestRunner(doctest.DocTestRunner): - def __init__(self, *args, **kw): - doctest.DocTestRunner.__init__(self, *args, **kw) - # Override a fake output target for capturing doctest output. - self._fakeout = _SpoofOutSphinx() - def summarize(self, out, verbose=None): string_io = StringIO() old_stdout = sys.stdout diff --git a/tests/roots/test-doctest/doctest.txt b/tests/roots/test-doctest/doctest.txt index ac5da0d15..053601f3c 100644 --- a/tests/roots/test-doctest/doctest.txt +++ b/tests/roots/test-doctest/doctest.txt @@ -136,3 +136,14 @@ umlauts: äöü. >>> print('Japanese: 日本語') Japanese: 日本語 +keep control char in raw string +------------------------------- + +.. doctest:: + + >>> print('one\ntwo') + one + two + >>> print(r'one\ntwo') + one\ntwo + From 7894f0bd9ca6796e329797a4a4da97dec4ff72f6 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sat, 9 Jan 2016 19:56:07 +0900 Subject: [PATCH 44/48] Fix #2225: If the option does not begin with dash, linking is not performed --- CHANGES | 1 + doc/markup/inline.rst | 5 ++--- sphinx/domains/std.py | 33 +++++++++++++++------------------ tests/root/objects.txt | 12 +++++++++++- tests/test_build_html.py | 21 ++++++++++++++++++--- 5 files changed, 47 insertions(+), 25 deletions(-) diff --git a/CHANGES b/CHANGES index d062fb417..6991f6846 100644 --- a/CHANGES +++ b/CHANGES @@ -45,6 +45,7 @@ Bugs fixed * #2172: Fix dysfunctional admonition \py@lightbox in sphinx.sty. Thanks to jfbu. * #2198,#2205: ``make gettext`` generate broken msgid for definition lists. * #2062: Escape characters in doctests are treated incorrectly with Python 2. +* #2225: Fix if the option does not begin with dash, linking is not performed Release 1.3.3 (released Dec 2, 2015) ==================================== diff --git a/doc/markup/inline.rst b/doc/markup/inline.rst index 10db17d79..0e825b66a 100644 --- a/doc/markup/inline.rst +++ b/doc/markup/inline.rst @@ -242,9 +242,8 @@ objects: .. rst:role:: option - A command-line option to an executable program. The leading hyphen(s) must - be included. This generates a link to a :rst:dir:`option` directive, if it - exists. + A command-line option to an executable program. This generates a link to + a :rst:dir:`option` directive, if it exists. The following role creates a cross-reference to a term in a diff --git a/sphinx/domains/std.py b/sphinx/domains/std.py index b0bf3031f..aa15279a0 100644 --- a/sphinx/domains/std.py +++ b/sphinx/domains/std.py @@ -210,10 +210,6 @@ class Program(Directive): class OptionXRefRole(XRefRole): def process_link(self, env, refnode, has_explicit_title, title, target): - # validate content - if not re.match(r'(.+ )?[-/+\w]', target): - env.warn_node('Malformed :option: %r, does not contain option ' - 'marker - or -- or / or +' % target, refnode) refnode['std:program'] = env.ref_context.get('std:program') return title, target @@ -664,22 +660,23 @@ class StandardDomain(Domain): return make_refnode(builder, fromdocname, docname, labelid, contnode) elif typ == 'option': + progname = node.get('std:program') target = target.strip() - # most obvious thing: we are a flag option without program - if target.startswith(('-', '/', '+')): - progname = node.get('std:program') - elif re.search(r'[-/+]', target): - try: - progname, target = re.split(r' (?=-|--|/|\+)', target, 1) - except ValueError: - return None - progname = ws_re.sub('-', progname.strip()) - else: - progname = None - docname, labelid = self.data['progoptions'].get((progname, target), - ('', '')) + docname, labelid = self.data['progoptions'].get((progname, target), ('', '')) if not docname: - return None + commands = [] + while ws_re.search(target): + subcommand, target = ws_re.split(target, 1) + commands.append(subcommand) + progname = "-".join(commands) + + docname, labelid = self.data['progoptions'].get((progname, target), + ('', '')) + if docname: + break + else: + return None + return make_refnode(builder, fromdocname, docname, labelid, contnode) else: diff --git a/tests/root/objects.txt b/tests/root/objects.txt index 02986f170..78d467472 100644 --- a/tests/root/objects.txt +++ b/tests/root/objects.txt @@ -174,7 +174,17 @@ Others .. option:: arg -Link to :option:`perl +p` and :option:`arg`. +Link to :option:`perl +p` and :option:`arg` + +.. program:: hg + +.. option:: commit + +.. program:: git commit + +.. option:: -p + +Link to :option:`hg commit` and :option:`git commit -p`. User markup diff --git a/tests/test_build_html.py b/tests/test_build_html.py index eaffad00c..7b04af8c8 100644 --- a/tests/test_build_html.py +++ b/tests/test_build_html.py @@ -31,9 +31,7 @@ http://www.python.org/logo.png reading included file u'.*?wrongenc.inc' seems to be wrong, try giving an \ :encoding: option\\n? %(root)s/includes.txt:4: WARNING: download file not readable: .*?nonexisting.png -(%(root)s/markup.txt:\\d+: WARNING: Malformed :option: u'&option', does \ -not contain option marker - or -- or / or \\+ -%(root)s/undecodable.txt:3: WARNING: undecodable source characters, replacing \ +(%(root)s/undecodable.txt:3: WARNING: undecodable source characters, replacing \ with "\\?": b?'here: >>>(\\\\|/)xbb<<<' )?""" @@ -234,6 +232,23 @@ HTML_XPATH = { (".//td[@class='field-body']/ul/li/strong", '^hour$'), (".//td[@class='field-body']/ul/li/em", '^DuplicateType$'), (".//td[@class='field-body']/ul/li/em", tail_check(r'.* Some parameter')), + # others + (".//a[@class='reference internal'][@href='#cmdoption-perl-arg-+p']/code/span", + 'perl'), + (".//a[@class='reference internal'][@href='#cmdoption-perl-arg-+p']/code/span", + '\+p'), + (".//a[@class='reference internal'][@href='#cmdoption-perl-arg-arg']/code/span", + 'arg'), + (".//a[@class='reference internal'][@href='#cmdoption-hg-arg-commit']/code/span", + 'hg'), + (".//a[@class='reference internal'][@href='#cmdoption-hg-arg-commit']/code/span", + 'commit'), + (".//a[@class='reference internal'][@href='#cmdoption-git-commit-p']/code/span", + 'git'), + (".//a[@class='reference internal'][@href='#cmdoption-git-commit-p']/code/span", + 'commit'), + (".//a[@class='reference internal'][@href='#cmdoption-git-commit-p']/code/span", + '-p'), ], 'contents.html': [ (".//meta[@name='hc'][@content='hcval']", ''), From 053d7806fee5e781b6854846bdf2582e9897c226 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sun, 10 Jan 2016 01:04:38 +0900 Subject: [PATCH 45/48] Refactoring testcases to reduce ResourceWarning (refs: #1409) --- tests/test_intl.py | 17 +++++++++++------ tests/test_util_i18n.py | 3 ++- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/tests/test_intl.py b/tests/test_intl.py index 35c18b1e6..691b68061 100644 --- a/tests/test_intl.py +++ b/tests/test_intl.py @@ -41,6 +41,11 @@ def gen_with_intl_app(builder, confoverrides={}, *args, **kw): return gen_with_app(builder, *args, **default_kw) +def read_po(pathname): + with pathname.open() as f: + return pofile.read_po(f) + + def setup_module(): if not root.exists(): (rootdir / 'roots' / 'test-intl').copytree(root) @@ -310,22 +315,22 @@ def test_gettext_builder(app, status, warning): app.builder.build_all() # --- definition terms: regression test for #2198, #2205 - expect = pofile.read_po((app.srcdir / 'definition_terms.po').open()) - actual = pofile.read_po((app.outdir / 'definition_terms.pot').open()) + expect = read_po(app.srcdir / 'definition_terms.po') + actual = read_po(app.outdir / 'definition_terms.pot') for expect_msg in [m for m in expect if m.id]: yield assert_in, expect_msg.id, [m.id for m in actual if m.id] # --- glossary terms: regression test for #1090 - expect = pofile.read_po((app.srcdir / 'glossary_terms.po').open()) - actual = pofile.read_po((app.outdir / 'glossary_terms.pot').open()) + expect = read_po(app.srcdir / 'glossary_terms.po') + actual = read_po(app.outdir / 'glossary_terms.pot') for expect_msg in [m for m in expect if m.id]: yield assert_in, expect_msg.id, [m.id for m in actual if m.id] warnings = warning.getvalue().replace(os.sep, '/') yield assert_not_in, 'term not in glossary', warnings # --- glossary term inconsistencies: regression test for #1090 - expect = pofile.read_po((app.srcdir / 'glossary_terms_inconsistency.po').open()) - actual = pofile.read_po((app.outdir / 'glossary_terms_inconsistency.pot').open()) + expect = read_po(app.srcdir / 'glossary_terms_inconsistency.po') + actual = read_po(app.outdir / 'glossary_terms_inconsistency.pot') for expect_msg in [m for m in expect if m.id]: yield assert_in, expect_msg.id, [m.id for m in actual if m.id] diff --git a/tests/test_util_i18n.py b/tests/test_util_i18n.py index 47ef8ecce..03ca13266 100644 --- a/tests/test_util_i18n.py +++ b/tests/test_util_i18n.py @@ -55,7 +55,8 @@ def test_catalog_write_mo(dir): cat = i18n.CatalogInfo(dir, 'test', 'utf-8') cat.write_mo('en') assert path.exists(cat.mo_path) - assert read_mo(open(cat.mo_path, 'rb')) is not None + with open(cat.mo_path, 'rb') as f: + assert read_mo(f) is not None @with_tempdir From c8c6dc1fe9b15ad179333c312de36955252e79a6 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sun, 10 Jan 2016 02:20:39 +0900 Subject: [PATCH 46/48] Fix #2226: Math is not HTML-encoded when :nowrap: is given (jsmath, mathjax) --- CHANGES | 1 + sphinx/ext/jsmath.py | 2 +- sphinx/ext/mathjax.py | 2 +- tests/root/math.txt | 7 ++++++- tests/test_build_html.py | 17 ++++++++++++++++- 5 files changed, 25 insertions(+), 4 deletions(-) diff --git a/CHANGES b/CHANGES index 6991f6846..fc3e8e002 100644 --- a/CHANGES +++ b/CHANGES @@ -46,6 +46,7 @@ Bugs fixed * #2198,#2205: ``make gettext`` generate broken msgid for definition lists. * #2062: Escape characters in doctests are treated incorrectly with Python 2. * #2225: Fix if the option does not begin with dash, linking is not performed +* #2226: Fix math is not HTML-encoded when :nowrap: is given (jsmath, mathjax) Release 1.3.3 (released Dec 2, 2015) ==================================== diff --git a/sphinx/ext/jsmath.py b/sphinx/ext/jsmath.py index 2cc661430..f5e4ce0d7 100644 --- a/sphinx/ext/jsmath.py +++ b/sphinx/ext/jsmath.py @@ -26,7 +26,7 @@ def html_visit_math(self, node): def html_visit_displaymath(self, node): if node['nowrap']: self.body.append(self.starttag(node, 'div', CLASS='math')) - self.body.append(node['latex']) + self.body.append(self.encode(node['latex'])) self.body.append('') raise nodes.SkipNode for i, part in enumerate(node['latex'].split('\n\n')): diff --git a/sphinx/ext/mathjax.py b/sphinx/ext/mathjax.py index d512db465..61e8c05b5 100644 --- a/sphinx/ext/mathjax.py +++ b/sphinx/ext/mathjax.py @@ -30,7 +30,7 @@ def html_visit_displaymath(self, node): self.body.append(self.starttag(node, 'div', CLASS='math')) if node['nowrap']: self.body.append(self.builder.config.mathjax_display[0] + - node['latex'] + + self.encode(node['latex']) + self.builder.config.mathjax_display[1]) self.body.append('') raise nodes.SkipNode diff --git a/tests/root/math.txt b/tests/root/math.txt index aeba85f24..5a209bed4 100644 --- a/tests/root/math.txt +++ b/tests/root/math.txt @@ -7,7 +7,7 @@ This is inline math: :math:`a^2 + b^2 = c^2`. .. math:: - a^2 + b^2 = c^2 + a + 1 < b .. math:: :label: foo @@ -23,4 +23,9 @@ This is inline math: :math:`a^2 + b^2 = c^2`. n \in \mathbb N +.. math:: + :nowrap: + + a + 1 < b + Referencing equation :eq:`foo`. diff --git a/tests/test_build_html.py b/tests/test_build_html.py index 7b04af8c8..9ab944451 100644 --- a/tests/test_build_html.py +++ b/tests/test_build_html.py @@ -16,7 +16,7 @@ from six import PY3, iteritems from six.moves import html_entities from sphinx import __display_version__ -from util import remove_unicode_literals, gen_with_app +from util import remove_unicode_literals, gen_with_app, with_app from etree13 import ElementTree as ET @@ -929,3 +929,18 @@ def test_numfig_with_secnum_depth(app, status, warning): for xpath, check, be_found in paths: yield check_xpath, etree, fname, xpath, check, be_found + + +@with_app(buildername='html') +def test_jsmath(app, status, warning): + app.builder.build_all() + content = (app.outdir / 'math.html').text() + + assert '

    \na^2 + b^2 = c^2
    ' in content + assert '
    \n\\begin{split}a + 1 < b\\end{split}
    ' in content + assert ('(1)
    \n' + 'e^{i\\pi} = 1
    ' in content) + assert ('(2)
    \n' + 'e^{ix} = \\cos x + i\\sin x
    ' in content) + assert '
    \nn \\in \\mathbb N
    ' in content + assert '
    \na + 1 < b
    ' in content From ff01b7841274c53646a108e7a831cde7d1475240 Mon Sep 17 00:00:00 2001 From: shimizukawa Date: Sun, 10 Jan 2016 11:08:25 +0900 Subject: [PATCH 47/48] Remove version specific installation procedure and link to stable/latest document page because sphinx site has been moved to ReadTheDocs so the information is obsoleted. --- doc/_templates/indexsidebar.html | 8 -------- 1 file changed, 8 deletions(-) diff --git a/doc/_templates/indexsidebar.html b/doc/_templates/indexsidebar.html index 56094809f..b6f12f031 100644 --- a/doc/_templates/indexsidebar.html +++ b/doc/_templates/indexsidebar.html @@ -14,15 +14,7 @@

    {%trans%}Current version: {{ version }}{%endtrans%}

    {%trans%}Get Sphinx from the Python Package Index, or install it with:{%endtrans%}

    -{% if version.split('b')|length > 1 %} -
    pip install Sphinx=={{ version }}
    -

    {%trans%}Stable version docs -are also available.{%endtrans%}

    -{% else %}
    pip install -U Sphinx
    -

    {%trans%}Latest development version docs -are also available.{%endtrans%}

    -{% endif %} {% endif %}

    {%trans%}Questions? Suggestions?{%endtrans%}

    From 09b931745d14462a4c728fa5fc868984eff5687a Mon Sep 17 00:00:00 2001 From: shimizukawa Date: Sun, 10 Jan 2016 11:17:45 +0900 Subject: [PATCH 48/48] Switch links for pdf version documentation to on ReadTheDocs. --- doc/_templates/index.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/_templates/index.html b/doc/_templates/index.html index ccef89a78..4c23114db 100644 --- a/doc/_templates/index.html +++ b/doc/_templates/index.html @@ -62,11 +62,11 @@

    {%trans%} - You can also download PDF versions of the Sphinx documentation: - a version generated from + You can also download PDF/EPUB versions of the Sphinx documentation: + a PDF version generated from the LaTeX Sphinx produces, and - a version generated - by rst2pdf.{%endtrans%} + a EPUB version. + {%endtrans%}

    {%trans%}Examples{%endtrans%}