From 44da8f4fa744e88472d91a86fd7219f1729cae88 Mon Sep 17 00:00:00 2001 From: Julien Palard Date: Wed, 24 May 2017 23:52:56 +0200 Subject: [PATCH 1/8] i18n: This string is used as html_title, it needs to be capitalized. --- sphinx/locale/fr/LC_MESSAGES/sphinx.po | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sphinx/locale/fr/LC_MESSAGES/sphinx.po b/sphinx/locale/fr/LC_MESSAGES/sphinx.po index fd1ae6605..6f6492b53 100644 --- a/sphinx/locale/fr/LC_MESSAGES/sphinx.po +++ b/sphinx/locale/fr/LC_MESSAGES/sphinx.po @@ -356,7 +356,7 @@ msgstr "précédent" #: sphinx/builders/html.py:1313 #, python-format msgid "%s %s documentation" -msgstr "documentation %s %s" +msgstr "Documentation %s %s" #: sphinx/builders/latex.py:199 sphinx/builders/texinfo.py:217 msgid " (in " From ea03e27fb86ace1ca936ea603bab3c963990c7a5 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sat, 29 Jul 2017 16:49:34 +0900 Subject: [PATCH 2/8] Fix :pep: and :rfc: does not supports ``default-role`` directive (refs: #3960) --- CHANGES | 1 + sphinx/environment/__init__.py | 1 + sphinx/roles.py | 3 ++- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 4d037ed60..ec2db7821 100644 --- a/CHANGES +++ b/CHANGES @@ -21,6 +21,7 @@ Bugs fixed * #3924: docname lost after dynamically parsing RST in extension * #3946: Typo in sphinx.sty (this was a bug with no effect in default context) +* Fix :pep: and :rfc: does not supports ``default-role`` directive (refs: #3960) Testing -------- diff --git a/sphinx/environment/__init__.py b/sphinx/environment/__init__.py index edec9ba2f..126a962a3 100644 --- a/sphinx/environment/__init__.py +++ b/sphinx/environment/__init__.py @@ -665,6 +665,7 @@ class BuildEnvironment(object): self.temp_data['docname'] = docname # defaults to the global default, but can be re-set in a document + self.temp_data['default_role'] = self.config.default_role self.temp_data['default_domain'] = \ self.domains.get(self.config.primary_domain) diff --git a/sphinx/roles.py b/sphinx/roles.py index dbd136fdb..ab6efc89f 100644 --- a/sphinx/roles.py +++ b/sphinx/roles.py @@ -185,7 +185,8 @@ def indexmarkup_role(typ, rawtext, text, lineno, inliner, options={}, content=[] """Role for PEP/RFC references that generate an index entry.""" env = inliner.document.settings.env if not typ: - typ = env.config.default_role + assert env.temp_data['default_role'] + typ = env.temp_data['default_role'].lower() else: typ = typ.lower() has_explicit_title, title, target = split_explicit_title(text) From fa9ad8552d92f3727264cddb70cdfe2fc87f62eb Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sun, 30 Jul 2017 23:52:39 +0900 Subject: [PATCH 3/8] Fix #3960: default_role = guilabel not functioning --- CHANGES | 3 ++- sphinx/roles.py | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index ec2db7821..32e945ec3 100644 --- a/CHANGES +++ b/CHANGES @@ -21,7 +21,8 @@ Bugs fixed * #3924: docname lost after dynamically parsing RST in extension * #3946: Typo in sphinx.sty (this was a bug with no effect in default context) -* Fix :pep: and :rfc: does not supports ``default-role`` directive (refs: #3960) +* :pep: and :rfc: does not supports ``default-role`` directive (refs: #3960) +* #3960: default_role = 'guilabel' not functioning Testing -------- diff --git a/sphinx/roles.py b/sphinx/roles.py index ab6efc89f..4007b9f88 100644 --- a/sphinx/roles.py +++ b/sphinx/roles.py @@ -189,6 +189,7 @@ def indexmarkup_role(typ, rawtext, text, lineno, inliner, options={}, content=[] typ = env.temp_data['default_role'].lower() else: typ = typ.lower() + has_explicit_title, title, target = split_explicit_title(text) title = utils.unescape(title) target = utils.unescape(target) @@ -250,6 +251,13 @@ _amp_re = re.compile(r'(? Tuple[List[nodes.Node], List[nodes.Node]] # NOQA + env = inliner.document.settings.env + if not typ: + assert env.temp_data['default_role'] + typ = env.temp_data['default_role'].lower() + else: + typ = typ.lower() + text = utils.unescape(text) if typ == 'menuselection': text = text.replace('-->', u'\N{TRIANGULAR BULLET}') @@ -281,6 +289,13 @@ _litvar_re = re.compile('{([^}]+)}') def emph_literal_role(typ, rawtext, text, lineno, inliner, options={}, content=[]): # type: (unicode, unicode, unicode, int, Inliner, Dict, List[unicode]) -> Tuple[List[nodes.Node], List[nodes.Node]] # NOQA + env = inliner.document.settings.env + if not typ: + assert env.temp_data['default_role'] + typ = env.temp_data['default_role'].lower() + else: + typ = typ.lower() + text = utils.unescape(text) pos = 0 retnode = nodes.literal(role=typ.lower(), classes=[typ]) From da0fda3b0be4b4de26c4e55fdd6bece9575d70ad Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Mon, 31 Jul 2017 00:46:26 +0900 Subject: [PATCH 4/8] Add tests for default-role --- tests/roots/test-default_role/conf.py | 3 ++ tests/roots/test-default_role/foo.rst | 4 +++ tests/roots/test-default_role/index.rst | 6 ++++ tests/test_markup.py | 41 +++++++++++++++++++++++++ 4 files changed, 54 insertions(+) create mode 100644 tests/roots/test-default_role/conf.py create mode 100644 tests/roots/test-default_role/foo.rst create mode 100644 tests/roots/test-default_role/index.rst diff --git a/tests/roots/test-default_role/conf.py b/tests/roots/test-default_role/conf.py new file mode 100644 index 000000000..f81c30bc4 --- /dev/null +++ b/tests/roots/test-default_role/conf.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +master_doc = 'index' diff --git a/tests/roots/test-default_role/foo.rst b/tests/roots/test-default_role/foo.rst new file mode 100644 index 000000000..00e5ae59d --- /dev/null +++ b/tests/roots/test-default_role/foo.rst @@ -0,0 +1,4 @@ +foo.rst +======= + +`OK` button diff --git a/tests/roots/test-default_role/index.rst b/tests/roots/test-default_role/index.rst new file mode 100644 index 000000000..34c1855f6 --- /dev/null +++ b/tests/roots/test-default_role/index.rst @@ -0,0 +1,6 @@ +default_role +============ + +.. default-role:: pep + +`8` diff --git a/tests/test_markup.py b/tests/test_markup.py index 9690f2bf9..dfa4d74cf 100644 --- a/tests/test_markup.py +++ b/tests/test_markup.py @@ -286,3 +286,44 @@ def test_compact_refonly_bullet_list(app, status, warning): assert_node(doctree[0][4], nodes.bullet_list) assert_node(doctree[0][4][0][0], nodes.paragraph) assert doctree[0][4][0][0].astext() == 'Hello' + + +@pytest.mark.sphinx('dummy', testroot='default_role') +def test_default_role1(app, status, warning): + app.builder.build_all() + + # default-role: pep + doctree = pickle.loads((app.doctreedir / 'index.doctree').bytes()) + assert_node(doctree[0], nodes.section) + assert_node(doctree[0][1], nodes.paragraph) + assert_node(doctree[0][1][0], addnodes.index) + assert_node(doctree[0][1][1], nodes.target) + assert_node(doctree[0][1][2], nodes.reference, classes=["pep"]) + + # no default-role + doctree = pickle.loads((app.doctreedir / 'foo.doctree').bytes()) + assert_node(doctree[0], nodes.section) + assert_node(doctree[0][1], nodes.paragraph) + assert_node(doctree[0][1][0], nodes.title_reference) + assert_node(doctree[0][1][1], nodes.Text) + + +@pytest.mark.sphinx('dummy', testroot='default_role', + confoverrides={'default_role': 'guilabel'}) +def test_default_role2(app, status, warning): + app.builder.build_all() + + # default-role directive is stronger than configratuion + doctree = pickle.loads((app.doctreedir / 'index.doctree').bytes()) + assert_node(doctree[0], nodes.section) + assert_node(doctree[0][1], nodes.paragraph) + assert_node(doctree[0][1][0], addnodes.index) + assert_node(doctree[0][1][1], nodes.target) + assert_node(doctree[0][1][2], nodes.reference, classes=["pep"]) + + # default_role changes the default behavior + doctree = pickle.loads((app.doctreedir / 'foo.doctree').bytes()) + assert_node(doctree[0], nodes.section) + assert_node(doctree[0][1], nodes.paragraph) + assert_node(doctree[0][1][0], nodes.inline, classes=["guilabel"]) + assert_node(doctree[0][1][1], nodes.Text) From d63a6782287b797fa3924e59f2df113d73e9a909 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Mon, 31 Jul 2017 22:30:37 +0900 Subject: [PATCH 5/8] Reduce DeprecationWarning --- sphinx/builders/epub3.py | 29 +++++++++++++---------------- sphinx/builders/html.py | 4 ++-- tests/test_directive_only.py | 2 +- tests/test_environment_toctree.py | 17 +++++++++-------- 4 files changed, 25 insertions(+), 27 deletions(-) diff --git a/sphinx/builders/epub3.py b/sphinx/builders/epub3.py index 6256b0f6d..fb2a71b34 100644 --- a/sphinx/builders/epub3.py +++ b/sphinx/builders/epub3.py @@ -85,40 +85,37 @@ class Epub3Builder(_epub_base.EpubBuilder): def validate_config_value(self): # lang attribute, dc:language if not self.app.config.epub_language: - self.app.warn( - 'conf value "epub_language" (or "language") ' - 'should not be empty for EPUB3') + logger.warning('conf value "epub_language" (or "language") ' + 'should not be empty for EPUB3') # unique-identifier attribute if not xmlname_checker().match(self.app.config.epub_uid): - self.app.warn('conf value "epub_uid" should be XML NAME for EPUB3') + logger.warning('conf value "epub_uid" should be XML NAME for EPUB3') # dc:title if not self.app.config.epub_title: - self.app.warn( - 'conf value "epub_title" (or "html_title") ' - 'should not be empty for EPUB3') + logger.warning('conf value "epub_title" (or "html_title") ' + 'should not be empty for EPUB3') # dc:creator if not self.app.config.epub_author: - self.app.warn('conf value "epub_author" should not be empty for EPUB3') + logger.warning('conf value "epub_author" should not be empty for EPUB3') # dc:contributor if not self.app.config.epub_contributor: - self.app.warn('conf value "epub_contributor" should not be empty for EPUB3') + logger.warning('conf value "epub_contributor" should not be empty for EPUB3') # dc:description if not self.app.config.epub_description: - self.app.warn('conf value "epub_description" should not be empty for EPUB3') + logger.warning('conf value "epub_description" should not be empty for EPUB3') # dc:publisher if not self.app.config.epub_publisher: - self.app.warn('conf value "epub_publisher" should not be empty for EPUB3') + logger.warning('conf value "epub_publisher" should not be empty for EPUB3') # dc:rights if not self.app.config.epub_copyright: - self.app.warn( - 'conf value "epub_copyright" (or "copyright")' - 'should not be empty for EPUB3') + logger.warning('conf value "epub_copyright" (or "copyright")' + 'should not be empty for EPUB3') # dc:identifier if not self.app.config.epub_identifier: - self.app.warn('conf value "epub_identifier" should not be empty for EPUB3') + logger.warning('conf value "epub_identifier" should not be empty for EPUB3') # meta ibooks:version if not self.app.config.version: - self.app.warn('conf value "version" should not be empty for EPUB3') + logger.warning('conf value "version" should not be empty for EPUB3') def content_metadata(self): # type: () -> Dict diff --git a/sphinx/builders/html.py b/sphinx/builders/html.py index 540125b2a..0265f6a1b 100644 --- a/sphinx/builders/html.py +++ b/sphinx/builders/html.py @@ -605,7 +605,7 @@ class StandaloneHTMLBuilder(Builder): # additional pages from conf.py for pagename, template in self.config.html_additional_pages.items(): - self.info(' ' + pagename, nonl=1) + logger.info(' ' + pagename, nonl=1) self.handle_page(pagename, {}, template) # the search page @@ -1188,7 +1188,7 @@ class SingleFileHTMLBuilder(StandaloneHTMLBuilder): # additional pages from conf.py for pagename, template in self.config.html_additional_pages.items(): - self.info(' ' + pagename, nonl=1) + logger.info(' ' + pagename, nonl=1) self.handle_page(pagename, {}, template) if self.config.html_use_opensearch: diff --git a/tests/test_directive_only.py b/tests/test_directive_only.py index 35d15b391..d70585774 100644 --- a/tests/test_directive_only.py +++ b/tests/test_directive_only.py @@ -46,7 +46,7 @@ def test_sectioning(app, status, warning): app.builder.build(['only']) doctree = app.env.get_doctree('only') - process_only_nodes(doctree, app.builder.tags) + app.env.apply_post_transforms(doctree, 'only') parts = [getsects(n) for n in [_n for _n in doctree.children if isinstance(_n, nodes.section)]] diff --git a/tests/test_environment_toctree.py b/tests/test_environment_toctree.py index db07aa479..5fef9218a 100644 --- a/tests/test_environment_toctree.py +++ b/tests/test_environment_toctree.py @@ -14,6 +14,7 @@ from docutils.nodes import bullet_list, list_item, caption, comment, reference from sphinx import addnodes from sphinx.addnodes import compact_paragraph, only from sphinx.builders.html import StandaloneHTMLBuilder +from sphinx.environment.adapters.toctree import TocTree import pytest from sphinx.testing.util import assert_node @@ -138,7 +139,7 @@ def test_glob(app): @pytest.mark.test_params(shared_result='test_environment_toctree_basic') def test_get_toc_for(app): app.build() - toctree = app.env.get_toc_for('index', app.builder) + toctree = TocTree(app.env).get_toc_for('index', app.builder) assert_node(toctree, [bullet_list, ([list_item, (compact_paragraph, # [0][0] @@ -165,7 +166,7 @@ def test_get_toc_for(app): def test_get_toc_for_only(app): app.build() builder = StandaloneHTMLBuilder(app) - toctree = app.env.get_toc_for('index', builder) + toctree = TocTree(app.env).get_toc_for('index', builder) assert_node(toctree, [bullet_list, ([list_item, (compact_paragraph, # [0][0] @@ -194,7 +195,7 @@ def test_get_toc_for_only(app): @pytest.mark.test_params(shared_result='test_environment_toctree_basic') def test_get_toc_for_tocdepth(app): app.build() - toctree = app.env.get_toc_for('tocdepth', app.builder) + toctree = TocTree(app.env).get_toc_for('tocdepth', app.builder) assert_node(toctree, [bullet_list, list_item, (compact_paragraph, # [0][0] @@ -209,7 +210,7 @@ def test_get_toc_for_tocdepth(app): @pytest.mark.test_params(shared_result='test_environment_toctree_basic') def test_get_toctree_for(app): app.build() - toctree = app.env.get_toctree_for('index', app.builder, collapse=False) + toctree = TocTree(app.env).get_toctree_for('index', app.builder, collapse=False) assert_node(toctree, [compact_paragraph, ([caption, "Table of Contents"], bullet_list, @@ -246,7 +247,7 @@ def test_get_toctree_for(app): @pytest.mark.test_params(shared_result='test_environment_toctree_basic') def test_get_toctree_for_collapse(app): app.build() - toctree = app.env.get_toctree_for('index', app.builder, collapse=True) + toctree = TocTree(app.env).get_toctree_for('index', app.builder, collapse=True) assert_node(toctree, [compact_paragraph, ([caption, "Table of Contents"], bullet_list, @@ -274,7 +275,7 @@ def test_get_toctree_for_collapse(app): @pytest.mark.test_params(shared_result='test_environment_toctree_basic') def test_get_toctree_for_maxdepth(app): app.build() - toctree = app.env.get_toctree_for('index', app.builder, collapse=False, maxdepth=3) + toctree = TocTree(app.env).get_toctree_for('index', app.builder, collapse=False, maxdepth=3) assert_node(toctree, [compact_paragraph, ([caption, "Table of Contents"], bullet_list, @@ -316,8 +317,8 @@ def test_get_toctree_for_maxdepth(app): @pytest.mark.test_params(shared_result='test_environment_toctree_basic') def test_get_toctree_for_includehidden(app): app.build() - toctree = app.env.get_toctree_for('index', app.builder, collapse=False, - includehidden=False) + toctree = TocTree(app.env).get_toctree_for('index', app.builder, collapse=False, + includehidden=False) assert_node(toctree, [compact_paragraph, ([caption, "Table of Contents"], bullet_list, From 4f0de6f49ba130835dc087ca36b7e15a941aea29 Mon Sep 17 00:00:00 2001 From: shimizukawa Date: Wed, 16 Aug 2017 15:13:15 +0900 Subject: [PATCH 6/8] copy static files beyond symlinked directories under _static directory. This issue caused from ref #2744 --- sphinx/util/fileutil.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sphinx/util/fileutil.py b/sphinx/util/fileutil.py index 04fd338b7..fe98117d2 100644 --- a/sphinx/util/fileutil.py +++ b/sphinx/util/fileutil.py @@ -77,7 +77,7 @@ def copy_asset(source, destination, excluded=lambda path: False, context=None, r copy_asset_file(source, destination, context, renderer) return - for root, dirs, files in walk(source): + for root, dirs, files in walk(source, followlinks=True): reldir = relative_path(source, root) for dir in dirs[:]: if excluded(posixpath.join(reldir, dir)): From feab97e2939909d83fd24794efa83f6278db8d59 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sun, 20 Aug 2017 00:27:07 +0900 Subject: [PATCH 7/8] Fix flake8 violation --- tests/test_environment_toctree.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/test_environment_toctree.py b/tests/test_environment_toctree.py index 5fef9218a..f7a24d1fc 100644 --- a/tests/test_environment_toctree.py +++ b/tests/test_environment_toctree.py @@ -275,7 +275,8 @@ def test_get_toctree_for_collapse(app): @pytest.mark.test_params(shared_result='test_environment_toctree_basic') def test_get_toctree_for_maxdepth(app): app.build() - toctree = TocTree(app.env).get_toctree_for('index', app.builder, collapse=False, maxdepth=3) + toctree = TocTree(app.env).get_toctree_for('index', app.builder, + collapse=False, maxdepth=3) assert_node(toctree, [compact_paragraph, ([caption, "Table of Contents"], bullet_list, From dd8c3211bea1cb53a84959dbd34aad51e072202e Mon Sep 17 00:00:00 2001 From: shimizukawa Date: Tue, 22 Aug 2017 11:02:51 +0900 Subject: [PATCH 8/8] fix: missing ``texinputs_win/Makefile`` to be used in latexpdf builder on windows. --- CHANGES | 1 + MANIFEST.in | 1 + 2 files changed, 2 insertions(+) diff --git a/CHANGES b/CHANGES index 32e945ec3..d2a764f0d 100644 --- a/CHANGES +++ b/CHANGES @@ -23,6 +23,7 @@ Bugs fixed * #3946: Typo in sphinx.sty (this was a bug with no effect in default context) * :pep: and :rfc: does not supports ``default-role`` directive (refs: #3960) * #3960: default_role = 'guilabel' not functioning +* Missing ``texinputs_win/Makefile`` to be used in latexpdf builder on windows. Testing -------- diff --git a/MANIFEST.in b/MANIFEST.in index 6fe5c7d6d..d478724e7 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -18,6 +18,7 @@ include sphinx/locale/.tx/config recursive-include sphinx/templates * recursive-include sphinx/texinputs * +recursive-include sphinx/texinputs_win * recursive-include sphinx/themes * recursive-include sphinx/pycode/pgen2 *.c *.pyx recursive-include sphinx/locale *.js *.pot *.po *.mo