mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge commit '63c15998f66eeb42f3fcfef6087a7264645bee6b~1'
This commit is contained in:
commit
c32233b0e1
3
CHANGES
3
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
|
||||
--------
|
||||
|
@ -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
|
||||
|
@ -86,40 +86,37 @@ class Epub3Builder(_epub_base.EpubBuilder):
|
||||
def validate_config_value(self):
|
||||
# <package> 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')
|
||||
# <package> 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
|
||||
|
@ -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:
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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 "
|
||||
|
@ -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'(?<!&)&(?![&\s])')
|
||||
|
||||
def menusel_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)
|
||||
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])
|
||||
|
@ -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)):
|
||||
|
3
tests/roots/test-default_role/conf.py
Normal file
3
tests/roots/test-default_role/conf.py
Normal file
@ -0,0 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
master_doc = 'index'
|
4
tests/roots/test-default_role/foo.rst
Normal file
4
tests/roots/test-default_role/foo.rst
Normal file
@ -0,0 +1,4 @@
|
||||
foo.rst
|
||||
=======
|
||||
|
||||
`OK` button
|
6
tests/roots/test-default_role/index.rst
Normal file
6
tests/roots/test-default_role/index.rst
Normal file
@ -0,0 +1,6 @@
|
||||
default_role
|
||||
============
|
||||
|
||||
.. default-role:: pep
|
||||
|
||||
`8`
|
@ -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,
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user