mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge branch 'stable'
This commit is contained in:
commit
7e7b389eed
1
AUTHORS
1
AUTHORS
@ -29,6 +29,7 @@ Other contributors, listed alphabetically, are:
|
||||
* Kevin Dunn -- MathJax extension
|
||||
* Josip Dzolonga -- coverage builder
|
||||
* Buck Evan -- dummy builder
|
||||
* Matthew Fernandez -- todo extension fix
|
||||
* Hernan Grecco -- search improvements
|
||||
* Horst Gutmann -- internationalization support
|
||||
* Martin Hans -- autodoc improvements
|
||||
|
24
CHANGES
24
CHANGES
@ -80,7 +80,7 @@ Testing
|
||||
|
||||
* Add support for docutils 0.14
|
||||
|
||||
Release 1.6.5 (in development)
|
||||
Release 1.6.6 (in development)
|
||||
==============================
|
||||
|
||||
Dependencies
|
||||
@ -95,6 +95,18 @@ Deprecated
|
||||
Features added
|
||||
--------------
|
||||
|
||||
Bugs fixed
|
||||
----------
|
||||
|
||||
Testing
|
||||
--------
|
||||
|
||||
Release 1.6.5 (released Oct 23, 2017)
|
||||
=====================================
|
||||
|
||||
Features added
|
||||
--------------
|
||||
|
||||
* #4107: Make searchtools.js compatible with pre-Sphinx1.5 templates
|
||||
* #4112: Don't override the smart_quotes setting if it was already set
|
||||
* #4125: Display reference texts of original and translated passages on
|
||||
@ -115,9 +127,13 @@ Bugs fixed
|
||||
* #4063: Sphinx crashes when labeling directive ``.. todolist::``
|
||||
* #4134: [doc] :file:`docutils.conf` is not documented explicitly
|
||||
* #4169: Chinese language doesn't trigger Chinese search automatically
|
||||
|
||||
Testing
|
||||
--------
|
||||
* #1020: ext.todo todolist not linking to the page in pdflatex
|
||||
* #3965: New quickstart generates wrong SPHINXBUILD in Makefile
|
||||
* #3739: ``:module:`` option is ignored at content of pyobjects
|
||||
* #4149: Documentation: Help choosing :confval:`latex_engine`
|
||||
* #4090: [doc] :confval:`latex_additional_files` with extra LaTeX macros should
|
||||
not use ``.tex`` extension
|
||||
* Failed to convert reST parser error to warning (refs: #4132)
|
||||
|
||||
Release 1.6.4 (released Sep 26, 2017)
|
||||
=====================================
|
||||
|
@ -1546,6 +1546,25 @@ These options influence LaTeX output. See further :doc:`latex`.
|
||||
* ``'lualatex'`` -- LuaLaTeX
|
||||
* ``'platex'`` -- pLaTeX (default if :confval:`language` is ``'ja'``)
|
||||
|
||||
PDFLaTeX's support for Unicode characters covers those from the document
|
||||
language (the LaTeX ``babel`` and ``inputenc`` packages map them to glyph
|
||||
slots in the document font, at various encodings allowing each only 256
|
||||
characters; Sphinx uses by default (except for Cyrillic languages) the
|
||||
``times`` package), but stray characters from other scripts or special
|
||||
symbols may require adding extra LaTeX packages or macros to the LaTeX
|
||||
preamble.
|
||||
|
||||
If your project uses such extra Unicode characters, switching the engine to
|
||||
XeLaTeX or LuaLaTeX often provides a quick fix. They only work with UTF-8
|
||||
encoded sources and can (in fact, should) use OpenType fonts, either from
|
||||
the system or the TeX install tree. Recent LaTeX releases will default with
|
||||
these engines to the Latin Modern OpenType font, which has good coverage of
|
||||
Latin and Cyrillic scripts (it is provided by standard LaTeX installation),
|
||||
and Sphinx does not modify this default. Refer to the documentation of the
|
||||
LaTeX ``polyglossia`` package to see how to instruct LaTeX to use some
|
||||
other OpenType font if Unicode coverage proves insufficient (or use
|
||||
directly ``\setmainfont`` et. al. as in :ref:`this example <latex-basic>`.)
|
||||
|
||||
.. confval:: latex_documents
|
||||
|
||||
This value determines how to group the document tree into LaTeX source files.
|
||||
|
@ -29,6 +29,7 @@ The *latex* target does not benefit from pre-prepared themes like the
|
||||
cautionBgColor={named}{LightCyan}}
|
||||
\relax
|
||||
|
||||
.. _latex-basic:
|
||||
|
||||
Basic customization
|
||||
-------------------
|
||||
@ -61,17 +62,17 @@ It is achieved via usage of the
|
||||
.. highlight:: latex
|
||||
|
||||
If the size of the ``'preamble'`` contents becomes inconvenient, one may move
|
||||
all needed macros into some file :file:`mystyle.tex` of the project source
|
||||
all needed macros into some file :file:`mystyle.tex.txt` of the project source
|
||||
repertory, and get LaTeX to import it at run time::
|
||||
|
||||
'preamble': r'\input{mystyle.tex}',
|
||||
'preamble': r'\input{mystyle.tex.txt}',
|
||||
# or, if the \ProvidesPackage LaTeX macro is used in a file mystyle.sty
|
||||
'preamble': r'\usepackage{mystyle}',
|
||||
|
||||
It is needed to set appropriately :confval:`latex_additional_files`, for
|
||||
example::
|
||||
|
||||
latex_additional_files = ["mystyle.tex"]
|
||||
latex_additional_files = ["mystyle.sty"]
|
||||
|
||||
.. _latexsphinxsetup:
|
||||
|
||||
|
@ -348,6 +348,10 @@ class PyObject(ObjectDescription):
|
||||
if self.allow_nesting:
|
||||
classes = self.env.ref_context.setdefault('py:classes', [])
|
||||
classes.append(prefix)
|
||||
if 'module' in self.options:
|
||||
modules = self.env.ref_context.setdefault('py:modules', [])
|
||||
modules.append(self.env.ref_context.get('py:module'))
|
||||
self.env.ref_context['py:module'] = self.options['module']
|
||||
|
||||
def after_content(self):
|
||||
# type: () -> None
|
||||
@ -368,6 +372,12 @@ class PyObject(ObjectDescription):
|
||||
pass
|
||||
self.env.ref_context['py:class'] = (classes[-1] if len(classes) > 0
|
||||
else None)
|
||||
if 'module' in self.options:
|
||||
modules = self.env.ref_context.setdefault('py:modules', [])
|
||||
if modules:
|
||||
self.env.ref_context['py:module'] = modules.pop()
|
||||
else:
|
||||
self.env.ref_context.pop('py:module')
|
||||
|
||||
|
||||
class PyModulelevel(PyObject):
|
||||
|
@ -69,6 +69,8 @@ class Todo(BaseAdmonition):
|
||||
|
||||
env = self.state.document.settings.env
|
||||
targetid = 'index-%s' % env.new_serialno('index')
|
||||
# Stash the target to be retrieved later in latex_visit_todo_node.
|
||||
todo['targetref'] = '%s:%s' % (env.docname, targetid)
|
||||
targetnode = nodes.target('', '', ids=[targetid])
|
||||
return [targetnode, todo]
|
||||
|
||||
@ -173,8 +175,12 @@ def process_todo_nodes(app, doctree, fromdocname):
|
||||
para += newnode
|
||||
para += nodes.Text(desc2, desc2)
|
||||
|
||||
# (Recursively) resolve references in the todo content
|
||||
todo_entry = todo_info['todo']
|
||||
# Remove targetref from the (copied) node to avoid emitting a
|
||||
# duplicate label of the original entry when we walk this node.
|
||||
del todo_entry['targetref']
|
||||
|
||||
# (Recursively) resolve references in the todo content
|
||||
env.resolve_references(todo_entry, todo_info['docname'],
|
||||
app.builder)
|
||||
|
||||
@ -216,7 +222,13 @@ def depart_todo_node(self, node):
|
||||
def latex_visit_todo_node(self, node):
|
||||
# type: (nodes.NodeVisitor, todo_node) -> None
|
||||
title = node.pop(0).astext().translate(tex_escape_map)
|
||||
self.body.append(u'\n\\begin{sphinxadmonition}{note}{%s:}' % title)
|
||||
self.body.append(u'\n\\begin{sphinxadmonition}{note}{')
|
||||
# If this is the original todo node, emit a label that will be referenced by
|
||||
# a hyperref in the todolist.
|
||||
target = node.get('targetref')
|
||||
if target is not None:
|
||||
self.body.append(u'\\label{%s}' % target)
|
||||
self.body.append('%s:}' % title)
|
||||
|
||||
|
||||
def latex_depart_todo_node(self, node):
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
# You can set these variables from the command line.
|
||||
SPHINXOPTS =
|
||||
SPHINXBUILD = python -msphinx
|
||||
SPHINXBUILD = sphinx-build
|
||||
SPHINXPROJ = {{ project_fn }}
|
||||
SOURCEDIR = {{ rsrcdir }}
|
||||
BUILDDIR = {{ rbuilddir }}
|
||||
|
@ -2,9 +2,9 @@
|
||||
#
|
||||
|
||||
# You can set these variables from the command line.
|
||||
SPHINXOPTS =
|
||||
SPHINXBUILD = python -msphinx
|
||||
PAPER =
|
||||
SPHINXOPTS ?=
|
||||
SPHINXBUILD ?= sphinx-build
|
||||
PAPER ?=
|
||||
BUILDDIR = {{ rbuilddir }}
|
||||
|
||||
# Internal variables.
|
||||
|
@ -5,7 +5,7 @@ pushd %~dp0
|
||||
REM Command file for Sphinx documentation
|
||||
|
||||
if "%SPHINXBUILD%" == "" (
|
||||
set SPHINXBUILD=python -msphinx
|
||||
set SPHINXBUILD=sphinx-build
|
||||
)
|
||||
set SOURCEDIR={{ rsrcdir }}
|
||||
set BUILDDIR={{ rbuilddir }}
|
||||
@ -16,10 +16,10 @@ if "%1" == "" goto help
|
||||
%SPHINXBUILD% >NUL 2>NUL
|
||||
if errorlevel 9009 (
|
||||
echo.
|
||||
echo.The Sphinx module was not found. Make sure you have Sphinx installed,
|
||||
echo.then set the SPHINXBUILD environment variable to point to the full
|
||||
echo.path of the 'sphinx-build' executable. Alternatively you may add the
|
||||
echo.Sphinx directory to PATH.
|
||||
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
|
||||
echo.installed, then set the SPHINXBUILD environment variable to point
|
||||
echo.to the full path of the 'sphinx-build' executable. Alternatively you
|
||||
echo.may add the Sphinx directory to PATH.
|
||||
echo.
|
||||
echo.If you don't have Sphinx installed, grab it from
|
||||
echo.http://sphinx-doc.org/
|
||||
|
@ -5,7 +5,7 @@ REM Command file for Sphinx documentation
|
||||
pushd %~dp0
|
||||
|
||||
if "%SPHINXBUILD%" == "" (
|
||||
set SPHINXBUILD=python -msphinx
|
||||
set SPHINXBUILD=sphinx-build
|
||||
)
|
||||
set BUILDDIR={{ rbuilddir }}
|
||||
set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% {{ rsrcdir }}
|
||||
@ -52,20 +52,29 @@ if "%1" == "clean" (
|
||||
)
|
||||
|
||||
|
||||
REM Check if sphinx-build is available
|
||||
REM Check if sphinx-build is available and fallback to Python version if any
|
||||
%SPHINXBUILD% 1>NUL 2>NUL
|
||||
if errorlevel 1 (
|
||||
if errorlevel 9009 goto sphinx_python
|
||||
goto sphinx_ok
|
||||
|
||||
:sphinx_python
|
||||
|
||||
set SPHINXBUILD=python -m sphinx.__init__
|
||||
%SPHINXBUILD% 2> nul
|
||||
if errorlevel 9009 (
|
||||
echo.
|
||||
echo.The Sphinx module was not found. Make sure you have Sphinx installed,
|
||||
echo.then set the SPHINXBUILD environment variable to point to the full
|
||||
echo.path of the 'sphinx-build' executable. Alternatively you may add the
|
||||
echo.Sphinx directory to PATH.
|
||||
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
|
||||
echo.installed, then set the SPHINXBUILD environment variable to point
|
||||
echo.to the full path of the 'sphinx-build' executable. Alternatively you
|
||||
echo.may add the Sphinx directory to PATH.
|
||||
echo.
|
||||
echo.If you don't have Sphinx installed, grab it from
|
||||
echo.http://sphinx-doc.org/
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
:sphinx_ok
|
||||
|
||||
|
||||
if "%1" == "html" (
|
||||
%SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html
|
||||
|
@ -26,8 +26,7 @@ from sphinx.locale import __
|
||||
from sphinx.util import logging
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
report_re = re.compile('^(.+?:(?:\\d+)?): \\((DEBUG|INFO|WARNING|ERROR|SEVERE)/(\\d+)?\\) '
|
||||
'(.+?)\n?$')
|
||||
report_re = re.compile('^(.+?:(?:\\d+)?): \\((DEBUG|INFO|WARNING|ERROR|SEVERE)/(\\d+)?\\) ')
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
@ -162,7 +161,8 @@ class WarningStream(object):
|
||||
if not matched:
|
||||
logger.warning(text.rstrip("\r\n"))
|
||||
else:
|
||||
location, type, level, message = matched.groups()
|
||||
location, type, level = matched.groups()
|
||||
message = report_re.sub('', text).rstrip() # type: ignore
|
||||
logger.log(type, message, location=location)
|
||||
|
||||
|
||||
|
25
tests/roots/test-domain-py/module_option.rst
Normal file
25
tests/roots/test-domain-py/module_option.rst
Normal file
@ -0,0 +1,25 @@
|
||||
module_option
|
||||
=============
|
||||
|
||||
.. py:class:: B
|
||||
:module: test.extra
|
||||
|
||||
This is also a test.
|
||||
|
||||
|
||||
.. py:method:: B.baz()
|
||||
:module: test.extra
|
||||
|
||||
Does something similar to :meth:`foo`.
|
||||
|
||||
|
||||
.. py:method:: B.foo()
|
||||
:module: test.extra
|
||||
|
||||
Does something.
|
||||
|
||||
|
||||
.. py:method:: B.test()
|
||||
:module: test.extra
|
||||
|
||||
Does something completely unrelated to :meth:`foo`
|
@ -2,3 +2,8 @@
|
||||
|
||||
extensions = ['sphinx.ext.todo']
|
||||
master_doc = 'index'
|
||||
|
||||
latex_documents = [
|
||||
(master_doc, 'TodoTests.tex', 'Todo Tests Documentation',
|
||||
'Robin Banks', 'manual'),
|
||||
]
|
||||
|
@ -116,6 +116,15 @@ def test_domain_py_xrefs(app, status, warning):
|
||||
assert_refnode(refnodes[11], False, False, 'list', 'class')
|
||||
assert len(refnodes) == 12
|
||||
|
||||
doctree = app.env.get_doctree('module_option')
|
||||
refnodes = list(doctree.traverse(addnodes.pending_xref))
|
||||
print(refnodes)
|
||||
print(refnodes[0])
|
||||
print(refnodes[1])
|
||||
assert_refnode(refnodes[0], 'test.extra', 'B', 'foo', 'meth')
|
||||
assert_refnode(refnodes[1], 'test.extra', 'B', 'foo', 'meth')
|
||||
assert len(refnodes) == 2
|
||||
|
||||
|
||||
@pytest.mark.sphinx('dummy', testroot='domain-py')
|
||||
def test_domain_py_objects(app, status, warning):
|
||||
|
@ -84,3 +84,31 @@ def test_todo_not_included(app, status, warning):
|
||||
# check handled event
|
||||
assert len(todos) == 2
|
||||
assert set(todo[1].astext() for todo in todos) == set(['todo in foo', 'todo in bar'])
|
||||
|
||||
@pytest.mark.sphinx('latex', testroot='ext-todo', freshenv=True,
|
||||
confoverrides={'todo_include_todos': True, 'todo_emit_warnings': True})
|
||||
def test_todo_valid_link(app, status, warning):
|
||||
"""
|
||||
Test that the inserted "original entry" links for todo items have a target
|
||||
that exists in the LaTeX output. The target was previously incorrectly
|
||||
omitted (GitHub issue #1020).
|
||||
"""
|
||||
|
||||
# Ensure the LaTeX output is built.
|
||||
app.builder.build_all()
|
||||
|
||||
content = (app.outdir / 'TodoTests.tex').text()
|
||||
|
||||
# Look for the link to foo. We could equally well look for the link to bar.
|
||||
link = r'\{\\hyperref\[\\detokenize\{(.*?foo.*?)}]\{\\sphinxcrossref{' \
|
||||
r'\\sphinxstyleemphasis{original entry}}}}'
|
||||
m = re.findall(link, content)
|
||||
assert len(m) == 1
|
||||
target = m[0]
|
||||
|
||||
# Look for the targets of this link.
|
||||
labels = [m for m in re.findall(r'\\label\{([^}]*)}', content)
|
||||
if m == target]
|
||||
|
||||
# If everything is correct we should have exactly one target.
|
||||
assert len(labels) == 1
|
||||
|
@ -27,7 +27,7 @@ def test_rstdim_to_latexdim():
|
||||
assert rstdim_to_latexdim('30%') == '0.300\\linewidth'
|
||||
assert rstdim_to_latexdim('160') == '160\\sphinxpxdimen'
|
||||
|
||||
# flaot values
|
||||
# float values
|
||||
assert rstdim_to_latexdim('160.0em') == '160.0em'
|
||||
assert rstdim_to_latexdim('.5em') == '.5em'
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user