diff --git a/CHANGES b/CHANGES index 49086d391..0c5b23d8c 100644 --- a/CHANGES +++ b/CHANGES @@ -165,6 +165,31 @@ Bugs fixed Testing -------- +Release 2.0.2 (in development) +============================== + +Dependencies +------------ + +Incompatible changes +-------------------- + +Deprecated +---------- + +Features added +-------------- + +Bugs fixed +---------- + +* #6286: C++, allow 8 and 9 in hexadecimal integer literals. +* #6305: Fix the string in quickstart for 'path' argument of parser +* LaTeX: Figures in admonitions produced errors (refs: #6364) + +Testing +-------- + Release 2.0.1 (released Apr 08, 2019) ===================================== diff --git a/doc/latex.rst b/doc/latex.rst index 1e194ecfd..39c87484d 100644 --- a/doc/latex.rst +++ b/doc/latex.rst @@ -740,19 +740,41 @@ thus allowing redefinitions. Check the respective files for the defaults. Macros ~~~~~~ -- text styling commands ``\sphinx`` with ```` being one of - ``strong``, ``bfcode``, ``email``, ``tablecontinued``, ``titleref``, - ``menuselection``, ``accelerator``, ``crossref``, ``termref``, ``optional``. +- text styling commands: + - ``\sphinxstrong``, + - ``\sphinxbfcode``, + - ``\sphinxemail``, + - ``\sphinxtablecontinued``, + - ``\sphinxtitleref``, + - ``\sphinxmenuselection``, + - ``\sphinxaccelerator``, + - ``\sphinxcrossref``, + - ``\sphinxtermref``, + - ``\sphinxoptional``. + .. versionadded:: 1.4.5 Use of ``\sphinx`` prefixed macro names to limit possibilities of conflict with LaTeX packages. -- more text styling: ``\sphinxstyle`` with ```` one of - ``indexentry``, ``indexextra``, ``indexpageref``, ``topictitle``, - ``sidebartitle``, ``othertitle``, ``sidebarsubtitle``, ``theadfamily``, - ``emphasis``, ``literalemphasis``, ``strong``, ``literalstrong``, - ``abbreviation``, ``literalintitle``, ``codecontinued``, ``codecontinues`` +- more text styling: + - ``\sphinxstyleindexentry``, + - ``\sphinxstyleindexextra``, + - ``\sphinxstyleindexpageref``, + - ``\sphinxstyletopictitle``, + - ``\sphinxstylesidebartitle``, + - ``\sphinxstyleothertitle``, + - ``\sphinxstylesidebarsubtitle``, + - ``\sphinxstyletheadfamily``, + - ``\sphinxstyleemphasis``, + - ``\sphinxstyleliteralemphasis``, + - ``\sphinxstylestrong``, + - ``\sphinxstyleliteralstrong``, + - ``\sphinxstyleabbreviation``, + - ``\sphinxstyleliteralintitle``, + - ``\sphinxstylecodecontinued``, + - ``\sphinxstylecodecontinues``. + .. versionadded:: 1.5 these macros were formerly hard-coded as non customizable ``\texttt``, ``\emph``, etc... @@ -761,7 +783,7 @@ Macros multiple paragraphs in header cells of tables. .. versionadded:: 1.6.3 ``\sphinxstylecodecontinued`` and ``\sphinxstylecodecontinues``. -- the table of contents is typeset via ``\sphinxtableofcontents`` which is a +- ``\sphinxtableofcontents``: it is a wrapper (defined differently in :file:`sphinxhowto.cls` and in :file:`sphinxmanual.cls`) of standard ``\tableofcontents``. The macro ``\sphinxtableofcontentshook`` is executed during its expansion right before @@ -774,22 +796,22 @@ Macros done during loading of ``'manual'`` docclass are now executed later via ``\sphinxtableofcontentshook``. This macro is also executed by the ``'howto'`` docclass, but defaults to empty with it. -- a custom ``\sphinxmaketitle`` is defined in the class files +- ``\sphinxmaketitle``: it is defined in the class files :file:`sphinxmanual.cls` and :file:`sphinxhowto.cls` and is used as default setting of ``'maketitle'`` :confval:`latex_elements` key. .. versionchanged:: 1.8.3 formerly, ``\maketitle`` from LaTeX document class was modified by Sphinx. -- for ``'manual'`` docclass a macro ``\sphinxbackoftitlepage``, if it is - defined, gets executed at end of ``\sphinxmaketitle``, before the final +- ``\sphinxbackoftitlepage``: for ``'manual'`` docclass, and if it is + defined, it gets executed at end of ``\sphinxmaketitle``, before the final ``\clearpage``. Use either the ``'maketitle'`` key or the ``'preamble'`` key of :confval:`latex_elements` to add a custom definition of ``\sphinxbackoftitlepage``. .. versionadded:: 1.8.3 -- the citation reference is typeset via ``\sphinxcite`` which is a wrapper - of standard ``\cite``. +- ``\sphinxcite``: it is a wrapper of standard ``\cite`` for citation + references. Environments ~~~~~~~~~~~~ @@ -801,12 +823,23 @@ Environments .. versionadded:: 1.5.6 formerly, the ``\small`` was hardcoded in LaTeX writer and the ending ``\par`` was lacking. -- for each admonition type ````, the - used environment is named ``sphinx``. They may be ``\renewenvironment`` +- environments associated with admonitions: + + - ``sphinxnote``, + - ``sphinxhint``, + - ``sphinximportant``, + - ``sphinxtip``, + - ``sphinxwarning``, + - ``sphinxcaution``, + - ``sphinxattention``, + - ``sphinxdanger``, + - ``sphinxerror``. + + They may be ``\renewenvironment`` 'd individually, and must then be defined with one argument (it is the heading of the notice, for example ``Warning:`` for :dudir:`warning` directive, if English is the document language). Their default definitions use either the - *sphinxheavybox* (for the first listed directives) or the *sphinxlightbox* + *sphinxheavybox* (for the last 5 ones) or the *sphinxlightbox* environments, configured to use the parameters (colours, border thickness) specific to each type, which can be set via ``'sphinxsetup'`` string. diff --git a/doc/usage/configuration.rst b/doc/usage/configuration.rst index f411abb1c..6619c5015 100644 --- a/doc/usage/configuration.rst +++ b/doc/usage/configuration.rst @@ -497,6 +497,17 @@ General configuration direct usage of :program:`sphinx-build` as it caches (in its default usage) the parsed source files in per builder locations. + .. hint:: An alternative way to effectively deactivate (or customize) the + smart quotes for a given builder, for example ``latex``, is to use + ``make`` this way: + + .. code-block:: console + + make latex O="-D smartquotes_action=" + + This can follow some ``make html`` with no problem, in contrast to the + situation from the prior note. It requires Docutils 0.14 or later. + .. versionadded:: 1.6.6 .. confval:: tls_verify diff --git a/sphinx/cmd/build.py b/sphinx/cmd/build.py index ed11ea763..810d69078 100644 --- a/sphinx/cmd/build.py +++ b/sphinx/cmd/build.py @@ -45,7 +45,7 @@ def handle_exception(app, args, exception, stderr=sys.stderr): traceback.print_exc(None, stderr) print(file=stderr) if isinstance(exception, KeyboardInterrupt): - print(__('interrupted!'), file=stderr) + print(__('Interrupted!'), file=stderr) elif isinstance(exception, SystemMessage): print(red(__('reST markup error:')), file=stderr) print(terminal_safe(exception.args[0]), file=stderr) diff --git a/sphinx/cmd/quickstart.py b/sphinx/cmd/quickstart.py index 51fa29cbd..972b62149 100644 --- a/sphinx/cmd/quickstart.py +++ b/sphinx/cmd/quickstart.py @@ -506,7 +506,7 @@ def get_parser(): version='%%(prog)s %s' % __display_version__) parser.add_argument('path', metavar='PROJECT_DIR', default='.', nargs='?', - help=__('output path')) + help=__('project root')) group = parser.add_argument_group(__('Structure options')) group.add_argument('--sep', action='store_true', default=None, diff --git a/sphinx/deprecation.py b/sphinx/deprecation.py index f283d7e5d..23efe8ba7 100644 --- a/sphinx/deprecation.py +++ b/sphinx/deprecation.py @@ -48,8 +48,8 @@ class _ModuleWrapper: def __getattr__(self, name): # type: (str) -> Any if name in self._objects: - warnings.warn("%s.%s is now deprecated. Please refer CHANGES to grasp " - "the changes of Sphinx API." % (self._modname, name), + warnings.warn("%s.%s is deprecated. Check CHANGES for Sphinx " + "API modifications." % (self._modname, name), self._warning, stacklevel=3) return self._objects[name] diff --git a/sphinx/domains/cpp.py b/sphinx/domains/cpp.py index a9f4b1c24..417bdb2b6 100644 --- a/sphinx/domains/cpp.py +++ b/sphinx/domains/cpp.py @@ -292,7 +292,7 @@ logger = logging.getLogger(__name__) _integer_literal_re = re.compile(r'[1-9][0-9]*') _octal_literal_re = re.compile(r'0[0-7]*') -_hex_literal_re = re.compile(r'0[xX][0-7a-fA-F][0-7a-fA-F]*') +_hex_literal_re = re.compile(r'0[xX][0-9a-fA-F][0-9a-fA-F]*') _binary_literal_re = re.compile(r'0[bB][01][01]*') _integer_suffix_re = re.compile(r'') _float_literal_re = re.compile(r'''(?x) diff --git a/sphinx/writers/latex.py b/sphinx/writers/latex.py index 7681f479b..dd285845c 100644 --- a/sphinx/writers/latex.py +++ b/sphinx/writers/latex.py @@ -466,6 +466,7 @@ class LaTeXTranslator(SphinxTranslator): self.in_term = 0 self.needs_linetrimming = 0 self.in_minipage = 0 + self.no_latex_floats = 0 self.first_document = 1 self.this_is_the_title = 1 self.literal_whitespace = 0 @@ -1587,6 +1588,9 @@ class LaTeXTranslator(SphinxTranslator): def visit_figure(self, node): # type: (nodes.Element) -> None + align = self.elements['figure_align'] + if self.no_latex_floats: + align = "H" if self.table: # TODO: support align option if 'width' in node: @@ -1612,8 +1616,7 @@ class LaTeXTranslator(SphinxTranslator): self.body.append('\n\\begin{center}') self.context.append('\\end{center}\n') else: - self.body.append('\n\\begin{figure}[%s]\n\\centering\n' % - self.elements['figure_align']) + self.body.append('\n\\begin{figure}[%s]\n\\centering\n' % align) if any(isinstance(child, nodes.caption) for child in node): self.body.append('\\capstart\n') self.context.append('\\end{figure}\n') @@ -1653,20 +1656,24 @@ class LaTeXTranslator(SphinxTranslator): def visit_admonition(self, node): # type: (nodes.Element) -> None self.body.append('\n\\begin{sphinxadmonition}{note}') + self.no_latex_floats += 1 def depart_admonition(self, node): # type: (nodes.Element) -> None self.body.append('\\end{sphinxadmonition}\n') + self.no_latex_floats -= 1 def _visit_named_admonition(self, node): # type: (nodes.Element) -> None label = admonitionlabels[node.tagname] self.body.append('\n\\begin{sphinxadmonition}{%s}{%s:}' % (node.tagname, label)) + self.no_latex_floats += 1 def _depart_named_admonition(self, node): # type: (nodes.Element) -> None self.body.append('\\end{sphinxadmonition}\n') + self.no_latex_floats -= 1 visit_attention = _visit_named_admonition depart_attention = _depart_named_admonition diff --git a/tests/roots/test-latex-figure-in-admonition/conf.py b/tests/roots/test-latex-figure-in-admonition/conf.py new file mode 100644 index 000000000..a45d22e28 --- /dev/null +++ b/tests/roots/test-latex-figure-in-admonition/conf.py @@ -0,0 +1 @@ +exclude_patterns = ['_build'] diff --git a/tests/roots/test-latex-figure-in-admonition/img.png b/tests/roots/test-latex-figure-in-admonition/img.png new file mode 100644 index 000000000..a97e86d66 Binary files /dev/null and b/tests/roots/test-latex-figure-in-admonition/img.png differ diff --git a/tests/roots/test-latex-figure-in-admonition/index.rst b/tests/roots/test-latex-figure-in-admonition/index.rst new file mode 100644 index 000000000..e3d39d3ee --- /dev/null +++ b/tests/roots/test-latex-figure-in-admonition/index.rst @@ -0,0 +1,9 @@ +Test Figure in Admonition +========================= + +.. caution:: + + This uses a figure in an admonition. + + .. figure:: img.png + diff --git a/tests/test_build_latex.py b/tests/test_build_latex.py index 45e993501..13bb22e96 100644 --- a/tests/test_build_latex.py +++ b/tests/test_build_latex.py @@ -1399,6 +1399,12 @@ def test_latex_labels(app, status, warning): assert result.count(r'\label{\detokenize{index:section1}}') == 1 +@pytest.mark.sphinx('latex', testroot='latex-figure-in-admonition') +def test_latex_figure_in_admonition(app, status, warning): + app.builder.build_all() + result = (app.outdir / 'python.tex').text(encoding='utf8') + assert(r'\begin{figure}[H]' in result) + def test_default_latex_documents(): from sphinx.util import texescape texescape.init() diff --git a/tests/test_domain_cpp.py b/tests/test_domain_cpp.py index d6470dc7c..c81d66b17 100644 --- a/tests/test_domain_cpp.py +++ b/tests/test_domain_cpp.py @@ -114,7 +114,7 @@ def test_expressions(): exprCheck('nullptr', 'LDnE') exprCheck('true', 'L1E') exprCheck('false', 'L0E') - ints = ['5', '0', '075', '0xF', '0XF', '0b1', '0B1'] + ints = ['5', '0', '075', '0x0123456789ABCDEF', '0XF', '0b1', '0B1'] unsignedSuffix = ['', 'u', 'U'] longSuffix = ['', 'l', 'L', 'll', 'LL'] for i in ints: