diff --git a/CHANGES b/CHANGES index 548ffc737..7ebf8061e 100644 --- a/CHANGES +++ b/CHANGES @@ -98,6 +98,9 @@ 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) +* :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 c55e44fb1..1530c28cd 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/locale *.js *.pot *.po *.mo recursive-include sphinx/search/non-minified-js *.js diff --git a/sphinx/builders/epub3.py b/sphinx/builders/epub3.py index f94c9ff3c..92c55c880 100644 --- a/sphinx/builders/epub3.py +++ b/sphinx/builders/epub3.py @@ -86,40 +86,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 8083c6200..80816d8b9 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/sphinx/environment/__init__.py b/sphinx/environment/__init__.py index 536aa959e..30763adcd 100644 --- a/sphinx/environment/__init__.py +++ b/sphinx/environment/__init__.py @@ -664,6 +664,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/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 " diff --git a/sphinx/roles.py b/sphinx/roles.py index dbd136fdb..4007b9f88 100644 --- a/sphinx/roles.py +++ b/sphinx/roles.py @@ -185,9 +185,11 @@ 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) title = utils.unescape(title) target = utils.unescape(target) @@ -249,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}') @@ -280,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]) 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)): 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_environment_toctree.py b/tests/test_environment_toctree.py index db07aa479..f7a24d1fc 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,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 = 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 +318,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, 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)