mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge branch '5.x' into autodoc_force_undocumented_rtype
This commit is contained in:
@@ -1,11 +1,3 @@
|
||||
"""
|
||||
pytest config for sphinx/tests
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
:copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
|
||||
import os
|
||||
import shutil
|
||||
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
"""
|
||||
Test module for napoleon PEP 526 compatibility with google style
|
||||
"""
|
||||
"""Test module for napoleon PEP 526 compatibility with google style"""
|
||||
|
||||
module_level_var: int = 99
|
||||
"""This is an example module level variable"""
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
"""
|
||||
Test module for napoleon PEP 526 compatibility with numpy style
|
||||
"""
|
||||
"""Test module for napoleon PEP 526 compatibility with numpy style"""
|
||||
|
||||
module_level_var: int = 99
|
||||
"""This is an example module level variable"""
|
||||
|
||||
@@ -1,91 +1,41 @@
|
||||
var DOCUMENTATION_OPTIONS = {};
|
||||
const DOCUMENTATION_OPTIONS = {};
|
||||
|
||||
describe('highlightText', function() {
|
||||
|
||||
describe('jQuery extensions', function() {
|
||||
|
||||
describe('urldecode', function() {
|
||||
|
||||
it('should correctly decode URLs and replace `+`s with a spaces', function() {
|
||||
var test_encoded_string =
|
||||
'%D1%88%D0%B5%D0%BB%D0%BB%D1%8B+%D1%88%D0%B5%D0%BB%D0%BB%D1%8B';
|
||||
var test_decoded_string = 'шеллы шеллы';
|
||||
expect(jQuery.urldecode(test_encoded_string)).toEqual(test_decoded_string);
|
||||
});
|
||||
|
||||
it('+ should result in " "', function() {
|
||||
expect(jQuery.urldecode('+')).toEqual(' ');
|
||||
});
|
||||
const cyrillicTerm = 'шеллы';
|
||||
const umlautTerm = 'gänsefüßchen';
|
||||
|
||||
it('should highlight text incl. special characters correctly in HTML', function() {
|
||||
const highlightTestSpan = new DOMParser().parseFromString(
|
||||
'<span>This is the шеллы and Gänsefüßchen test!</span>', 'text/html').body.firstChild
|
||||
_highlightText(highlightTestSpan, cyrillicTerm, 'highlighted');
|
||||
_highlightText(highlightTestSpan, umlautTerm, 'highlighted');
|
||||
const expectedHtmlString =
|
||||
'This is the <span class=\"highlighted\">шеллы</span> and ' +
|
||||
'<span class=\"highlighted\">Gänsefüßchen</span> test!';
|
||||
expect(highlightTestSpan.innerHTML).toEqual(expectedHtmlString);
|
||||
});
|
||||
|
||||
describe('getQueryParameters', function() {
|
||||
var paramString = '?q=test+this&check_keywords=yes&area=default';
|
||||
var queryParamObject = {
|
||||
area: ['default'],
|
||||
check_keywords: ['yes'],
|
||||
q: ['test this']
|
||||
};
|
||||
|
||||
it('should correctly create query parameter object from string', function() {
|
||||
expect(jQuery.getQueryParameters(paramString)).toEqual(queryParamObject);
|
||||
});
|
||||
|
||||
it('should correctly create query param object from URL params', function() {
|
||||
history.pushState({}, '_', window.location + paramString);
|
||||
expect(jQuery.getQueryParameters()).toEqual(queryParamObject);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('highlightText', function() {
|
||||
|
||||
var cyrillicTerm = 'шеллы';
|
||||
var umlautTerm = 'gänsefüßchen';
|
||||
|
||||
it('should highlight text incl. special characters correctly in HTML', function() {
|
||||
var highlightTestSpan =
|
||||
jQuery('<span>This is the шеллы and Gänsefüßchen test!</span>');
|
||||
jQuery(document.body).append(highlightTestSpan);
|
||||
highlightTestSpan.highlightText(cyrillicTerm, 'highlighted');
|
||||
highlightTestSpan.highlightText(umlautTerm, 'highlighted');
|
||||
var expectedHtmlString =
|
||||
'This is the <span class=\"highlighted\">шеллы</span> and ' +
|
||||
'<span class=\"highlighted\">Gänsefüßchen</span> test!';
|
||||
expect(highlightTestSpan.html()).toEqual(expectedHtmlString);
|
||||
});
|
||||
|
||||
it('should highlight text incl. special characters correctly in SVG', function() {
|
||||
var highlightTestSvg = jQuery(
|
||||
'<span id="svg-highlight-test">' +
|
||||
'<svg xmlns="http://www.w3.org/2000/svg" height="50" width="500">' +
|
||||
'<text x="0" y="15">' +
|
||||
'This is the шеллы and Gänsefüßchen test!' +
|
||||
'</text>' +
|
||||
'</svg>' +
|
||||
'</span>');
|
||||
jQuery(document.body).append(highlightTestSvg);
|
||||
highlightTestSvg.highlightText(cyrillicTerm, 'highlighted');
|
||||
highlightTestSvg.highlightText(umlautTerm, 'highlighted');
|
||||
/* Note wild cards and ``toMatch``; allowing for some variability
|
||||
seems to be necessary, even between different FF versions */
|
||||
var expectedSvgString =
|
||||
it('should highlight text incl. special characters correctly in SVG', function() {
|
||||
const highlightTestSvg = new DOMParser().parseFromString(
|
||||
'<span id="svg-highlight-test">' +
|
||||
'<svg xmlns="http://www.w3.org/2000/svg" height="50" width="500">' +
|
||||
'<rect x=".*" y=".*" width=".*" height=".*" class="highlighted">' +
|
||||
'</rect>' +
|
||||
'<rect x=".*" y=".*" width=".*" height=".*" class="highlighted">' +
|
||||
'</rect>' +
|
||||
'<text x=".*" y=".*">' +
|
||||
'This is the ' +
|
||||
'<tspan>шеллы</tspan> and ' +
|
||||
'<tspan>Gänsefüßchen</tspan> test!' +
|
||||
'<text x="0" y="15">' +
|
||||
'This is the шеллы and Gänsefüßchen test!' +
|
||||
'</text>' +
|
||||
'</svg>';
|
||||
expect(highlightTestSvg.html()).toMatch(new RegExp(expectedSvgString));
|
||||
});
|
||||
|
||||
'</svg>' +
|
||||
'</span>', 'text/html').body.firstChild
|
||||
_highlightText(highlightTestSvg, cyrillicTerm, 'highlighted');
|
||||
_highlightText(highlightTestSvg, umlautTerm, 'highlighted');
|
||||
/* Note wild cards and ``toMatch``; allowing for some variability
|
||||
seems to be necessary, even between different FF versions */
|
||||
const expectedSvgString =
|
||||
'<svg xmlns="http://www.w3.org/2000/svg" height="50" width="500">'
|
||||
+ '<rect x=".*" y=".*" width=".*" height=".*" class="highlighted"/>'
|
||||
+ '<rect x=".*" y=".*" width=".*" height=".*" class="highlighted"/>'
|
||||
+ '<text x=".*" y=".*">This is the <tspan>шеллы</tspan> and '
|
||||
+ '<tspan>Gänsefüßchen</tspan> test!</text></svg>';
|
||||
expect(new XMLSerializer().serializeToString(highlightTestSvg.firstChild)).toMatch(new RegExp(expectedSvgString));
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
@@ -30,3 +30,33 @@ describe('Basic html theme search', function() {
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
// This is regression test for https://github.com/sphinx-doc/sphinx/issues/3150
|
||||
describe('splitQuery regression tests', () => {
|
||||
|
||||
it('can split English words', () => {
|
||||
const parts = splitQuery(' Hello World ')
|
||||
expect(parts).toEqual(['Hello', 'World'])
|
||||
})
|
||||
|
||||
it('can split special characters', () => {
|
||||
const parts = splitQuery('Pin-Code')
|
||||
expect(parts).toEqual(['Pin', 'Code'])
|
||||
})
|
||||
|
||||
it('can split Chinese characters', () => {
|
||||
const parts = splitQuery('Hello from 中国 上海')
|
||||
expect(parts).toEqual(['Hello', 'from', '中国', '上海'])
|
||||
})
|
||||
|
||||
it('can split Emoji (surrogate pair) characters. It should keep emojis.', () => {
|
||||
const parts = splitQuery('😁😁')
|
||||
expect(parts).toEqual(['😁😁'])
|
||||
})
|
||||
|
||||
it('can split umlauts. It should keep umlauts.', () => {
|
||||
const parts = splitQuery('Löschen Prüfung Abändern ærlig spørsmål')
|
||||
expect(parts).toEqual(['Löschen', 'Prüfung', 'Abändern', 'ærlig', 'spørsmål'])
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
project = 'Sphinx ChangesBuilder tests'
|
||||
copyright = '2007-2021 by the Sphinx team, see AUTHORS'
|
||||
copyright = '2007-2022 by the Sphinx team, see AUTHORS'
|
||||
version = '0.6'
|
||||
release = '0.6alpha1'
|
||||
|
||||
64
tests/roots/test-directive-code/dedent.rst
Normal file
64
tests/roots/test-directive-code/dedent.rst
Normal file
@@ -0,0 +1,64 @@
|
||||
dedent option
|
||||
-------------
|
||||
|
||||
.. code-block::
|
||||
|
||||
First line
|
||||
Second line
|
||||
Third line
|
||||
Fourth line
|
||||
|
||||
ReST has no fixed indent and only a change in indention is significant not the amount [1]_.
|
||||
Thus, the following code inside the code block is not indent even it looks so with respect to the previous block.
|
||||
|
||||
.. code-block::
|
||||
|
||||
First line
|
||||
Second line
|
||||
Third line
|
||||
Fourth line
|
||||
|
||||
Having an option "fixates" the indent to be 3 spaces, thus the code inside the code block is indented by 4 spaces.
|
||||
|
||||
.. code-block::
|
||||
:class: dummy
|
||||
|
||||
First line
|
||||
Second line
|
||||
Third line
|
||||
Fourth line
|
||||
|
||||
The code has 6 spaces indent, minus 4 spaces dedent should yield a 2 space indented code in the output.
|
||||
|
||||
.. code-block::
|
||||
:dedent: 4
|
||||
|
||||
First line
|
||||
Second line
|
||||
Third line
|
||||
Fourth line
|
||||
|
||||
Dedenting by zero, should not strip any spaces and be a no-op.
|
||||
|
||||
.. note::
|
||||
This can be used as an alternative to ``:class: dummy`` above, to fixate the ReST indention of the block.
|
||||
|
||||
.. code-block::
|
||||
:dedent: 0
|
||||
|
||||
First line
|
||||
Second line
|
||||
Third line
|
||||
Fourth line
|
||||
|
||||
Dedent without argument should autostrip common whitespace at the beginning.
|
||||
|
||||
.. code-block::
|
||||
:dedent:
|
||||
|
||||
First line
|
||||
Second line
|
||||
Third line
|
||||
Fourth line
|
||||
|
||||
.. [1] https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html#indentation
|
||||
@@ -22,10 +22,12 @@ class D:
|
||||
class E:
|
||||
def __init__(self):
|
||||
"""E(foo: int, bar: int, baz: int) -> None \\
|
||||
E(foo: str, bar: str, baz: str) -> None"""
|
||||
E(foo: str, bar: str, baz: str) -> None \\
|
||||
E(foo: float, bar: float, baz: float)"""
|
||||
|
||||
|
||||
class F:
|
||||
def __init__(self):
|
||||
"""F(foo: int, bar: int, baz: int) -> None
|
||||
F(foo: str, bar: str, baz: str) -> None"""
|
||||
F(foo: str, bar: str, baz: str) -> None
|
||||
F(foo: float, bar: float, baz: float)"""
|
||||
|
||||
@@ -9,3 +9,6 @@ C = Callable[[int], None] # a generic alias not having a doccomment
|
||||
class Class:
|
||||
#: A list of int
|
||||
T = List[int]
|
||||
|
||||
#: A list of Class
|
||||
L = List[Class]
|
||||
|
||||
@@ -8,7 +8,10 @@ SENTINEL = object()
|
||||
def foo(name: str = CONSTANT,
|
||||
sentinel: Any = SENTINEL,
|
||||
now: datetime = datetime.now(),
|
||||
color: int = 0xFFFFFF) -> None:
|
||||
color: int = 0xFFFFFF,
|
||||
*,
|
||||
kwarg1,
|
||||
kwarg2 = 0xFFFFFF) -> None:
|
||||
"""docstring"""
|
||||
|
||||
|
||||
@@ -16,5 +19,6 @@ class Class:
|
||||
"""docstring"""
|
||||
|
||||
def meth(self, name: str = CONSTANT, sentinel: Any = SENTINEL,
|
||||
now: datetime = datetime.now(), color: int = 0xFFFFFF) -> None:
|
||||
now: datetime = datetime.now(), color: int = 0xFFFFFF,
|
||||
*, kwarg1, kwarg2 = 0xFFFFFF) -> None:
|
||||
"""docstring"""
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from datetime import date
|
||||
from typing import NewType, TypeVar
|
||||
|
||||
#: T1
|
||||
@@ -15,7 +16,7 @@ T4 = TypeVar("T4", covariant=True)
|
||||
T5 = TypeVar("T5", contravariant=True)
|
||||
|
||||
#: T6
|
||||
T6 = NewType("T6", int)
|
||||
T6 = NewType("T6", date)
|
||||
|
||||
#: T7
|
||||
T7 = TypeVar("T7", bound=int)
|
||||
@@ -26,4 +27,4 @@ class Class:
|
||||
T1 = TypeVar("T1")
|
||||
|
||||
#: T6
|
||||
T6 = NewType("T6", int)
|
||||
T6 = NewType("T6", date)
|
||||
|
||||
@@ -3,3 +3,4 @@ extlinks = {
|
||||
'user': ('https://github.com/%s', '@%s'),
|
||||
'repo': ('https://github.com/%s', 'project %s'),
|
||||
}
|
||||
extlinks_detect_hardcoded_links = True
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
extensions = ['sphinx.ext.extlinks']
|
||||
extlinks = {'issue': ('https://github.com/sphinx-doc/sphinx/issues/%s', 'issue %s')}
|
||||
extlinks_detect_hardcoded_links = True
|
||||
|
||||
3
tests/roots/test-ext-intersphinx-role/conf.py
Normal file
3
tests/roots/test-ext-intersphinx-role/conf.py
Normal file
@@ -0,0 +1,3 @@
|
||||
extensions = ['sphinx.ext.intersphinx']
|
||||
# the role should not honor this conf var
|
||||
intersphinx_disabled_reftypes = ['*']
|
||||
44
tests/roots/test-ext-intersphinx-role/index.rst
Normal file
44
tests/roots/test-ext-intersphinx-role/index.rst
Normal file
@@ -0,0 +1,44 @@
|
||||
- ``module1`` is only defined in ``inv``:
|
||||
:external:py:mod:`module1`
|
||||
|
||||
.. py:module:: module2
|
||||
|
||||
- ``module2`` is defined here and also in ``inv``, but should resolve to inv:
|
||||
:external:py:mod:`module2`
|
||||
|
||||
- ``module3`` is not defined anywhere, so should warn:
|
||||
:external:py:mod:`module3`
|
||||
|
||||
.. py:module:: module10
|
||||
|
||||
- ``module10`` is only defined here, but should still not be resolved to:
|
||||
:external:py:mod:`module10`
|
||||
|
||||
- a function in inv:
|
||||
:external:py:func:`module1.func`
|
||||
- a method, but with old style inventory prefix, which shouldn't work:
|
||||
:external:py:meth:`inv:Foo.bar`
|
||||
- a non-existing role:
|
||||
:external:py:nope:`something`
|
||||
|
||||
.. default-domain:: cpp
|
||||
|
||||
- a type where the default domain is used to find the role:
|
||||
:external:type:`std::uint8_t`
|
||||
- a non-existing role in default domain:
|
||||
:external:nope:`somethingElse`
|
||||
|
||||
- two roles in ``std`` which can be found without a default domain:
|
||||
|
||||
- :external:doc:`docname`
|
||||
- :external:option:`ls -l`
|
||||
|
||||
|
||||
- a function with explicit inventory:
|
||||
:external+inv:c:func:`CFunc`
|
||||
- a class with explicit non-existing inventory, which also has upper-case in name:
|
||||
:external+invNope:cpp:class:`foo::Bar`
|
||||
|
||||
|
||||
- explicit title:
|
||||
:external:cpp:type:`FoonsTitle <foons>`
|
||||
@@ -33,6 +33,7 @@ The section with a reference to [AuthorYear]_
|
||||
* Second footnote: [1]_
|
||||
* `Sphinx <http://sphinx-doc.org/>`_
|
||||
* Third footnote: [#]_
|
||||
* Fourth footnote: [#named]_
|
||||
* `URL including tilde <http://sphinx-doc.org/~test/>`_
|
||||
* GitHub Page: `https://github.com/sphinx-doc/sphinx <https://github.com/sphinx-doc/sphinx>`_
|
||||
* Mailing list: `sphinx-dev@googlegroups.com <mailto:sphinx-dev@googlegroups.com>`_
|
||||
@@ -41,6 +42,7 @@ The section with a reference to [AuthorYear]_
|
||||
.. [1] Second
|
||||
.. [#] Third [#]_
|
||||
.. [#] Footnote inside footnote
|
||||
.. [#named] Fourth
|
||||
|
||||
The section with a reference to [#]_
|
||||
=====================================
|
||||
@@ -175,3 +177,12 @@ The section with an object description
|
||||
|
||||
.. py:function:: dummy(N)
|
||||
:noindex:
|
||||
|
||||
Footnotes referred twice
|
||||
========================
|
||||
|
||||
* Explicitly numbered footnote: [100]_ [100]_
|
||||
* Named footnote: [#twice]_ [#twice]_
|
||||
|
||||
.. [100] Numbered footnote
|
||||
.. [#twice] Named footnote
|
||||
|
||||
@@ -18,5 +18,5 @@ test-glossary
|
||||
über
|
||||
Gewisse
|
||||
|
||||
änhlich
|
||||
ähnlich
|
||||
Dinge
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
"""
|
||||
Test with nested classes.
|
||||
"""Test with nested classes.
|
||||
"""
|
||||
|
||||
|
||||
|
||||
@@ -12,3 +12,18 @@ i18n with glossary terms
|
||||
The corresponding glossary #2
|
||||
|
||||
link to :term:`Some term`.
|
||||
|
||||
Translated glossary should be sorted by translated terms:
|
||||
|
||||
.. glossary::
|
||||
:sorted:
|
||||
|
||||
AAA
|
||||
Define AAA
|
||||
|
||||
CCC
|
||||
EEE
|
||||
Define CCC
|
||||
|
||||
BBB
|
||||
Define BBB
|
||||
|
||||
@@ -49,6 +49,14 @@ code blocks
|
||||
literal-block
|
||||
in list
|
||||
|
||||
.. highlight:: none
|
||||
|
||||
::
|
||||
|
||||
test_code_for_noqa()
|
||||
continued()
|
||||
|
||||
|
||||
doctest blocks
|
||||
==============
|
||||
|
||||
|
||||
16
tests/roots/test-intl/noqa.txt
Normal file
16
tests/roots/test-intl/noqa.txt
Normal file
@@ -0,0 +1,16 @@
|
||||
First section
|
||||
=============
|
||||
|
||||
Some text with a reference, :ref:`next-section`.
|
||||
|
||||
Another reference: :ref:`next-section`.
|
||||
|
||||
This should allow to test escaping ``#noqa``.
|
||||
|
||||
.. _next-section:
|
||||
|
||||
Next section
|
||||
============
|
||||
|
||||
Some text, again referring to the section: :ref:`next-section`.
|
||||
|
||||
@@ -1,35 +1,59 @@
|
||||
# SOME DESCRIPTIVE TITLE.
|
||||
# Copyright (C) 2012, foof
|
||||
# This file is distributed under the same license as the foo package.
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||
#
|
||||
#, fuzzy
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: sphinx 1.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2013-01-29 14:10+0000\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
msgid "i18n with glossary terms"
|
||||
msgstr "I18N WITH GLOSSARY TERMS"
|
||||
|
||||
msgid "Some term"
|
||||
msgstr "SOME NEW TERM"
|
||||
|
||||
msgid "The corresponding glossary"
|
||||
msgstr "THE CORRESPONDING GLOSSARY"
|
||||
|
||||
msgid "Some other term"
|
||||
msgstr "SOME OTHER NEW TERM"
|
||||
|
||||
msgid "The corresponding glossary #2"
|
||||
msgstr "THE CORRESPONDING GLOSSARY #2"
|
||||
|
||||
msgid "link to :term:`Some term`."
|
||||
msgstr "LINK TO :term:`SOME NEW TERM`."
|
||||
# SOME DESCRIPTIVE TITLE.
|
||||
# Copyright (C) 2012, foof
|
||||
# This file is distributed under the same license as the foo package.
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||
#
|
||||
#, fuzzy
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: sphinx 1.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2013-01-29 14:10+0000\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
msgid "i18n with glossary terms"
|
||||
msgstr "I18N WITH GLOSSARY TERMS"
|
||||
|
||||
msgid "Some term"
|
||||
msgstr "SOME NEW TERM"
|
||||
|
||||
msgid "The corresponding glossary"
|
||||
msgstr "THE CORRESPONDING GLOSSARY"
|
||||
|
||||
msgid "Some other term"
|
||||
msgstr "SOME OTHER NEW TERM"
|
||||
|
||||
msgid "The corresponding glossary #2"
|
||||
msgstr "THE CORRESPONDING GLOSSARY #2"
|
||||
|
||||
msgid "link to :term:`Some term`."
|
||||
msgstr "LINK TO :term:`SOME NEW TERM`."
|
||||
|
||||
msgid "Translated glossary should be sorted by translated terms:"
|
||||
msgstr "TRANSLATED GLOSSARY SHOULD BE SORTED BY TRANSLATED TERMS:"
|
||||
|
||||
msgid "BBB"
|
||||
msgstr "TRANSLATED TERM XXX"
|
||||
|
||||
msgid "Define BBB"
|
||||
msgstr "DEFINE XXX"
|
||||
|
||||
msgid "AAA"
|
||||
msgstr "TRANSLATED TERM YYY"
|
||||
|
||||
msgid "Define AAA"
|
||||
msgstr "DEFINE YYY"
|
||||
|
||||
msgid "CCC"
|
||||
msgstr "TRANSLATED TERM ZZZ"
|
||||
|
||||
msgid "EEE"
|
||||
msgstr "VVV"
|
||||
|
||||
msgid "Define CCC"
|
||||
msgstr "DEFINE ZZZ"
|
||||
|
||||
@@ -77,6 +77,12 @@ msgid "literal-block\n"
|
||||
msgstr "LITERAL-BLOCK\n"
|
||||
"IN LIST"
|
||||
|
||||
msgid "test_code_for_noqa()\n"
|
||||
"continued()"
|
||||
msgstr ""
|
||||
"# TRAILING noqa SHOULD NOT GET STRIPPED\n"
|
||||
"# FROM THIS BLOCK. #noqa"
|
||||
|
||||
msgid "doctest blocks"
|
||||
msgstr "DOCTEST-BLOCKS"
|
||||
|
||||
|
||||
46
tests/roots/test-intl/xx/LC_MESSAGES/noqa.po
Normal file
46
tests/roots/test-intl/xx/LC_MESSAGES/noqa.po
Normal file
@@ -0,0 +1,46 @@
|
||||
# SOME DESCRIPTIVE TITLE.
|
||||
# Copyright (C)
|
||||
# This file is distributed under the same license as the Sphinx intl <Tests> package.
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2022-01-16 15:23+0100\n"
|
||||
"PO-Revision-Date: 2022-01-16 15:23+0100\n"
|
||||
"Last-Translator: Jean Abou Samra <jean@abou-samra.fr>\n"
|
||||
"Language-Team: \n"
|
||||
"Language: xx\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"X-Generator: Poedit 3.0\n"
|
||||
|
||||
#: ../tests/roots/test-intl/noqa.txt:2
|
||||
msgid "First section"
|
||||
msgstr "FIRST SECTION"
|
||||
|
||||
#: ../tests/roots/test-intl/noqa.txt:4
|
||||
msgid "Some text with a reference, :ref:`next-section`."
|
||||
msgstr "TRANSLATED TEXT WITHOUT REFERENCE. #noqa"
|
||||
|
||||
#: ../tests/roots/test-intl/noqa.txt:6
|
||||
msgid "Another reference: :ref:`next-section`."
|
||||
msgstr ""
|
||||
"TEST noqa WHITESPACE INSENSITIVITY.\n"
|
||||
"# \n"
|
||||
" noqa"
|
||||
|
||||
#: ../tests/roots/test-intl/noqa.txt:8
|
||||
msgid "This should allow to test escaping ``#noqa``."
|
||||
msgstr "``#noqa`` IS ESCAPED AT THE END OF THIS STRING. \\#noqa"
|
||||
|
||||
#: ../tests/roots/test-intl/noqa.txt:13
|
||||
msgid "Next section"
|
||||
msgstr "NEXT SECTION WITH PARAGRAPH TO TEST BARE noqa"
|
||||
|
||||
# This edge case should not fail.
|
||||
#: ../tests/roots/test-intl/noqa.txt:15
|
||||
msgid "Some text, again referring to the section: :ref:`next-section`."
|
||||
msgstr "#noqa"
|
||||
@@ -0,0 +1,5 @@
|
||||
Broken link
|
||||
===========
|
||||
|
||||
Some links are `broken <https://www.sphinx-doc.org/this-is-another-broken-link>`__
|
||||
but sometimes not worrying about some broken links is a valid strategy.
|
||||
@@ -0,0 +1,5 @@
|
||||
Broken link
|
||||
===========
|
||||
|
||||
Some links are `broken <https://www.sphinx-doc.org/this-is-a-broken-link>`__
|
||||
but sometimes not worrying about some broken links is a valid strategy.
|
||||
5
tests/roots/test-linkcheck-documents_exclude/conf.py
Normal file
5
tests/roots/test-linkcheck-documents_exclude/conf.py
Normal file
@@ -0,0 +1,5 @@
|
||||
exclude_patterns = ['_build']
|
||||
linkcheck_exclude_documents = [
|
||||
'^broken_link$',
|
||||
'br[0-9]ken_link',
|
||||
]
|
||||
3
tests/roots/test-linkcheck-documents_exclude/index.rst
Normal file
3
tests/roots/test-linkcheck-documents_exclude/index.rst
Normal file
@@ -0,0 +1,3 @@
|
||||
.. toctree::
|
||||
broken_link
|
||||
br0ken_link
|
||||
@@ -352,7 +352,7 @@ This tests :CLASS:`role names in uppercase`.
|
||||
über
|
||||
Gewisse
|
||||
|
||||
änhlich
|
||||
ähnlich
|
||||
Dinge
|
||||
|
||||
.. productionlist::
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from distutils.core import setup
|
||||
from setuptools import setup
|
||||
|
||||
from sphinx.setup_command import BuildDoc
|
||||
|
||||
|
||||
@@ -1,12 +1,4 @@
|
||||
"""
|
||||
test_api_translator
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Test the Sphinx API for translator.
|
||||
|
||||
:copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
"""Test the Sphinx API for translator."""
|
||||
|
||||
import sys
|
||||
|
||||
|
||||
@@ -1,12 +1,4 @@
|
||||
"""
|
||||
test_application
|
||||
~~~~~~~~~~~~~~~~
|
||||
|
||||
Test the Sphinx class.
|
||||
|
||||
:copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
"""Test the Sphinx class."""
|
||||
|
||||
from unittest.mock import Mock
|
||||
|
||||
|
||||
@@ -1,12 +1,4 @@
|
||||
"""
|
||||
test_build
|
||||
~~~~~~~~~~
|
||||
|
||||
Test all builders.
|
||||
|
||||
:copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
"""Test all builders."""
|
||||
|
||||
import sys
|
||||
from textwrap import dedent
|
||||
|
||||
@@ -1,12 +1,4 @@
|
||||
"""
|
||||
test_build_changes
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Test the ChangesBuilder class.
|
||||
|
||||
:copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
"""Test the ChangesBuilder class."""
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@@ -1,12 +1,4 @@
|
||||
"""
|
||||
test_build_dirhtml
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Test dirhtml builder.
|
||||
|
||||
:copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
"""Test dirhtml builder."""
|
||||
|
||||
import posixpath
|
||||
|
||||
|
||||
@@ -1,12 +1,4 @@
|
||||
"""
|
||||
test_build_html
|
||||
~~~~~~~~~~~~~~~
|
||||
|
||||
Test the HTML builder and check output against XPath.
|
||||
|
||||
:copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
"""Test the HTML builder and check output against XPath."""
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
@@ -1,12 +1,4 @@
|
||||
"""
|
||||
test_build_gettext
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Test the build process with gettext builder with the test root.
|
||||
|
||||
:copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
"""Test the build process with gettext builder with the test root."""
|
||||
|
||||
import gettext
|
||||
import os
|
||||
|
||||
@@ -1,12 +1,4 @@
|
||||
"""
|
||||
test_build_html
|
||||
~~~~~~~~~~~~~~~
|
||||
|
||||
Test the HTML builder and check output against XPath.
|
||||
|
||||
:copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
"""Test the HTML builder and check output against XPath."""
|
||||
|
||||
import os
|
||||
import re
|
||||
@@ -99,7 +91,7 @@ def check_xpath(etree, fname, path, check, be_found=True):
|
||||
else:
|
||||
assert nodes != [], ('did not find any node matching xpath '
|
||||
'%r in file %s' % (path, fname))
|
||||
if hasattr(check, '__call__'):
|
||||
if callable(check):
|
||||
check(nodes)
|
||||
elif not check:
|
||||
# only check for node presence
|
||||
@@ -220,9 +212,9 @@ def test_html4_output(app, status, warning):
|
||||
(".//li/p/code/span[@class='pre']", '^a/$'),
|
||||
(".//li/p/code/em/span[@class='pre']", '^varpart$'),
|
||||
(".//li/p/code/em/span[@class='pre']", '^i$'),
|
||||
(".//a[@href='https://www.python.org/dev/peps/pep-0008']"
|
||||
(".//a[@href='https://peps.python.org/pep-0008/']"
|
||||
"[@class='pep reference external']/strong", 'PEP 8'),
|
||||
(".//a[@href='https://www.python.org/dev/peps/pep-0008']"
|
||||
(".//a[@href='https://peps.python.org/pep-0008/']"
|
||||
"[@class='pep reference external']/strong",
|
||||
'Python Enhancement Proposal #8'),
|
||||
(".//a[@href='https://datatracker.ietf.org/doc/html/rfc1.html']"
|
||||
@@ -361,8 +353,6 @@ def test_html4_output(app, status, warning):
|
||||
'index.html': [
|
||||
(".//meta[@name='hc'][@content='hcval']", ''),
|
||||
(".//meta[@name='hc_co'][@content='hcval_co']", ''),
|
||||
(".//dt[@class='label']/span[@class='brackets']", r'Ref1'),
|
||||
(".//dt[@class='label']", ''),
|
||||
(".//li[@class='toctree-l1']/a", 'Testing various markup'),
|
||||
(".//li[@class='toctree-l2']/a", 'Inline markup'),
|
||||
(".//title", 'Sphinx <Tests>'),
|
||||
@@ -400,6 +390,26 @@ def test_html4_output(app, status, warning):
|
||||
(".//a", "entry"),
|
||||
(".//li/a", "double"),
|
||||
],
|
||||
'otherext.html': [
|
||||
(".//h1", "Generated section"),
|
||||
(".//a[@href='_sources/otherext.foo.txt']", ''),
|
||||
]
|
||||
}))
|
||||
@pytest.mark.sphinx('html', tags=['testtag'],
|
||||
confoverrides={'html_context.hckey_co': 'hcval_co'})
|
||||
@pytest.mark.test_params(shared_result='test_build_html_output')
|
||||
def test_html5_output(app, cached_etree_parse, fname, expect):
|
||||
app.build()
|
||||
print(app.outdir / fname)
|
||||
check_xpath(cached_etree_parse(app.outdir / fname), fname, *expect)
|
||||
|
||||
|
||||
@pytest.mark.skipif(docutils.__version_info__ >= (0, 18), reason='docutils-0.17 or below is required.')
|
||||
@pytest.mark.parametrize("fname,expect", flat_dict({
|
||||
'index.html': [
|
||||
(".//dt[@class='label']/span[@class='brackets']", r'Ref1'),
|
||||
(".//dt[@class='label']", ''),
|
||||
],
|
||||
'footnote.html': [
|
||||
(".//a[@class='footnote-reference brackets'][@href='#id9'][@id='id1']", r"1"),
|
||||
(".//a[@class='footnote-reference brackets'][@href='#id10'][@id='id2']", r"2"),
|
||||
@@ -417,15 +427,42 @@ def test_html4_output(app, status, warning):
|
||||
(".//a[@class='fn-backref'][@href='#id7']", r"5"),
|
||||
(".//a[@class='fn-backref'][@href='#id8']", r"6"),
|
||||
],
|
||||
'otherext.html': [
|
||||
(".//h1", "Generated section"),
|
||||
(".//a[@href='_sources/otherext.foo.txt']", ''),
|
||||
]
|
||||
}))
|
||||
@pytest.mark.sphinx('html', tags=['testtag'],
|
||||
confoverrides={'html_context.hckey_co': 'hcval_co'})
|
||||
@pytest.mark.test_params(shared_result='test_build_html_output')
|
||||
def test_html5_output(app, cached_etree_parse, fname, expect):
|
||||
@pytest.mark.sphinx('html')
|
||||
@pytest.mark.test_params(shared_result='test_build_html_output_docutils17')
|
||||
def test_docutils17_output(app, cached_etree_parse, fname, expect):
|
||||
app.build()
|
||||
print(app.outdir / fname)
|
||||
check_xpath(cached_etree_parse(app.outdir / fname), fname, *expect)
|
||||
|
||||
|
||||
@pytest.mark.skipif(docutils.__version_info__ < (0, 18), reason='docutils-0.18+ is required.')
|
||||
@pytest.mark.parametrize("fname,expect", flat_dict({
|
||||
'index.html': [
|
||||
(".//div[@class='citation']/span", r'Ref1'),
|
||||
(".//div[@class='citation']/span", r'Ref_1'),
|
||||
],
|
||||
'footnote.html': [
|
||||
(".//a[@class='footnote-reference brackets'][@href='#id9'][@id='id1']", r"1"),
|
||||
(".//a[@class='footnote-reference brackets'][@href='#id10'][@id='id2']", r"2"),
|
||||
(".//a[@class='footnote-reference brackets'][@href='#foo'][@id='id3']", r"3"),
|
||||
(".//a[@class='reference internal'][@href='#bar'][@id='id4']/span", r"\[bar\]"),
|
||||
(".//a[@class='reference internal'][@href='#baz-qux'][@id='id5']/span", r"\[baz_qux\]"),
|
||||
(".//a[@class='footnote-reference brackets'][@href='#id11'][@id='id6']", r"4"),
|
||||
(".//a[@class='footnote-reference brackets'][@href='#id12'][@id='id7']", r"5"),
|
||||
(".//aside[@class='footnote brackets']/span/a[@href='#id1']", r"1"),
|
||||
(".//aside[@class='footnote brackets']/span/a[@href='#id2']", r"2"),
|
||||
(".//aside[@class='footnote brackets']/span/a[@href='#id3']", r"3"),
|
||||
(".//div[@class='citation']/span/a[@href='#id4']", r"bar"),
|
||||
(".//div[@class='citation']/span/a[@href='#id5']", r"baz_qux"),
|
||||
(".//aside[@class='footnote brackets']/span/a[@href='#id6']", r"4"),
|
||||
(".//aside[@class='footnote brackets']/span/a[@href='#id7']", r"5"),
|
||||
(".//aside[@class='footnote brackets']/span/a[@href='#id8']", r"6"),
|
||||
],
|
||||
}))
|
||||
@pytest.mark.sphinx('html')
|
||||
@pytest.mark.test_params(shared_result='test_build_html_output_docutils18')
|
||||
def test_docutils18_output(app, cached_etree_parse, fname, expect):
|
||||
app.build()
|
||||
print(app.outdir / fname)
|
||||
check_xpath(cached_etree_parse(app.outdir / fname), fname, *expect)
|
||||
@@ -1195,6 +1232,20 @@ def test_assets_order(app):
|
||||
assert re.search(pattern, content, re.S)
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='html_assets')
|
||||
def test_javscript_loading_method(app):
|
||||
app.add_js_file('normal.js')
|
||||
app.add_js_file('early.js', loading_method='async')
|
||||
app.add_js_file('late.js', loading_method='defer')
|
||||
|
||||
app.builder.build_all()
|
||||
content = (app.outdir / 'index.html').read_text()
|
||||
|
||||
assert '<script src="_static/normal.js"></script>' in content
|
||||
assert '<script async="async" src="_static/early.js"></script>' in content
|
||||
assert '<script defer="defer" src="_static/late.js"></script>' in content
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='basic', confoverrides={'html_copy_source': False})
|
||||
def test_html_copy_source(app):
|
||||
app.builder.build_all()
|
||||
@@ -1650,7 +1701,7 @@ def test_html_permalink_icon(app):
|
||||
|
||||
assert ('<h1>The basic Sphinx documentation for testing<a class="headerlink" '
|
||||
'href="#the-basic-sphinx-documentation-for-testing" '
|
||||
'title="Permalink to this headline"><span>[PERMALINK]</span></a></h1>' in content)
|
||||
'title="Permalink to this heading"><span>[PERMALINK]</span></a></h1>' in content)
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='html_signaturereturn_icon')
|
||||
|
||||
@@ -1,12 +1,4 @@
|
||||
"""
|
||||
test_build_latex
|
||||
~~~~~~~~~~~~~~~~
|
||||
|
||||
Test the build process with LaTeX builder with the test root.
|
||||
|
||||
:copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
"""Test the build process with LaTeX builder with the test root."""
|
||||
|
||||
import os
|
||||
import re
|
||||
@@ -528,7 +520,7 @@ def test_babel_with_no_language_settings(app, status, warning):
|
||||
assert '\\usepackage[Bjarne]{fncychap}' in result
|
||||
assert ('\\addto\\captionsenglish{\\renewcommand{\\contentsname}{Table of content}}\n'
|
||||
in result)
|
||||
assert '\\shorthandoff' not in result
|
||||
assert '\\shorthandoff{"}' in result
|
||||
|
||||
# sphinxmessages.sty
|
||||
result = (app.outdir / 'sphinxmessages.sty').read_text()
|
||||
@@ -723,9 +715,8 @@ def test_footnote(app, status, warning):
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
assert ('\\sphinxstepexplicit %\n\\begin{footnote}[1]\\phantomsection'
|
||||
'\\label{\\thesphinxscope.1}%\n\\sphinxAtStartFootnote\nnumbered\n%\n'
|
||||
'\\end{footnote}') in result
|
||||
assert ('\\sphinxAtStartPar\n%\n\\begin{footnote}[1]\\sphinxAtStartFootnote\n'
|
||||
'numbered\n%\n\\end{footnote}') in result
|
||||
assert ('\\begin{footnote}[2]\\sphinxAtStartFootnote\nauto numbered\n%\n'
|
||||
'\\end{footnote}') in result
|
||||
assert '\\begin{footnote}[3]\\sphinxAtStartFootnote\nnamed\n%\n\\end{footnote}' in result
|
||||
@@ -762,40 +753,60 @@ def test_reference_in_caption_and_codeblock_in_footnote(app, status, warning):
|
||||
assert ('\\sphinxcaption{The table title with a reference'
|
||||
' to {[}AuthorYear{]}}' in result)
|
||||
assert '\\subsubsection*{The rubric title with a reference to {[}AuthorYear{]}}' in result
|
||||
assert ('\\chapter{The section with a reference to \\sphinxfootnotemark[5]}\n'
|
||||
assert ('\\chapter{The section with a reference to \\sphinxfootnotemark[6]}\n'
|
||||
'\\label{\\detokenize{index:the-section-with-a-reference-to}}'
|
||||
'%\n\\begin{footnotetext}[5]'
|
||||
'\\phantomsection\\label{\\thesphinxscope.5}%\n'
|
||||
'%\n\\begin{footnotetext}[6]'
|
||||
'\\phantomsection\\label{\\thesphinxscope.6}%\n'
|
||||
'\\sphinxAtStartFootnote\n'
|
||||
'Footnote in section\n%\n\\end{footnotetext}') in result
|
||||
assert ('\\caption{This is the figure caption with a footnote to '
|
||||
'\\sphinxfootnotemark[7].}\\label{\\detokenize{index:id29}}\\end{figure}\n'
|
||||
'%\n\\begin{footnotetext}[7]'
|
||||
'\\phantomsection\\label{\\thesphinxscope.7}%\n'
|
||||
'\\sphinxfootnotemark[8].}\\label{\\detokenize{index:id35}}\\end{figure}\n'
|
||||
'%\n\\begin{footnotetext}[8]'
|
||||
'\\phantomsection\\label{\\thesphinxscope.8}%\n'
|
||||
'\\sphinxAtStartFootnote\n'
|
||||
'Footnote in caption\n%\n\\end{footnotetext}') in result
|
||||
assert ('\\sphinxcaption{footnote \\sphinxfootnotemark[8] in '
|
||||
'caption of normal table}\\label{\\detokenize{index:id30}}') in result
|
||||
assert ('\\caption{footnote \\sphinxfootnotemark[9] '
|
||||
'in caption \\sphinxfootnotemark[10] of longtable\\strut}') in result
|
||||
assert ('\\endlastfoot\n%\n\\begin{footnotetext}[9]'
|
||||
'\\phantomsection\\label{\\thesphinxscope.9}%\n'
|
||||
assert ('\\sphinxcaption{footnote \\sphinxfootnotemark[9] in '
|
||||
'caption of normal table}\\label{\\detokenize{index:id36}}') in result
|
||||
assert ('\\caption{footnote \\sphinxfootnotemark[10] '
|
||||
'in caption \\sphinxfootnotemark[11] of longtable\\strut}') in result
|
||||
assert ('\\endlastfoot\n%\n\\begin{footnotetext}[10]'
|
||||
'\\phantomsection\\label{\\thesphinxscope.10}%\n'
|
||||
'\\sphinxAtStartFootnote\n'
|
||||
'Foot note in longtable\n%\n\\end{footnotetext}\\ignorespaces %\n'
|
||||
'\\begin{footnotetext}[10]'
|
||||
'\\phantomsection\\label{\\thesphinxscope.10}%\n'
|
||||
'\\begin{footnotetext}[11]'
|
||||
'\\phantomsection\\label{\\thesphinxscope.11}%\n'
|
||||
'\\sphinxAtStartFootnote\n'
|
||||
'Second footnote in caption of longtable\n') in result
|
||||
assert ('This is a reference to the code\\sphinxhyphen{}block in the footnote:\n'
|
||||
'{\\hyperref[\\detokenize{index:codeblockinfootnote}]'
|
||||
'{\\sphinxcrossref{\\DUrole{std,std-ref}{I am in a footnote}}}}') in result
|
||||
assert ('&\n\\sphinxAtStartPar\nThis is one more footnote with some code in it %\n'
|
||||
'\\begin{footnote}[11]\\sphinxAtStartFootnote\n'
|
||||
'\\begin{footnote}[12]\\sphinxAtStartFootnote\n'
|
||||
'Third footnote in longtable\n') in result
|
||||
assert ('\\end{sphinxVerbatim}\n%\n\\end{footnote}.\n') in result
|
||||
assert '\\begin{sphinxVerbatim}[commandchars=\\\\\\{\\}]' in result
|
||||
|
||||
|
||||
@pytest.mark.sphinx('latex', testroot='footnotes')
|
||||
def test_footnote_referred_multiple_times(app, status, warning):
|
||||
app.builder.build_all()
|
||||
result = (app.outdir / 'python.tex').read_text()
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
|
||||
assert ('Explicitly numbered footnote: \\sphinxstepexplicit %\n'
|
||||
'\\begin{footnote}[100]\\phantomsection\\label{\\thesphinxscope.100}%\n'
|
||||
'\\sphinxAtStartFootnote\nNumbered footnote\n%\n'
|
||||
'\\end{footnote} \\sphinxfootnotemark[100]\n'
|
||||
in result)
|
||||
assert ('Named footnote: \\sphinxstepexplicit %\n'
|
||||
'\\begin{footnote}[13]\\phantomsection\\label{\\thesphinxscope.13}%\n'
|
||||
'\\sphinxAtStartFootnote\nNamed footnote\n%\n'
|
||||
'\\end{footnote} \\sphinxfootnotemark[13]\n'
|
||||
in result)
|
||||
|
||||
|
||||
@pytest.mark.sphinx(
|
||||
'latex', testroot='footnotes',
|
||||
confoverrides={'latex_show_urls': 'inline'})
|
||||
@@ -805,26 +816,24 @@ def test_latex_show_urls_is_inline(app, status, warning):
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
assert ('Same footnote number \\sphinxstepexplicit %\n'
|
||||
'\\begin{footnote}[1]\\phantomsection\\label{\\thesphinxscope.1}%\n'
|
||||
'\\sphinxAtStartFootnote\n'
|
||||
assert ('Same footnote number %\n'
|
||||
'\\begin{footnote}[1]\\sphinxAtStartFootnote\n'
|
||||
'footnote in bar\n%\n\\end{footnote} in bar.rst') in result
|
||||
assert ('Auto footnote number %\n\\begin{footnote}[1]\\sphinxAtStartFootnote\n'
|
||||
'footnote in baz\n%\n\\end{footnote} in baz.rst') in result
|
||||
assert ('\\phantomsection\\label{\\detokenize{index:id32}}'
|
||||
assert ('\\phantomsection\\label{\\detokenize{index:id38}}'
|
||||
'{\\hyperref[\\detokenize{index:the-section'
|
||||
'-with-a-reference-to-authoryear}]'
|
||||
'{\\sphinxcrossref{The section with a reference to '
|
||||
'\\sphinxcite{index:authoryear}}}}') in result
|
||||
assert ('\\phantomsection\\label{\\detokenize{index:id33}}'
|
||||
assert ('\\phantomsection\\label{\\detokenize{index:id39}}'
|
||||
'{\\hyperref[\\detokenize{index:the-section-with-a-reference-to}]'
|
||||
'{\\sphinxcrossref{The section with a reference to }}}' in result)
|
||||
assert ('First footnote: %\n\\begin{footnote}[2]\\sphinxAtStartFootnote\n'
|
||||
'First\n%\n\\end{footnote}') in result
|
||||
assert ('Second footnote: \\sphinxstepexplicit %\n'
|
||||
'\\begin{footnote}[1]\\phantomsection\\label{\\thesphinxscope.1}%\n'
|
||||
'\\sphinxAtStartFootnote\n'
|
||||
'Second\n%\n\\end{footnote}') in result
|
||||
assert ('Second footnote: %\n'
|
||||
'\\begin{footnote}[1]\\sphinxAtStartFootnote\n'
|
||||
'Second\n%\n\\end{footnote}\n') in result
|
||||
assert '\\sphinxhref{http://sphinx-doc.org/}{Sphinx} (http://sphinx\\sphinxhyphen{}doc.org/)' in result
|
||||
assert ('Third footnote: %\n\\begin{footnote}[3]\\sphinxAtStartFootnote\n'
|
||||
'Third \\sphinxfootnotemark[4]\n%\n\\end{footnote}%\n'
|
||||
@@ -832,20 +841,21 @@ def test_latex_show_urls_is_inline(app, status, warning):
|
||||
'\\phantomsection\\label{\\thesphinxscope.4}%\n'
|
||||
'\\sphinxAtStartFootnote\n'
|
||||
'Footnote inside footnote\n%\n\\end{footnotetext}\\ignorespaces') in result
|
||||
assert ('Fourth footnote: %\n\\begin{footnote}[5]\\sphinxAtStartFootnote\n'
|
||||
'Fourth\n%\n\\end{footnote}\n') in result
|
||||
assert ('\\sphinxhref{http://sphinx-doc.org/~test/}{URL including tilde} '
|
||||
'(http://sphinx\\sphinxhyphen{}doc.org/\\textasciitilde{}test/)') in result
|
||||
assert ('\\item[{\\sphinxhref{http://sphinx-doc.org/}{URL in term} '
|
||||
'(http://sphinx\\sphinxhyphen{}doc.org/)}] '
|
||||
'\\leavevmode\n\\sphinxAtStartPar\nDescription' in result)
|
||||
assert ('\\item[{Footnote in term \\sphinxfootnotemark[6]}] '
|
||||
'\\leavevmode%\n\\begin{footnotetext}[6]'
|
||||
'\\phantomsection\\label{\\thesphinxscope.6}%\n'
|
||||
assert ('\\sphinxlineitem{\\sphinxhref{http://sphinx-doc.org/}{URL in term} '
|
||||
'(http://sphinx\\sphinxhyphen{}doc.org/)}\n'
|
||||
'\\sphinxAtStartPar\nDescription' in result)
|
||||
assert ('\\sphinxlineitem{Footnote in term \\sphinxfootnotemark[7]}%\n'
|
||||
'\\begin{footnotetext}[7]\\phantomsection\\label{\\thesphinxscope.7}%\n'
|
||||
'\\sphinxAtStartFootnote\n'
|
||||
'Footnote in term\n%\n\\end{footnotetext}\\ignorespaces '
|
||||
'\n\\sphinxAtStartPar\nDescription') in result
|
||||
assert ('\\item[{\\sphinxhref{http://sphinx-doc.org/}{Term in deflist} '
|
||||
'(http://sphinx\\sphinxhyphen{}doc.org/)}] '
|
||||
'\\leavevmode\n\\sphinxAtStartPar\nDescription') in result
|
||||
assert ('\\sphinxlineitem{\\sphinxhref{http://sphinx-doc.org/}{Term in deflist} '
|
||||
'(http://sphinx\\sphinxhyphen{}doc.org/)}'
|
||||
'\n\\sphinxAtStartPar\nDescription') in result
|
||||
assert '\\sphinxurl{https://github.com/sphinx-doc/sphinx}\n' in result
|
||||
assert ('\\sphinxhref{mailto:sphinx-dev@googlegroups.com}'
|
||||
'{sphinx\\sphinxhyphen{}dev@googlegroups.com}') in result
|
||||
@@ -861,24 +871,22 @@ def test_latex_show_urls_is_footnote(app, status, warning):
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
assert ('Same footnote number \\sphinxstepexplicit %\n'
|
||||
'\\begin{footnote}[1]\\phantomsection\\label{\\thesphinxscope.1}%\n'
|
||||
'\\sphinxAtStartFootnote\n'
|
||||
assert ('Same footnote number %\n'
|
||||
'\\begin{footnote}[1]\\sphinxAtStartFootnote\n'
|
||||
'footnote in bar\n%\n\\end{footnote} in bar.rst') in result
|
||||
assert ('Auto footnote number %\n\\begin{footnote}[2]\\sphinxAtStartFootnote\n'
|
||||
'footnote in baz\n%\n\\end{footnote} in baz.rst') in result
|
||||
assert ('\\phantomsection\\label{\\detokenize{index:id32}}'
|
||||
assert ('\\phantomsection\\label{\\detokenize{index:id38}}'
|
||||
'{\\hyperref[\\detokenize{index:the-section-with-a-reference-to-authoryear}]'
|
||||
'{\\sphinxcrossref{The section with a reference '
|
||||
'to \\sphinxcite{index:authoryear}}}}') in result
|
||||
assert ('\\phantomsection\\label{\\detokenize{index:id33}}'
|
||||
assert ('\\phantomsection\\label{\\detokenize{index:id39}}'
|
||||
'{\\hyperref[\\detokenize{index:the-section-with-a-reference-to}]'
|
||||
'{\\sphinxcrossref{The section with a reference to }}}') in result
|
||||
assert ('First footnote: %\n\\begin{footnote}[3]\\sphinxAtStartFootnote\n'
|
||||
'First\n%\n\\end{footnote}') in result
|
||||
assert ('Second footnote: \\sphinxstepexplicit %\n'
|
||||
'\\begin{footnote}[1]\\phantomsection\\label{\\thesphinxscope.1}%\n'
|
||||
'\\sphinxAtStartFootnote\n'
|
||||
assert ('Second footnote: %\n'
|
||||
'\\begin{footnote}[1]\\sphinxAtStartFootnote\n'
|
||||
'Second\n%\n\\end{footnote}') in result
|
||||
assert ('\\sphinxhref{http://sphinx-doc.org/}{Sphinx}'
|
||||
'%\n\\begin{footnote}[4]\\sphinxAtStartFootnote\n'
|
||||
@@ -890,26 +898,25 @@ def test_latex_show_urls_is_footnote(app, status, warning):
|
||||
'\\sphinxAtStartFootnote\n'
|
||||
'Footnote inside footnote\n%\n'
|
||||
'\\end{footnotetext}\\ignorespaces') in result
|
||||
assert ('Fourth footnote: %\n\\begin{footnote}[8]\\sphinxAtStartFootnote\n'
|
||||
'Fourth\n%\n\\end{footnote}\n') in result
|
||||
assert ('\\sphinxhref{http://sphinx-doc.org/~test/}{URL including tilde}'
|
||||
'%\n\\begin{footnote}[5]\\sphinxAtStartFootnote\n'
|
||||
'\\sphinxnolinkurl{http://sphinx-doc.org/~test/}\n%\n\\end{footnote}') in result
|
||||
assert ('\\item[{\\sphinxhref{http://sphinx-doc.org/}'
|
||||
'{URL in term}\\sphinxfootnotemark[9]}] '
|
||||
'\\leavevmode%\n\\begin{footnotetext}[9]'
|
||||
'\\phantomsection\\label{\\thesphinxscope.9}%\n'
|
||||
assert ('\\sphinxlineitem{\\sphinxhref{http://sphinx-doc.org/}'
|
||||
'{URL in term}\\sphinxfootnotemark[10]}%\n'
|
||||
'\\begin{footnotetext}[10]\\phantomsection\\label{\\thesphinxscope.10}%\n'
|
||||
'\\sphinxAtStartFootnote\n'
|
||||
'\\sphinxnolinkurl{http://sphinx-doc.org/}\n%\n'
|
||||
'\\end{footnotetext}\\ignorespaces \n\\sphinxAtStartPar\nDescription') in result
|
||||
assert ('\\item[{Footnote in term \\sphinxfootnotemark[11]}] '
|
||||
'\\leavevmode%\n\\begin{footnotetext}[11]'
|
||||
'\\phantomsection\\label{\\thesphinxscope.11}%\n'
|
||||
assert ('\\sphinxlineitem{Footnote in term \\sphinxfootnotemark[12]}%\n'
|
||||
'\\begin{footnotetext}[12]\\phantomsection\\label{\\thesphinxscope.12}%\n'
|
||||
'\\sphinxAtStartFootnote\n'
|
||||
'Footnote in term\n%\n\\end{footnotetext}\\ignorespaces '
|
||||
'\n\\sphinxAtStartPar\nDescription') in result
|
||||
assert ('\\item[{\\sphinxhref{http://sphinx-doc.org/}{Term in deflist}'
|
||||
'\\sphinxfootnotemark[10]}] '
|
||||
'\\leavevmode%\n\\begin{footnotetext}[10]'
|
||||
'\\phantomsection\\label{\\thesphinxscope.10}%\n'
|
||||
assert ('\\sphinxlineitem{\\sphinxhref{http://sphinx-doc.org/}{Term in deflist}'
|
||||
'\\sphinxfootnotemark[11]}%\n'
|
||||
'\\begin{footnotetext}[11]\\phantomsection\\label{\\thesphinxscope.11}%\n'
|
||||
'\\sphinxAtStartFootnote\n'
|
||||
'\\sphinxnolinkurl{http://sphinx-doc.org/}\n%\n'
|
||||
'\\end{footnotetext}\\ignorespaces \n\\sphinxAtStartPar\nDescription') in result
|
||||
@@ -928,24 +935,22 @@ def test_latex_show_urls_is_no(app, status, warning):
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
assert ('Same footnote number \\sphinxstepexplicit %\n'
|
||||
'\\begin{footnote}[1]\\phantomsection\\label{\\thesphinxscope.1}%\n'
|
||||
'\\sphinxAtStartFootnote\n'
|
||||
assert ('Same footnote number %\n'
|
||||
'\\begin{footnote}[1]\\sphinxAtStartFootnote\n'
|
||||
'footnote in bar\n%\n\\end{footnote} in bar.rst') in result
|
||||
assert ('Auto footnote number %\n\\begin{footnote}[1]\\sphinxAtStartFootnote\n'
|
||||
'footnote in baz\n%\n\\end{footnote} in baz.rst') in result
|
||||
assert ('\\phantomsection\\label{\\detokenize{index:id32}}'
|
||||
assert ('\\phantomsection\\label{\\detokenize{index:id38}}'
|
||||
'{\\hyperref[\\detokenize{index:the-section-with-a-reference-to-authoryear}]'
|
||||
'{\\sphinxcrossref{The section with a reference '
|
||||
'to \\sphinxcite{index:authoryear}}}}') in result
|
||||
assert ('\\phantomsection\\label{\\detokenize{index:id33}}'
|
||||
assert ('\\phantomsection\\label{\\detokenize{index:id39}}'
|
||||
'{\\hyperref[\\detokenize{index:the-section-with-a-reference-to}]'
|
||||
'{\\sphinxcrossref{The section with a reference to }}}' in result)
|
||||
assert ('First footnote: %\n\\begin{footnote}[2]\\sphinxAtStartFootnote\n'
|
||||
'First\n%\n\\end{footnote}') in result
|
||||
assert ('Second footnote: \\sphinxstepexplicit %\n'
|
||||
'\\begin{footnote}[1]\\phantomsection\\label{\\thesphinxscope.1}%\n'
|
||||
'\\sphinxAtStartFootnote\n'
|
||||
assert ('Second footnote: %\n'
|
||||
'\\begin{footnote}[1]\\sphinxAtStartFootnote\n'
|
||||
'Second\n%\n\\end{footnote}') in result
|
||||
assert '\\sphinxhref{http://sphinx-doc.org/}{Sphinx}' in result
|
||||
assert ('Third footnote: %\n\\begin{footnote}[3]\\sphinxAtStartFootnote\n'
|
||||
@@ -954,17 +959,18 @@ def test_latex_show_urls_is_no(app, status, warning):
|
||||
'\\phantomsection\\label{\\thesphinxscope.4}%\n'
|
||||
'\\sphinxAtStartFootnote\n'
|
||||
'Footnote inside footnote\n%\n\\end{footnotetext}\\ignorespaces') in result
|
||||
assert ('Fourth footnote: %\n\\begin{footnote}[5]\\sphinxAtStartFootnote\n'
|
||||
'Fourth\n%\n\\end{footnote}\n') in result
|
||||
assert '\\sphinxhref{http://sphinx-doc.org/~test/}{URL including tilde}' in result
|
||||
assert ('\\item[{\\sphinxhref{http://sphinx-doc.org/}{URL in term}}] '
|
||||
'\\leavevmode\n\\sphinxAtStartPar\nDescription') in result
|
||||
assert ('\\item[{Footnote in term \\sphinxfootnotemark[6]}] '
|
||||
'\\leavevmode%\n\\begin{footnotetext}[6]'
|
||||
'\\phantomsection\\label{\\thesphinxscope.6}%\n'
|
||||
assert ('\\sphinxlineitem{\\sphinxhref{http://sphinx-doc.org/}{URL in term}}\n'
|
||||
'\\sphinxAtStartPar\nDescription') in result
|
||||
assert ('\\sphinxlineitem{Footnote in term \\sphinxfootnotemark[7]}%\n'
|
||||
'\\begin{footnotetext}[7]\\phantomsection\\label{\\thesphinxscope.7}%\n'
|
||||
'\\sphinxAtStartFootnote\n'
|
||||
'Footnote in term\n%\n\\end{footnotetext}\\ignorespaces '
|
||||
'\n\\sphinxAtStartPar\nDescription') in result
|
||||
assert ('\\item[{\\sphinxhref{http://sphinx-doc.org/}{Term in deflist}}] '
|
||||
'\\leavevmode\n\\sphinxAtStartPar\nDescription') in result
|
||||
assert ('\\sphinxlineitem{\\sphinxhref{http://sphinx-doc.org/}{Term in deflist}}'
|
||||
'\n\\sphinxAtStartPar\nDescription') in result
|
||||
assert ('\\sphinxurl{https://github.com/sphinx-doc/sphinx}\n' in result)
|
||||
assert ('\\sphinxhref{mailto:sphinx-dev@googlegroups.com}'
|
||||
'{sphinx\\sphinxhyphen{}dev@googlegroups.com}\n') in result
|
||||
@@ -1178,6 +1184,7 @@ def test_latex_table_tabulars(app, status, warning):
|
||||
tables = {}
|
||||
for chap in re.split(r'\\(?:section|chapter){', result)[1:]:
|
||||
sectname, content = chap.split('}', 1)
|
||||
content = re.sub(r'\\sphinxstepscope', '', content) # filter a separator
|
||||
tables[sectname] = content.strip()
|
||||
|
||||
def get_expected(name):
|
||||
@@ -1247,6 +1254,7 @@ def test_latex_table_longtable(app, status, warning):
|
||||
tables = {}
|
||||
for chap in re.split(r'\\(?:section|chapter){', result)[1:]:
|
||||
sectname, content = chap.split('}', 1)
|
||||
content = re.sub(r'\\sphinxstepscope', '', content) # filter a separator
|
||||
tables[sectname] = content.strip()
|
||||
|
||||
def get_expected(name):
|
||||
@@ -1454,23 +1462,23 @@ def test_latex_glossary(app, status, warning):
|
||||
app.builder.build_all()
|
||||
|
||||
result = (app.outdir / 'python.tex').read_text()
|
||||
assert ('\\item[{änhlich\\index{änhlich@\\spxentry{änhlich}|spxpagem}'
|
||||
assert (r'\sphinxlineitem{ähnlich\index{ähnlich@\spxentry{ähnlich}|spxpagem}'
|
||||
r'\phantomsection'
|
||||
r'\label{\detokenize{index:term-anhlich}}}] \leavevmode' in result)
|
||||
assert (r'\item[{boson\index{boson@\spxentry{boson}|spxpagem}\phantomsection'
|
||||
r'\label{\detokenize{index:term-boson}}}] \leavevmode' in result)
|
||||
assert (r'\item[{\sphinxstyleemphasis{fermion}'
|
||||
r'\label{\detokenize{index:term-ahnlich}}}' in result)
|
||||
assert (r'\sphinxlineitem{boson\index{boson@\spxentry{boson}|spxpagem}\phantomsection'
|
||||
r'\label{\detokenize{index:term-boson}}}' in result)
|
||||
assert (r'\sphinxlineitem{\sphinxstyleemphasis{fermion}'
|
||||
r'\index{fermion@\spxentry{fermion}|spxpagem}'
|
||||
r'\phantomsection'
|
||||
r'\label{\detokenize{index:term-fermion}}}] \leavevmode' in result)
|
||||
assert (r'\item[{tauon\index{tauon@\spxentry{tauon}|spxpagem}\phantomsection'
|
||||
r'\label{\detokenize{index:term-tauon}}}] \leavevmode'
|
||||
r'\item[{myon\index{myon@\spxentry{myon}|spxpagem}\phantomsection'
|
||||
r'\label{\detokenize{index:term-myon}}}] \leavevmode'
|
||||
r'\item[{electron\index{electron@\spxentry{electron}|spxpagem}\phantomsection'
|
||||
r'\label{\detokenize{index:term-electron}}}] \leavevmode' in result)
|
||||
assert ('\\item[{über\\index{über@\\spxentry{über}|spxpagem}\\phantomsection'
|
||||
r'\label{\detokenize{index:term-uber}}}] \leavevmode' in result)
|
||||
r'\label{\detokenize{index:term-fermion}}}' in result)
|
||||
assert (r'\sphinxlineitem{tauon\index{tauon@\spxentry{tauon}|spxpagem}\phantomsection'
|
||||
r'\label{\detokenize{index:term-tauon}}}'
|
||||
r'\sphinxlineitem{myon\index{myon@\spxentry{myon}|spxpagem}\phantomsection'
|
||||
r'\label{\detokenize{index:term-myon}}}'
|
||||
r'\sphinxlineitem{electron\index{electron@\spxentry{electron}|spxpagem}\phantomsection'
|
||||
r'\label{\detokenize{index:term-electron}}}' in result)
|
||||
assert (r'\sphinxlineitem{über\index{über@\spxentry{über}|spxpagem}\phantomsection'
|
||||
r'\label{\detokenize{index:term-uber}}}' in result)
|
||||
|
||||
|
||||
@pytest.mark.sphinx('latex', testroot='latex-labels')
|
||||
|
||||
@@ -1,12 +1,4 @@
|
||||
"""
|
||||
test_build_linkcheck
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Test the build process with manpage builder with the test root.
|
||||
|
||||
:copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
"""Test the build process with manpage builder with the test root."""
|
||||
|
||||
import http.server
|
||||
import json
|
||||
@@ -625,3 +617,30 @@ def test_get_after_head_raises_connection_error(app):
|
||||
"uri": "http://localhost:7777/",
|
||||
"info": "",
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.sphinx('linkcheck', testroot='linkcheck-documents_exclude', freshenv=True)
|
||||
def test_linkcheck_exclude_documents(app):
|
||||
app.build()
|
||||
|
||||
with open(app.outdir / 'output.json') as fp:
|
||||
content = [json.loads(record) for record in fp]
|
||||
|
||||
assert content == [
|
||||
{
|
||||
'filename': 'broken_link.rst',
|
||||
'lineno': 4,
|
||||
'status': 'ignored',
|
||||
'code': 0,
|
||||
'uri': 'https://www.sphinx-doc.org/this-is-a-broken-link',
|
||||
'info': 'broken_link matched ^broken_link$ from linkcheck_exclude_documents',
|
||||
},
|
||||
{
|
||||
'filename': 'br0ken_link.rst',
|
||||
'lineno': 4,
|
||||
'status': 'ignored',
|
||||
'code': 0,
|
||||
'uri': 'https://www.sphinx-doc.org/this-is-another-broken-link',
|
||||
'info': 'br0ken_link matched br[0-9]ken_link from linkcheck_exclude_documents',
|
||||
},
|
||||
]
|
||||
|
||||
@@ -1,12 +1,4 @@
|
||||
"""
|
||||
test_build_manpage
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Test the build process with manpage builder with the test root.
|
||||
|
||||
:copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
"""Test the build process with manpage builder with the test root."""
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@@ -1,12 +1,4 @@
|
||||
"""
|
||||
test_build_texinfo
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Test the build process with Texinfo builder with the test root.
|
||||
|
||||
:copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
"""Test the build process with Texinfo builder with the test root."""
|
||||
|
||||
import os
|
||||
import re
|
||||
@@ -112,3 +104,36 @@ def test_texinfo_escape_id(app, status, warning):
|
||||
assert translator.escape_id('Hello(world)') == 'Hello world'
|
||||
assert translator.escape_id('Hello world.') == 'Hello world'
|
||||
assert translator.escape_id('.') == '.'
|
||||
|
||||
|
||||
@pytest.mark.sphinx('texinfo', testroot='footnotes')
|
||||
def test_texinfo_footnote(app, status, warning):
|
||||
app.builder.build_all()
|
||||
|
||||
output = (app.outdir / 'python.texi').read_text()
|
||||
assert 'First footnote: @footnote{\nFirst\n}' in output
|
||||
|
||||
|
||||
@pytest.mark.sphinx('texinfo')
|
||||
def test_texinfo_xrefs(app, status, warning):
|
||||
app.builder.build_all()
|
||||
output = (app.outdir / 'sphinxtests.texi').read_text()
|
||||
assert re.search(r'@ref{\w+,,--plugin\.option}', output)
|
||||
|
||||
# Now rebuild it without xrefs
|
||||
app.config.texinfo_cross_references = False
|
||||
app.builder.build_all()
|
||||
output = (app.outdir / 'sphinxtests.texi').read_text()
|
||||
assert not re.search(r'@ref{\w+,,--plugin\.option}', output)
|
||||
assert 'Link to perl +p, --ObjC++, --plugin.option, create-auth-token, arg and -j' in output
|
||||
|
||||
|
||||
@pytest.mark.sphinx('texinfo', testroot='root')
|
||||
def test_texinfo_samp_with_variable(app, status, warning):
|
||||
app.build()
|
||||
|
||||
output = (app.outdir / 'sphinxtests.texi').read_text()
|
||||
|
||||
assert '@code{@var{variable_only}}' in output
|
||||
assert '@code{@var{variable} and text}' in output
|
||||
assert '@code{Show @var{variable} in the middle}' in output
|
||||
|
||||
@@ -1,12 +1,4 @@
|
||||
"""
|
||||
test_build_text
|
||||
~~~~~~~~~~~~~~~
|
||||
|
||||
Test the build process with Text builder with the test root.
|
||||
|
||||
:copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
"""Test the build process with Text builder with the test root."""
|
||||
|
||||
import pytest
|
||||
from docutils.utils import column_width
|
||||
|
||||
@@ -1,12 +1,4 @@
|
||||
"""
|
||||
test_builder
|
||||
~~~~~~~~
|
||||
|
||||
Test the Builder class.
|
||||
|
||||
:copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
"""Test the Builder class."""
|
||||
import pytest
|
||||
|
||||
|
||||
|
||||
@@ -1,12 +1,4 @@
|
||||
"""
|
||||
test_build_base
|
||||
~~~~~~~~~~~~~~~
|
||||
|
||||
Test the base build process.
|
||||
|
||||
:copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
"""Test the base build process."""
|
||||
import shutil
|
||||
|
||||
import pytest
|
||||
|
||||
@@ -1,13 +1,4 @@
|
||||
"""
|
||||
test_config
|
||||
~~~~~~~~~~~
|
||||
|
||||
Test the sphinx.config.Config class and its handling in the
|
||||
Application class.
|
||||
|
||||
:copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
"""Test the sphinx.config.Config class."""
|
||||
|
||||
from unittest import mock
|
||||
|
||||
|
||||
@@ -1,12 +1,4 @@
|
||||
"""
|
||||
test_correct_year
|
||||
~~~~~~~~~~~~~~~~~
|
||||
|
||||
Test copyright year adjustment
|
||||
|
||||
:copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
"""Test copyright year adjustment"""
|
||||
import pytest
|
||||
|
||||
|
||||
|
||||
@@ -1,12 +1,4 @@
|
||||
"""
|
||||
test_directive_code
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Test the code-block directive.
|
||||
|
||||
:copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
"""Test the code-block directive."""
|
||||
|
||||
import os
|
||||
|
||||
@@ -259,6 +251,19 @@ def test_LiteralIncludeReader_dedent(literal_inc_path):
|
||||
"\n")
|
||||
|
||||
|
||||
@pytest.mark.xfail(os.name != 'posix', reason="Not working on windows")
|
||||
def test_LiteralIncludeReader_dedent_and_append_and_prepend(literal_inc_path):
|
||||
# dedent: 2
|
||||
options = {'lines': '9-11', 'dedent': 2, 'prepend': 'class Foo:', 'append': '# comment'}
|
||||
reader = LiteralIncludeReader(literal_inc_path, options, DUMMY_CONFIG)
|
||||
content, lines = reader.read()
|
||||
assert content == ("class Foo:\n"
|
||||
" def baz():\n"
|
||||
" pass\n"
|
||||
"\n"
|
||||
"# comment\n")
|
||||
|
||||
|
||||
@pytest.mark.xfail(os.name != 'posix', reason="Not working on windows")
|
||||
def test_LiteralIncludeReader_tabwidth(testroot):
|
||||
# tab-width: 4
|
||||
@@ -553,7 +558,7 @@ def test_literalinclude_pydecorators(app, status, warning):
|
||||
def test_code_block_highlighted(app, status, warning):
|
||||
app.builder.build(['highlight'])
|
||||
doctree = app.env.get_doctree('highlight')
|
||||
codeblocks = list(doctree.traverse(nodes.literal_block))
|
||||
codeblocks = list(doctree.findall(nodes.literal_block))
|
||||
|
||||
assert codeblocks[0]['language'] == 'default'
|
||||
assert codeblocks[1]['language'] == 'python2'
|
||||
@@ -580,3 +585,30 @@ def test_linenothreshold(app, status, warning):
|
||||
# literal include not using linenothreshold (no line numbers)
|
||||
assert ('<span></span><span class="c1"># Very small literal include '
|
||||
'(linenothreshold check)</span>' in html)
|
||||
|
||||
|
||||
@pytest.mark.sphinx('dummy', testroot='directive-code')
|
||||
def test_code_block_dedent(app, status, warning):
|
||||
app.builder.build(['dedent'])
|
||||
doctree = app.env.get_doctree('dedent')
|
||||
codeblocks = list(doctree.traverse(nodes.literal_block))
|
||||
# Note: comparison string should not have newlines at the beginning or end
|
||||
text_0_indent = '''First line
|
||||
Second line
|
||||
Third line
|
||||
Fourth line'''
|
||||
text_2_indent = ''' First line
|
||||
Second line
|
||||
Third line
|
||||
Fourth line'''
|
||||
text_4_indent = ''' First line
|
||||
Second line
|
||||
Third line
|
||||
Fourth line'''
|
||||
|
||||
assert codeblocks[0].astext() == text_0_indent
|
||||
assert codeblocks[1].astext() == text_0_indent
|
||||
assert codeblocks[2].astext() == text_4_indent
|
||||
assert codeblocks[3].astext() == text_2_indent
|
||||
assert codeblocks[4].astext() == text_4_indent
|
||||
assert codeblocks[5].astext() == text_0_indent
|
||||
|
||||
@@ -1,12 +1,4 @@
|
||||
"""
|
||||
test_only_directive
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Test the only directive with the test root.
|
||||
|
||||
:copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
"""Test the only directive with the test root."""
|
||||
|
||||
import re
|
||||
|
||||
|
||||
@@ -1,12 +1,4 @@
|
||||
"""
|
||||
test_directive_other
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Test the other directives.
|
||||
|
||||
:copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
"""Test the other directives."""
|
||||
|
||||
import pytest
|
||||
from docutils import nodes
|
||||
|
||||
@@ -1,12 +1,4 @@
|
||||
"""
|
||||
test_directive_patch
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Test the patched directives.
|
||||
|
||||
:copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
"""Test the patched directives."""
|
||||
|
||||
import pytest
|
||||
from docutils import nodes
|
||||
|
||||
@@ -1,12 +1,4 @@
|
||||
"""
|
||||
test_docutilsconf
|
||||
~~~~~~~~~~~~~~~~~
|
||||
|
||||
Test docutils.conf support for several writers.
|
||||
|
||||
:copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
"""Test docutils.conf support for several writers."""
|
||||
|
||||
import pytest
|
||||
from docutils import nodes
|
||||
|
||||
@@ -1,13 +1,6 @@
|
||||
"""
|
||||
test_domain_c
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
Tests the C Domain
|
||||
|
||||
:copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
"""Tests the C Domain"""
|
||||
|
||||
import itertools
|
||||
import zlib
|
||||
from xml.etree import ElementTree
|
||||
|
||||
@@ -329,6 +322,13 @@ def test_domain_c_ast_fundamental_types():
|
||||
input = "{key}%s foo" % t
|
||||
output = ' '.join(input.split())
|
||||
check('type', input, {1: 'foo'}, key='typedef', output=output)
|
||||
if ' ' in t:
|
||||
# try permutations of all components
|
||||
tcs = t.split()
|
||||
for p in itertools.permutations(tcs):
|
||||
input = "{key}%s foo" % ' '.join(p)
|
||||
output = ' '.join(input.split())
|
||||
check("type", input, {1: 'foo'}, key='typedef', output=output)
|
||||
|
||||
|
||||
def test_domain_c_ast_type_definitions():
|
||||
@@ -587,10 +587,7 @@ def test_domain_c_ast_attributes():
|
||||
|
||||
def test_extra_keywords():
|
||||
with pytest.raises(DefinitionError,
|
||||
match='Expected identifier, got user-defined keyword: complex.'):
|
||||
parse('function', 'void f(int complex)')
|
||||
with pytest.raises(DefinitionError,
|
||||
match='Expected identifier, got user-defined keyword: complex.'):
|
||||
match='Expected identifier in nested name'):
|
||||
parse('function', 'void complex(void)')
|
||||
|
||||
|
||||
@@ -711,7 +708,7 @@ def test_domain_c_build_field_role(app, status, warning):
|
||||
|
||||
def _get_obj(app, queryName):
|
||||
domain = app.env.get_domain('c')
|
||||
for name, dispname, objectType, docname, anchor, prio in domain.get_objects():
|
||||
for name, _dispname, objectType, docname, anchor, _prio in domain.get_objects():
|
||||
if name == queryName:
|
||||
return (docname, anchor, objectType)
|
||||
return (queryName, "not", "found")
|
||||
|
||||
@@ -1,13 +1,6 @@
|
||||
"""
|
||||
test_domain_cpp
|
||||
~~~~~~~~~~~~~~~
|
||||
|
||||
Tests the C++ Domain
|
||||
|
||||
:copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
"""Tests the C++ Domain"""
|
||||
|
||||
import itertools
|
||||
import re
|
||||
import zlib
|
||||
|
||||
@@ -137,9 +130,17 @@ def test_domain_cpp_ast_fundamental_types():
|
||||
if t == "std::nullptr_t":
|
||||
id = "NSt9nullptr_tE"
|
||||
return "1f%s" % id
|
||||
id1 = makeIdV1()
|
||||
id2 = makeIdV2()
|
||||
input = "void f(%s arg)" % t.replace(' ', ' ')
|
||||
output = "void f(%s arg)" % t
|
||||
check("function", input, {1: makeIdV1(), 2: makeIdV2()}, output=output)
|
||||
check("function", input, {1: id1, 2: id2}, output=output)
|
||||
if ' ' in t:
|
||||
# try permutations of all components
|
||||
tcs = t.split()
|
||||
for p in itertools.permutations(tcs):
|
||||
input = "void f(%s arg)" % ' '.join(p)
|
||||
check("function", input, {1: id1, 2: id2})
|
||||
|
||||
|
||||
def test_domain_cpp_ast_expressions():
|
||||
@@ -987,6 +988,11 @@ def test_domain_cpp_ast_attributes():
|
||||
# position: parameters and qualifiers
|
||||
check('function', 'void f() [[attr1]] [[attr2]]', {1: 'f', 2: '1fv'})
|
||||
|
||||
# position: class, union, enum
|
||||
check('class', '{key}[[nodiscard]] Foo', {1: 'Foo', 2: '3Foo'}, key='class')
|
||||
check('union', '{key}[[nodiscard]] Foo', {1: None, 2: '3Foo'}, key='union')
|
||||
check('enum', '{key}[[nodiscard]] Foo', {1: None, 2: '3Foo'}, key='enum')
|
||||
|
||||
|
||||
def test_domain_cpp_ast_xref_parsing():
|
||||
def check(target):
|
||||
|
||||
@@ -1,12 +1,4 @@
|
||||
"""
|
||||
test_domain_js
|
||||
~~~~~~~~~~~~~~
|
||||
|
||||
Tests the JavaScript Domain
|
||||
|
||||
:copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
"""Tests the JavaScript Domain"""
|
||||
|
||||
from unittest.mock import Mock
|
||||
|
||||
@@ -42,7 +34,7 @@ def test_domain_js_xrefs(app, status, warning):
|
||||
assert_node(node, **attributes)
|
||||
|
||||
doctree = app.env.get_doctree('roles')
|
||||
refnodes = list(doctree.traverse(addnodes.pending_xref))
|
||||
refnodes = list(doctree.findall(addnodes.pending_xref))
|
||||
assert_refnode(refnodes[0], None, None, 'TopLevel', 'class')
|
||||
assert_refnode(refnodes[1], None, None, 'top_level', 'func')
|
||||
assert_refnode(refnodes[2], None, 'NestedParentA', 'child_1', 'func')
|
||||
@@ -60,7 +52,7 @@ def test_domain_js_xrefs(app, status, warning):
|
||||
assert len(refnodes) == 13
|
||||
|
||||
doctree = app.env.get_doctree('module')
|
||||
refnodes = list(doctree.traverse(addnodes.pending_xref))
|
||||
refnodes = list(doctree.findall(addnodes.pending_xref))
|
||||
assert_refnode(refnodes[0], 'module_a.submodule', None, 'ModTopLevel',
|
||||
'class')
|
||||
assert_refnode(refnodes[1], 'module_a.submodule', 'ModTopLevel',
|
||||
|
||||
@@ -1,12 +1,4 @@
|
||||
"""
|
||||
test_domain_py
|
||||
~~~~~~~~~~~~~~
|
||||
|
||||
Tests the Python Domain
|
||||
|
||||
:copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
"""Tests the Python Domain"""
|
||||
|
||||
import re
|
||||
import sys
|
||||
@@ -79,7 +71,7 @@ def test_domain_py_xrefs(app, status, warning):
|
||||
assert_node(node, **attributes)
|
||||
|
||||
doctree = app.env.get_doctree('roles')
|
||||
refnodes = list(doctree.traverse(pending_xref))
|
||||
refnodes = list(doctree.findall(pending_xref))
|
||||
assert_refnode(refnodes[0], None, None, 'TopLevel', 'class')
|
||||
assert_refnode(refnodes[1], None, None, 'top_level', 'meth')
|
||||
assert_refnode(refnodes[2], None, 'NestedParentA', 'child_1', 'meth')
|
||||
@@ -97,7 +89,7 @@ def test_domain_py_xrefs(app, status, warning):
|
||||
assert len(refnodes) == 13
|
||||
|
||||
doctree = app.env.get_doctree('module')
|
||||
refnodes = list(doctree.traverse(pending_xref))
|
||||
refnodes = list(doctree.findall(pending_xref))
|
||||
assert_refnode(refnodes[0], 'module_a.submodule', None,
|
||||
'ModTopLevel', 'class')
|
||||
assert_refnode(refnodes[1], 'module_a.submodule', 'ModTopLevel',
|
||||
@@ -126,7 +118,7 @@ def test_domain_py_xrefs(app, status, warning):
|
||||
assert len(refnodes) == 16
|
||||
|
||||
doctree = app.env.get_doctree('module_option')
|
||||
refnodes = list(doctree.traverse(pending_xref))
|
||||
refnodes = list(doctree.findall(pending_xref))
|
||||
print(refnodes)
|
||||
print(refnodes[0])
|
||||
print(refnodes[1])
|
||||
@@ -314,7 +306,6 @@ def test_parse_annotation(app):
|
||||
[desc_sig_punctuation, "]"]))
|
||||
|
||||
doctree = _parse_annotation("Callable[[int, int], int]", app.env)
|
||||
print(doctree)
|
||||
assert_node(doctree, ([pending_xref, "Callable"],
|
||||
[desc_sig_punctuation, "["],
|
||||
[desc_sig_punctuation, "["],
|
||||
@@ -349,6 +340,29 @@ def test_parse_annotation(app):
|
||||
assert_node(doctree, ([pending_xref, "None"],))
|
||||
assert_node(doctree[0], pending_xref, refdomain="py", reftype="obj", reftarget="None")
|
||||
|
||||
# Literal type makes an object-reference (not a class reference)
|
||||
doctree = _parse_annotation("typing.Literal['a', 'b']", app.env)
|
||||
assert_node(doctree, ([pending_xref, "Literal"],
|
||||
[desc_sig_punctuation, "["],
|
||||
[desc_sig_literal_string, "'a'"],
|
||||
[desc_sig_punctuation, ","],
|
||||
desc_sig_space,
|
||||
[desc_sig_literal_string, "'b'"],
|
||||
[desc_sig_punctuation, "]"]))
|
||||
assert_node(doctree[0], pending_xref, refdomain="py", reftype="obj", reftarget="typing.Literal")
|
||||
|
||||
|
||||
def test_parse_annotation_suppress(app):
|
||||
doctree = _parse_annotation("~typing.Dict[str, str]", app.env)
|
||||
assert_node(doctree, ([pending_xref, "Dict"],
|
||||
[desc_sig_punctuation, "["],
|
||||
[pending_xref, "str"],
|
||||
[desc_sig_punctuation, ","],
|
||||
desc_sig_space,
|
||||
[pending_xref, "str"],
|
||||
[desc_sig_punctuation, "]"]))
|
||||
assert_node(doctree[0], pending_xref, refdomain="py", reftype="obj", reftarget="typing.Dict")
|
||||
|
||||
|
||||
@pytest.mark.skipif(sys.version_info < (3, 8), reason='python 3.8+ is required.')
|
||||
def test_parse_annotation_Literal(app):
|
||||
@@ -362,7 +376,7 @@ def test_parse_annotation_Literal(app):
|
||||
[desc_sig_punctuation, "]"]))
|
||||
|
||||
doctree = _parse_annotation("typing.Literal[0, 1, 'abc']", app.env)
|
||||
assert_node(doctree, ([pending_xref, "typing.Literal"],
|
||||
assert_node(doctree, ([pending_xref, "Literal"],
|
||||
[desc_sig_punctuation, "["],
|
||||
[desc_sig_literal_number, "0"],
|
||||
[desc_sig_punctuation, ","],
|
||||
@@ -1174,7 +1188,9 @@ def test_type_field(app):
|
||||
text = (".. py:data:: var1\n"
|
||||
" :type: .int\n"
|
||||
".. py:data:: var2\n"
|
||||
" :type: ~builtins.int\n")
|
||||
" :type: ~builtins.int\n"
|
||||
".. py:data:: var3\n"
|
||||
" :type: typing.Optional[typing.Tuple[int, typing.Any]]\n")
|
||||
doctree = restructuredtext.parse(app, text)
|
||||
assert_node(doctree, (addnodes.index,
|
||||
[desc, ([desc_signature, ([desc_name, "var1"],
|
||||
@@ -1187,9 +1203,28 @@ def test_type_field(app):
|
||||
[desc_annotation, ([desc_sig_punctuation, ':'],
|
||||
desc_sig_space,
|
||||
[pending_xref, "int"])])],
|
||||
[desc_content, ()])],
|
||||
addnodes.index,
|
||||
[desc, ([desc_signature, ([desc_name, "var3"],
|
||||
[desc_annotation, ([desc_sig_punctuation, ":"],
|
||||
desc_sig_space,
|
||||
[pending_xref, "Optional"],
|
||||
[desc_sig_punctuation, "["],
|
||||
[pending_xref, "Tuple"],
|
||||
[desc_sig_punctuation, "["],
|
||||
[pending_xref, "int"],
|
||||
[desc_sig_punctuation, ","],
|
||||
desc_sig_space,
|
||||
[pending_xref, "Any"],
|
||||
[desc_sig_punctuation, "]"],
|
||||
[desc_sig_punctuation, "]"])])],
|
||||
[desc_content, ()])]))
|
||||
assert_node(doctree[1][0][1][2], pending_xref, reftarget='int', refspecific=True)
|
||||
assert_node(doctree[3][0][1][2], pending_xref, reftarget='builtins.int', refspecific=False)
|
||||
assert_node(doctree[5][0][1][2], pending_xref, reftarget='typing.Optional', refspecific=False)
|
||||
assert_node(doctree[5][0][1][4], pending_xref, reftarget='typing.Tuple', refspecific=False)
|
||||
assert_node(doctree[5][0][1][6], pending_xref, reftarget='int', refspecific=False)
|
||||
assert_node(doctree[5][0][1][9], pending_xref, reftarget='typing.Any', refspecific=False)
|
||||
|
||||
|
||||
@pytest.mark.sphinx(freshenv=True)
|
||||
|
||||
@@ -1,12 +1,4 @@
|
||||
"""
|
||||
test_rst_domain
|
||||
~~~~~~~~~~~~~~~
|
||||
|
||||
Tests the reStructuredText domain.
|
||||
|
||||
:copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
"""Tests the reStructuredText domain."""
|
||||
|
||||
from sphinx import addnodes
|
||||
from sphinx.addnodes import (desc, desc_addname, desc_annotation, desc_content, desc_name,
|
||||
|
||||
@@ -1,12 +1,4 @@
|
||||
"""
|
||||
test_domain_std
|
||||
~~~~~~~~~~~~~~~
|
||||
|
||||
Tests the std domain
|
||||
|
||||
:copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
"""Tests the std domain"""
|
||||
|
||||
from unittest import mock
|
||||
|
||||
@@ -36,7 +28,7 @@ def test_process_doc_handle_figure_caption():
|
||||
ids={'testid': figure_node},
|
||||
citation_refs={},
|
||||
)
|
||||
document.traverse.return_value = []
|
||||
document.findall.return_value = []
|
||||
|
||||
domain = StandardDomain(env)
|
||||
if 'testname' in domain.data['labels']:
|
||||
@@ -60,7 +52,7 @@ def test_process_doc_handle_table_title():
|
||||
ids={'testid': table_node},
|
||||
citation_refs={},
|
||||
)
|
||||
document.traverse.return_value = []
|
||||
document.findall.return_value = []
|
||||
|
||||
domain = StandardDomain(env)
|
||||
if 'testname' in domain.data['labels']:
|
||||
@@ -97,6 +89,9 @@ def test_cmd_option_with_optional_value(app):
|
||||
[desc, ([desc_signature, ([desc_name, '-j'],
|
||||
[desc_addname, '[=N]'])],
|
||||
[desc_content, ()])]))
|
||||
assert_node(doctree[0], addnodes.index,
|
||||
entries=[('pair', 'command line option; -j', 'cmdoption-j', '', None)])
|
||||
|
||||
objects = list(app.env.get_domain("std").get_objects())
|
||||
assert ('-j', '-j', 'cmdoption', 'index', 'cmdoption-j', 1) in objects
|
||||
|
||||
@@ -355,10 +350,8 @@ def test_multiple_cmdoptions(app):
|
||||
[desc_addname, " directory"])],
|
||||
[desc_content, ()])]))
|
||||
assert_node(doctree[0], addnodes.index,
|
||||
entries=[('pair', 'cmd command line option; -o directory',
|
||||
'cmdoption-cmd-o', '', None),
|
||||
('pair', 'cmd command line option; --output directory',
|
||||
'cmdoption-cmd-o', '', None)])
|
||||
entries=[('pair', 'cmd command line option; -o', 'cmdoption-cmd-o', '', None),
|
||||
('pair', 'cmd command line option; --output', 'cmdoption-cmd-o', '', None)])
|
||||
assert ('cmd', '-o') in domain.progoptions
|
||||
assert ('cmd', '--output') in domain.progoptions
|
||||
assert domain.progoptions[('cmd', '-o')] == ('index', 'cmdoption-cmd-o')
|
||||
@@ -424,7 +417,7 @@ def test_productionlist2(app):
|
||||
" A: `:A` `A`\n"
|
||||
" B: `P1:B` `~P1:B`\n")
|
||||
doctree = restructuredtext.parse(app, text)
|
||||
refnodes = list(doctree.traverse(pending_xref))
|
||||
refnodes = list(doctree.findall(pending_xref))
|
||||
assert_node(refnodes[0], pending_xref, reftarget="A")
|
||||
assert_node(refnodes[1], pending_xref, reftarget="P2:A")
|
||||
assert_node(refnodes[2], pending_xref, reftarget="P1:B")
|
||||
|
||||
@@ -1,12 +1,4 @@
|
||||
"""
|
||||
test_env
|
||||
~~~~~~~~
|
||||
|
||||
Test the BuildEnvironment class.
|
||||
|
||||
:copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
"""Test the BuildEnvironment class."""
|
||||
import os
|
||||
import shutil
|
||||
|
||||
|
||||
@@ -1,12 +1,4 @@
|
||||
"""
|
||||
test_environment_indexentries
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Test the sphinx.environment.managers.indexentries.
|
||||
|
||||
:copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
"""Test the sphinx.environment.managers.indexentries."""
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@@ -1,12 +1,4 @@
|
||||
"""
|
||||
test_environment_toctree
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Test the sphinx.environment.managers.toctree.
|
||||
|
||||
:copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
"""Test the sphinx.environment.managers.toctree."""
|
||||
|
||||
import pytest
|
||||
from docutils import nodes
|
||||
|
||||
@@ -1,12 +1,4 @@
|
||||
"""
|
||||
test_events
|
||||
~~~~~~~~~~~
|
||||
|
||||
Test the EventManager class.
|
||||
|
||||
:copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
"""Test the EventManager class."""
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@@ -1,12 +1,4 @@
|
||||
"""
|
||||
test_apidoc
|
||||
~~~~~~~~~~~
|
||||
|
||||
Test the sphinx.apidoc module.
|
||||
|
||||
:copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
"""Test the sphinx.apidoc module."""
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
|
||||
@@ -1,12 +1,7 @@
|
||||
"""
|
||||
test_ext_autodoc
|
||||
~~~~~~~~~~~~~~~~
|
||||
"""Test the autodoc extension.
|
||||
|
||||
Test the autodoc extension. This tests mainly the Documenters; the auto
|
||||
directives are tested in a test source file translated by test_build.
|
||||
|
||||
:copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
This tests mainly the Documenters; the auto directives are tested in a test
|
||||
source file translated by test_build.
|
||||
"""
|
||||
|
||||
import sys
|
||||
@@ -1009,7 +1004,7 @@ def test_autodoc_inner_class(app):
|
||||
'',
|
||||
'.. py:class:: InnerChild()',
|
||||
' :module: target', '',
|
||||
' Bases: :py:class:`target.Outer.Inner`',
|
||||
' Bases: :py:class:`~target.Outer.Inner`',
|
||||
'',
|
||||
' InnerChild docstring',
|
||||
'',
|
||||
@@ -1705,7 +1700,7 @@ def test_autodoc_typed_instance_variables(app):
|
||||
'.. py:attribute:: Alias',
|
||||
' :module: target.typed_vars',
|
||||
'',
|
||||
' alias of :py:class:`target.typed_vars.Derived`',
|
||||
' alias of :py:class:`~target.typed_vars.Derived`',
|
||||
'',
|
||||
'.. py:class:: Class()',
|
||||
' :module: target.typed_vars',
|
||||
@@ -1874,6 +1869,12 @@ def test_autodoc_GenericAlias(app):
|
||||
'',
|
||||
' alias of :py:class:`~typing.List`\\ [:py:class:`int`]',
|
||||
'',
|
||||
'.. py:attribute:: L',
|
||||
' :module: target.genericalias',
|
||||
'',
|
||||
' A list of Class',
|
||||
'',
|
||||
'',
|
||||
'.. py:attribute:: T',
|
||||
' :module: target.genericalias',
|
||||
'',
|
||||
@@ -1898,6 +1899,15 @@ def test_autodoc_GenericAlias(app):
|
||||
' alias of :py:class:`~typing.List`\\ [:py:class:`int`]',
|
||||
'',
|
||||
'',
|
||||
'.. py:data:: L',
|
||||
' :module: target.genericalias',
|
||||
'',
|
||||
' A list of Class',
|
||||
'',
|
||||
' alias of :py:class:`~typing.List`\\ '
|
||||
'[:py:class:`~target.genericalias.Class`]',
|
||||
'',
|
||||
'',
|
||||
'.. py:data:: T',
|
||||
' :module: target.genericalias',
|
||||
'',
|
||||
@@ -1935,7 +1945,7 @@ def test_autodoc_TypeVar(app):
|
||||
'',
|
||||
' T6',
|
||||
'',
|
||||
' alias of :py:class:`int`',
|
||||
' alias of :py:class:`~datetime.date`',
|
||||
'',
|
||||
'',
|
||||
'.. py:data:: T1',
|
||||
@@ -1975,7 +1985,7 @@ def test_autodoc_TypeVar(app):
|
||||
'',
|
||||
' T6',
|
||||
'',
|
||||
' alias of :py:class:`int`',
|
||||
' alias of :py:class:`~datetime.date`',
|
||||
'',
|
||||
'',
|
||||
'.. py:data:: T7',
|
||||
@@ -2307,7 +2317,7 @@ def test_autodoc(app, status, warning):
|
||||
|
||||
my_name
|
||||
|
||||
alias of bug2437.autodoc_dummy_foo.Foo"""
|
||||
alias of Foo"""
|
||||
assert warning.getvalue() == ''
|
||||
|
||||
|
||||
|
||||
@@ -1,12 +1,7 @@
|
||||
"""
|
||||
test_ext_autodoc_autoattribute
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
"""Test the autodoc extension.
|
||||
|
||||
Test the autodoc extension. This tests mainly the Documenters; the auto
|
||||
directives are tested in a test source file translated by test_build.
|
||||
|
||||
:copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
This tests mainly the Documenters; the auto directives are tested in a test
|
||||
source file translated by test_build.
|
||||
"""
|
||||
|
||||
import sys
|
||||
@@ -32,7 +27,7 @@ def test_autoattribute(app):
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_autoattribute_novalue(app):
|
||||
options = {'no-value': True}
|
||||
options = {'no-value': None}
|
||||
actual = do_autodoc(app, 'attribute', 'target.Class.attr', options)
|
||||
assert list(actual) == [
|
||||
'',
|
||||
@@ -183,7 +178,7 @@ def test_autoattribute_NewType(app):
|
||||
'',
|
||||
' T6',
|
||||
'',
|
||||
' alias of :py:class:`int`',
|
||||
' alias of :py:class:`~datetime.date`',
|
||||
'',
|
||||
]
|
||||
|
||||
|
||||
@@ -1,12 +1,7 @@
|
||||
"""
|
||||
test_ext_autodoc_autoclass
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
"""Test the autodoc extension.
|
||||
|
||||
Test the autodoc extension. This tests mainly the Documenters; the auto
|
||||
directives are tested in a test source file translated by test_build.
|
||||
|
||||
:copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
This tests mainly the Documenters; the auto directives are tested in a test
|
||||
source file translated by test_build.
|
||||
"""
|
||||
|
||||
import sys
|
||||
@@ -284,7 +279,7 @@ def test_show_inheritance_for_decendants_of_generic_type(app):
|
||||
'.. py:class:: Corge(iterable=(), /)',
|
||||
' :module: target.classes',
|
||||
'',
|
||||
' Bases: :py:class:`target.classes.Quux`',
|
||||
' Bases: :py:class:`~target.classes.Quux`',
|
||||
'',
|
||||
]
|
||||
|
||||
@@ -391,7 +386,7 @@ def test_class_alias(app):
|
||||
'.. py:attribute:: Alias',
|
||||
' :module: target.classes',
|
||||
'',
|
||||
' alias of :py:class:`target.classes.Foo`',
|
||||
' alias of :py:class:`~target.classes.Foo`',
|
||||
]
|
||||
|
||||
|
||||
|
||||
@@ -1,12 +1,7 @@
|
||||
"""
|
||||
test_ext_autodoc_autodata
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
"""Test the autodoc extension.
|
||||
|
||||
Test the autodoc extension. This tests mainly the Documenters; the auto
|
||||
directives are tested in a test source file translated by test_build.
|
||||
|
||||
:copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
This tests mainly the Documenters; the auto directives are tested in a test
|
||||
source file translated by test_build.
|
||||
"""
|
||||
|
||||
import sys
|
||||
@@ -32,7 +27,7 @@ def test_autodata(app):
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_autodata_novalue(app):
|
||||
options = {'no-value': True}
|
||||
options = {'no-value': None}
|
||||
actual = do_autodoc(app, 'data', 'target.integer', options)
|
||||
assert list(actual) == [
|
||||
'',
|
||||
@@ -111,7 +106,7 @@ def test_autodata_NewType(app):
|
||||
'',
|
||||
' T6',
|
||||
'',
|
||||
' alias of :py:class:`int`',
|
||||
' alias of :py:class:`~datetime.date`',
|
||||
'',
|
||||
]
|
||||
|
||||
|
||||
@@ -1,12 +1,7 @@
|
||||
"""
|
||||
test_ext_autodoc_autofunction
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
"""Test the autodoc extension.
|
||||
|
||||
Test the autodoc extension. This tests mainly the Documenters; the auto
|
||||
directives are tested in a test source file translated by test_build.
|
||||
|
||||
:copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
This tests mainly the Documenters; the auto directives are tested in a test
|
||||
source file translated by test_build.
|
||||
"""
|
||||
|
||||
import pytest
|
||||
@@ -162,7 +157,7 @@ def test_wrapped_function_contextmanager(app):
|
||||
actual = do_autodoc(app, 'function', 'target.wrappedfunction.feeling_good')
|
||||
assert list(actual) == [
|
||||
'',
|
||||
'.. py:function:: feeling_good(x: int, y: int) -> Generator',
|
||||
'.. py:function:: feeling_good(x: int, y: int) -> ~typing.Generator',
|
||||
' :module: target.wrappedfunction',
|
||||
'',
|
||||
" You'll feel better in this context!",
|
||||
|
||||
@@ -1,12 +1,7 @@
|
||||
"""
|
||||
test_ext_autodoc_autocmodule
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
"""Test the autodoc extension.
|
||||
|
||||
Test the autodoc extension. This tests mainly the Documenters; the auto
|
||||
directives are tested in a test source file translated by test_build.
|
||||
|
||||
:copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
This tests mainly the Documenters; the auto directives are tested in a test
|
||||
source file translated by test_build.
|
||||
"""
|
||||
|
||||
import sys
|
||||
@@ -130,4 +125,4 @@ def test_subclass_of_mocked_object(app):
|
||||
|
||||
options = {'members': None}
|
||||
actual = do_autodoc(app, 'module', 'target.need_mocks', options)
|
||||
assert '.. py:class:: Inherited(*args: Any, **kwargs: Any)' in actual
|
||||
assert '.. py:class:: Inherited(*args: ~typing.Any, **kwargs: ~typing.Any)' in actual
|
||||
|
||||
@@ -1,12 +1,7 @@
|
||||
"""
|
||||
test_ext_autodoc_autoproperty
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
"""Test the autodoc extension.
|
||||
|
||||
Test the autodoc extension. This tests mainly the Documenters; the auto
|
||||
directives are tested in a test source file translated by test_build.
|
||||
|
||||
:copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
This tests mainly the Documenters; the auto directives are tested in a test
|
||||
source file translated by test_build.
|
||||
"""
|
||||
|
||||
import sys
|
||||
|
||||
@@ -1,12 +1,4 @@
|
||||
"""
|
||||
test_ext_autodoc_configs
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Test the autodoc extension. This tests mainly for config variables
|
||||
|
||||
:copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
"""Test the autodoc extension. This tests mainly for config variables"""
|
||||
|
||||
import platform
|
||||
import sys
|
||||
@@ -475,13 +467,15 @@ def test_autoclass_content_and_docstring_signature_init(app):
|
||||
' :module: target.docstring_signature',
|
||||
'',
|
||||
'',
|
||||
'.. py:class:: E(foo: int, bar: int, baz: int) -> None',
|
||||
' E(foo: str, bar: str, baz: str) -> None',
|
||||
'.. py:class:: E(foo: int, bar: int, baz: int)',
|
||||
' E(foo: str, bar: str, baz: str)',
|
||||
' E(foo: float, bar: float, baz: float)',
|
||||
' :module: target.docstring_signature',
|
||||
'',
|
||||
'',
|
||||
'.. py:class:: F(foo: int, bar: int, baz: int) -> None',
|
||||
' F(foo: str, bar: str, baz: str) -> None',
|
||||
'.. py:class:: F(foo: int, bar: int, baz: int)',
|
||||
' F(foo: str, bar: str, baz: str)',
|
||||
' F(foo: float, bar: float, baz: float)',
|
||||
' :module: target.docstring_signature',
|
||||
'',
|
||||
]
|
||||
@@ -518,13 +512,15 @@ def test_autoclass_content_and_docstring_signature_both(app):
|
||||
' :module: target.docstring_signature',
|
||||
'',
|
||||
'',
|
||||
'.. py:class:: E(foo: int, bar: int, baz: int) -> None',
|
||||
' E(foo: str, bar: str, baz: str) -> None',
|
||||
'.. py:class:: E(foo: int, bar: int, baz: int)',
|
||||
' E(foo: str, bar: str, baz: str)',
|
||||
' E(foo: float, bar: float, baz: float)',
|
||||
' :module: target.docstring_signature',
|
||||
'',
|
||||
'',
|
||||
'.. py:class:: F(foo: int, bar: int, baz: int) -> None',
|
||||
' F(foo: str, bar: str, baz: str) -> None',
|
||||
'.. py:class:: F(foo: int, bar: int, baz: int)',
|
||||
' F(foo: str, bar: str, baz: str)',
|
||||
' F(foo: float, bar: float, baz: float)',
|
||||
' :module: target.docstring_signature',
|
||||
'',
|
||||
]
|
||||
@@ -599,6 +595,11 @@ def test_mocked_module_imports(app, warning):
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc',
|
||||
confoverrides={'autodoc_typehints': "signature"})
|
||||
def test_autodoc_typehints_signature(app):
|
||||
if sys.version_info < (3, 11):
|
||||
type_o = "~typing.Optional[~typing.Any]"
|
||||
else:
|
||||
type_o = "~typing.Any"
|
||||
|
||||
options = {"members": None,
|
||||
"undoc-members": None}
|
||||
actual = do_autodoc(app, 'module', 'target.typehints', options)
|
||||
@@ -612,7 +613,7 @@ def test_autodoc_typehints_signature(app):
|
||||
' :type: int',
|
||||
'',
|
||||
'',
|
||||
'.. py:class:: Math(s: str, o: Optional[Any] = None)',
|
||||
'.. py:class:: Math(s: str, o: %s = None)' % type_o,
|
||||
' :module: target.typehints',
|
||||
'',
|
||||
'',
|
||||
@@ -677,7 +678,8 @@ def test_autodoc_typehints_signature(app):
|
||||
' :module: target.typehints',
|
||||
'',
|
||||
'',
|
||||
'.. py:function:: tuple_args(x: Tuple[int, Union[int, str]]) -> Tuple[int, int]',
|
||||
'.. py:function:: tuple_args(x: ~typing.Tuple[int, ~typing.Union[int, str]]) '
|
||||
'-> ~typing.Tuple[int, int]',
|
||||
' :module: target.typehints',
|
||||
'',
|
||||
]
|
||||
@@ -834,7 +836,7 @@ def test_autodoc_typehints_description(app):
|
||||
' **x** (*Tuple**[**int**, **Union**[**int**, **str**]**]*) --\n'
|
||||
'\n'
|
||||
' Return type:\n'
|
||||
' Tuple[int, int]\n'
|
||||
' *Tuple*[int, int]\n'
|
||||
in context)
|
||||
|
||||
# Overloads still get displayed in the signature
|
||||
@@ -886,7 +888,7 @@ def test_autodoc_typehints_description_no_undoc(app):
|
||||
' another tuple\n'
|
||||
'\n'
|
||||
' Return type:\n'
|
||||
' Tuple[int, int]\n'
|
||||
' *Tuple*[int, int]\n'
|
||||
in context)
|
||||
|
||||
|
||||
@@ -1066,7 +1068,7 @@ def test_autodoc_typehints_both(app):
|
||||
' **x** (*Tuple**[**int**, **Union**[**int**, **str**]**]*) --\n'
|
||||
'\n'
|
||||
' Return type:\n'
|
||||
' Tuple[int, int]\n'
|
||||
' *Tuple*[int, int]\n'
|
||||
in context)
|
||||
|
||||
# Overloads still get displayed in the signature
|
||||
@@ -1116,7 +1118,7 @@ def test_autodoc_type_aliases(app):
|
||||
' docstring',
|
||||
'',
|
||||
'',
|
||||
'.. py:function:: read(r: _io.BytesIO) -> _io.StringIO',
|
||||
'.. py:function:: read(r: ~_io.BytesIO) -> ~_io.StringIO',
|
||||
' :module: target.autodoc_type_aliases',
|
||||
'',
|
||||
' docstring',
|
||||
@@ -1180,7 +1182,7 @@ def test_autodoc_type_aliases(app):
|
||||
' docstring',
|
||||
'',
|
||||
'',
|
||||
'.. py:function:: read(r: _io.BytesIO) -> my.module.StringIO',
|
||||
'.. py:function:: read(r: ~_io.BytesIO) -> my.module.StringIO',
|
||||
' :module: target.autodoc_type_aliases',
|
||||
'',
|
||||
' docstring',
|
||||
@@ -1231,6 +1233,155 @@ def test_autodoc_typehints_description_and_type_aliases(app):
|
||||
' myint\n' == context)
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc',
|
||||
confoverrides={'autodoc_typehints_format': "fully-qualified"})
|
||||
def test_autodoc_typehints_format_fully_qualified(app):
|
||||
if sys.version_info < (3, 11):
|
||||
type_o = "typing.Optional[typing.Any]"
|
||||
else:
|
||||
type_o = "typing.Any"
|
||||
|
||||
options = {"members": None,
|
||||
"undoc-members": None}
|
||||
actual = do_autodoc(app, 'module', 'target.typehints', options)
|
||||
assert list(actual) == [
|
||||
'',
|
||||
'.. py:module:: target.typehints',
|
||||
'',
|
||||
'',
|
||||
'.. py:data:: CONST1',
|
||||
' :module: target.typehints',
|
||||
' :type: int',
|
||||
'',
|
||||
'',
|
||||
'.. py:class:: Math(s: str, o: %s = None)' % type_o,
|
||||
' :module: target.typehints',
|
||||
'',
|
||||
'',
|
||||
' .. py:attribute:: Math.CONST1',
|
||||
' :module: target.typehints',
|
||||
' :type: int',
|
||||
'',
|
||||
'',
|
||||
' .. py:attribute:: Math.CONST2',
|
||||
' :module: target.typehints',
|
||||
' :type: int',
|
||||
' :value: 1',
|
||||
'',
|
||||
'',
|
||||
' .. py:method:: Math.decr(a: int, b: int = 1) -> int',
|
||||
' :module: target.typehints',
|
||||
'',
|
||||
'',
|
||||
' .. py:method:: Math.horse(a: str, b: int) -> None',
|
||||
' :module: target.typehints',
|
||||
'',
|
||||
'',
|
||||
' .. py:method:: Math.incr(a: int, b: int = 1) -> int',
|
||||
' :module: target.typehints',
|
||||
'',
|
||||
'',
|
||||
' .. py:method:: Math.nothing() -> None',
|
||||
' :module: target.typehints',
|
||||
'',
|
||||
'',
|
||||
' .. py:property:: Math.prop',
|
||||
' :module: target.typehints',
|
||||
' :type: int',
|
||||
'',
|
||||
'',
|
||||
'.. py:class:: NewAnnotation(i: int)',
|
||||
' :module: target.typehints',
|
||||
'',
|
||||
'',
|
||||
'.. py:class:: NewComment(i: int)',
|
||||
' :module: target.typehints',
|
||||
'',
|
||||
'',
|
||||
'.. py:class:: SignatureFromMetaclass(a: int)',
|
||||
' :module: target.typehints',
|
||||
'',
|
||||
'',
|
||||
'.. py:function:: complex_func(arg1: str, arg2: List[int], arg3: Tuple[int, '
|
||||
'Union[str, Unknown]] = None, *args: str, **kwargs: str) -> None',
|
||||
' :module: target.typehints',
|
||||
'',
|
||||
'',
|
||||
'.. py:function:: decr(a: int, b: int = 1) -> int',
|
||||
' :module: target.typehints',
|
||||
'',
|
||||
'',
|
||||
'.. py:function:: incr(a: int, b: int = 1) -> int',
|
||||
' :module: target.typehints',
|
||||
'',
|
||||
'',
|
||||
'.. py:function:: missing_attr(c, a: str, b: Optional[str] = None) -> str',
|
||||
' :module: target.typehints',
|
||||
'',
|
||||
'',
|
||||
'.. py:function:: tuple_args(x: typing.Tuple[int, typing.Union[int, str]]) '
|
||||
'-> typing.Tuple[int, int]',
|
||||
' :module: target.typehints',
|
||||
'',
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc',
|
||||
confoverrides={'autodoc_typehints_format': "fully-qualified"})
|
||||
def test_autodoc_typehints_format_fully_qualified_for_class_alias(app):
|
||||
actual = do_autodoc(app, 'class', 'target.classes.Alias')
|
||||
assert list(actual) == [
|
||||
'',
|
||||
'.. py:attribute:: Alias',
|
||||
' :module: target.classes',
|
||||
'',
|
||||
' alias of :py:class:`target.classes.Foo`',
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc',
|
||||
confoverrides={'autodoc_typehints_format': "fully-qualified"})
|
||||
def test_autodoc_typehints_format_fully_qualified_for_generic_alias(app):
|
||||
actual = do_autodoc(app, 'data', 'target.genericalias.L')
|
||||
if sys.version_info < (3, 7):
|
||||
assert list(actual) == [
|
||||
'',
|
||||
'.. py:data:: L',
|
||||
' :module: target.genericalias',
|
||||
' :value: typing.List[target.genericalias.Class]',
|
||||
'',
|
||||
' A list of Class',
|
||||
'',
|
||||
]
|
||||
else:
|
||||
assert list(actual) == [
|
||||
'',
|
||||
'.. py:data:: L',
|
||||
' :module: target.genericalias',
|
||||
'',
|
||||
' A list of Class',
|
||||
'',
|
||||
' alias of :py:class:`~typing.List`\\ [:py:class:`target.genericalias.Class`]',
|
||||
'',
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc',
|
||||
confoverrides={'autodoc_typehints_format': "fully-qualified"})
|
||||
def test_autodoc_typehints_format_fully_qualified_for_newtype_alias(app):
|
||||
actual = do_autodoc(app, 'data', 'target.typevar.T6')
|
||||
assert list(actual) == [
|
||||
'',
|
||||
'.. py:data:: T6',
|
||||
' :module: target.typevar',
|
||||
'',
|
||||
' T6',
|
||||
'',
|
||||
' alias of :py:class:`datetime.date`',
|
||||
'',
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_autodoc_default_options(app):
|
||||
# no settings
|
||||
|
||||
@@ -1,12 +1,4 @@
|
||||
"""
|
||||
test_ext_autodoc_events
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Test the autodoc extension. This tests mainly for autodoc events
|
||||
|
||||
:copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
"""Test the autodoc extension. This tests mainly for autodoc events"""
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@@ -1,12 +1,4 @@
|
||||
"""
|
||||
test_ext_autodoc_mock
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Test the autodoc extension.
|
||||
|
||||
:copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
"""Test the autodoc extension."""
|
||||
|
||||
import abc
|
||||
import sys
|
||||
@@ -122,6 +114,11 @@ def test_mock_decorator():
|
||||
def meth(self):
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
@mock.method_deco
|
||||
def class_meth(cls):
|
||||
pass
|
||||
|
||||
@mock.class_deco
|
||||
class Bar:
|
||||
pass
|
||||
@@ -132,6 +129,7 @@ def test_mock_decorator():
|
||||
|
||||
assert undecorate(func).__name__ == "func"
|
||||
assert undecorate(Foo.meth).__name__ == "meth"
|
||||
assert undecorate(Foo.class_meth).__name__ == "class_meth"
|
||||
assert undecorate(Bar).__name__ == "Bar"
|
||||
assert undecorate(Baz).__name__ == "Baz"
|
||||
|
||||
|
||||
@@ -1,12 +1,4 @@
|
||||
"""
|
||||
test_ext_autodoc_preserve_defaults
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Test the autodoc extension.
|
||||
|
||||
:copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
"""Test the autodoc extension."""
|
||||
|
||||
import sys
|
||||
|
||||
@@ -36,15 +28,17 @@ def test_preserve_defaults(app):
|
||||
' docstring',
|
||||
'',
|
||||
'',
|
||||
' .. py:method:: Class.meth(name: str = CONSTANT, sentinel: Any = SENTINEL, '
|
||||
'now: datetime.datetime = datetime.now(), color: int = %s) -> None' % color,
|
||||
' .. py:method:: Class.meth(name: str = CONSTANT, sentinel: ~typing.Any = '
|
||||
'SENTINEL, now: ~datetime.datetime = datetime.now(), color: int = %s, *, '
|
||||
'kwarg1, kwarg2=%s) -> None' % (color, color),
|
||||
' :module: target.preserve_defaults',
|
||||
'',
|
||||
' docstring',
|
||||
'',
|
||||
'',
|
||||
'.. py:function:: foo(name: str = CONSTANT, sentinel: Any = SENTINEL, now: '
|
||||
'datetime.datetime = datetime.now(), color: int = %s) -> None' % color,
|
||||
'.. py:function:: foo(name: str = CONSTANT, sentinel: ~typing.Any = SENTINEL, '
|
||||
'now: ~datetime.datetime = datetime.now(), color: int = %s, *, kwarg1, '
|
||||
'kwarg2=%s) -> None' % (color, color),
|
||||
' :module: target.preserve_defaults',
|
||||
'',
|
||||
' docstring',
|
||||
|
||||
@@ -1,11 +1,4 @@
|
||||
"""
|
||||
test_ext_autodoc_private_members
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Test the autodoc extension. This tests mainly for private-members option.
|
||||
|
||||
:copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""Test the autodoc extension. This tests mainly for private-members option.
|
||||
"""
|
||||
|
||||
import pytest
|
||||
|
||||
@@ -1,12 +1,4 @@
|
||||
"""
|
||||
test_ext_autosectionlabel
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Test sphinx.ext.autosectionlabel extension.
|
||||
|
||||
:copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
"""Test sphinx.ext.autosectionlabel extension."""
|
||||
|
||||
import re
|
||||
|
||||
|
||||
@@ -1,12 +1,4 @@
|
||||
"""
|
||||
test_autosummary
|
||||
~~~~~~~~~~~~~~~~
|
||||
|
||||
Test the autosummary extension.
|
||||
|
||||
:copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
"""Test the autosummary extension."""
|
||||
|
||||
import sys
|
||||
from io import StringIO
|
||||
|
||||
@@ -1,12 +1,4 @@
|
||||
"""
|
||||
test_coverage
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
Test the coverage builder.
|
||||
|
||||
:copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
"""Test the coverage builder."""
|
||||
|
||||
import pickle
|
||||
|
||||
|
||||
@@ -1,12 +1,4 @@
|
||||
"""
|
||||
test_doctest
|
||||
~~~~~~~~~~~~
|
||||
|
||||
Test the doctest extension.
|
||||
|
||||
:copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
"""Test the doctest extension."""
|
||||
import os
|
||||
from collections import Counter
|
||||
|
||||
@@ -36,7 +28,7 @@ def test_build(app, status, warning):
|
||||
def test_highlight_language_default(app, status, warning):
|
||||
app.build()
|
||||
doctree = app.env.get_doctree('doctest')
|
||||
for node in doctree.traverse(nodes.literal_block):
|
||||
for node in doctree.findall(nodes.literal_block):
|
||||
assert node['language'] in ('python3', 'pycon3', 'none')
|
||||
|
||||
|
||||
@@ -45,7 +37,7 @@ def test_highlight_language_default(app, status, warning):
|
||||
def test_highlight_language_python2(app, status, warning):
|
||||
app.build()
|
||||
doctree = app.env.get_doctree('doctest')
|
||||
for node in doctree.traverse(nodes.literal_block):
|
||||
for node in doctree.findall(nodes.literal_block):
|
||||
assert node['language'] in ('python', 'pycon', 'none')
|
||||
|
||||
|
||||
|
||||
@@ -1,12 +1,4 @@
|
||||
"""
|
||||
test_ext_duration
|
||||
~~~~~~~~~~~~~~~~~
|
||||
|
||||
Test sphinx.ext.duration extension.
|
||||
|
||||
:copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
"""Test sphinx.ext.duration extension."""
|
||||
|
||||
import re
|
||||
|
||||
|
||||
@@ -1,18 +1,26 @@
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-extlinks-hardcoded-urls',
|
||||
confoverrides={'extlinks_detect_hardcoded_links': False})
|
||||
def test_extlinks_detect_candidates(app, warning):
|
||||
app.build()
|
||||
assert warning.getvalue() == ''
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-extlinks-hardcoded-urls')
|
||||
def test_replaceable_uris_emit_extlinks_warnings(app, warning):
|
||||
app.build()
|
||||
warning_output = warning.getvalue()
|
||||
|
||||
# there should be exactly three warnings for replaceable URLs
|
||||
message = (
|
||||
"WARNING: hardcoded link 'https://github.com/sphinx-doc/sphinx/issues/1' "
|
||||
"could be replaced by an extlink (try using ':issue:`1`' instead)"
|
||||
"index.rst:%d: WARNING: hardcoded link 'https://github.com/sphinx-doc/sphinx/issues/1' "
|
||||
"could be replaced by an extlink (try using '%s' instead)"
|
||||
)
|
||||
assert f"index.rst:11: {message}" in warning_output
|
||||
assert f"index.rst:13: {message}" in warning_output
|
||||
assert f"index.rst:15: {message}" in warning_output
|
||||
assert message % (11, ":issue:`1`") in warning_output
|
||||
assert message % (13, ":issue:`inline replaceable link <1>`") in warning_output
|
||||
assert message % (15, ":issue:`replaceable link <1>`") in warning_output
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-extlinks-hardcoded-urls-multiple-replacements')
|
||||
@@ -21,16 +29,16 @@ def test_all_replacements_suggested_if_multiple_replacements_possible(app, warni
|
||||
warning_output = warning.getvalue()
|
||||
# there should be six warnings for replaceable URLs, three pairs per link
|
||||
message = (
|
||||
"WARNING: hardcoded link 'https://github.com/octocat' "
|
||||
"could be replaced by an extlink (try using ':user:`octocat`' instead)"
|
||||
"index.rst:%d: WARNING: hardcoded link 'https://github.com/octocat' "
|
||||
"could be replaced by an extlink (try using '%s' instead)"
|
||||
)
|
||||
assert f"index.rst:14: {message}" in warning_output
|
||||
assert f"index.rst:16: {message}" in warning_output
|
||||
assert f"index.rst:18: {message}" in warning_output
|
||||
assert message % (14, ":user:`octocat`") in warning_output
|
||||
assert message % (16, ":user:`inline replaceable link <octocat>`") in warning_output
|
||||
assert message % (18, ":user:`replaceable link <octocat>`") in warning_output
|
||||
message = (
|
||||
"WARNING: hardcoded link 'https://github.com/octocat' "
|
||||
"could be replaced by an extlink (try using ':repo:`octocat`' instead)"
|
||||
"index.rst:%d: WARNING: hardcoded link 'https://github.com/octocat' "
|
||||
"could be replaced by an extlink (try using '%s' instead)"
|
||||
)
|
||||
assert f"index.rst:14: {message}" in warning_output
|
||||
assert f"index.rst:16: {message}" in warning_output
|
||||
assert f"index.rst:18: {message}" in warning_output
|
||||
assert message % (14, ":repo:`octocat`") in warning_output
|
||||
assert message % (16, ":repo:`inline replaceable link <octocat>`") in warning_output
|
||||
assert message % (18, ":repo:`replaceable link <octocat>`") in warning_output
|
||||
|
||||
@@ -1,12 +1,4 @@
|
||||
"""
|
||||
test_ext_githubpages
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Test sphinx.ext.githubpages extension.
|
||||
|
||||
:copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
"""Test sphinx.ext.githubpages extension."""
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@@ -1,12 +1,4 @@
|
||||
"""
|
||||
test_ext_graphviz
|
||||
~~~~~~~~~~~~~~~~~
|
||||
|
||||
Test sphinx.ext.graphviz extension.
|
||||
|
||||
:copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
"""Test sphinx.ext.graphviz extension."""
|
||||
|
||||
import re
|
||||
|
||||
|
||||
@@ -1,12 +1,4 @@
|
||||
"""
|
||||
test_ext_ifconfig
|
||||
~~~~~~~~~~~~~~~~~
|
||||
|
||||
Test sphinx.ext.ifconfig extension.
|
||||
|
||||
:copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
"""Test sphinx.ext.ifconfig extension."""
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@@ -1,12 +1,4 @@
|
||||
"""
|
||||
test_ext_imgconverter
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Test sphinx.ext.imgconverter extension.
|
||||
|
||||
:copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
"""Test sphinx.ext.imgconverter extension."""
|
||||
|
||||
import os
|
||||
|
||||
|
||||
@@ -1,12 +1,4 @@
|
||||
"""
|
||||
test_ext_inheritance_diagram
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Test sphinx.ext.inheritance_diagram extension.
|
||||
|
||||
:copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
"""Test sphinx.ext.inheritance_diagram extension."""
|
||||
|
||||
import os
|
||||
import re
|
||||
|
||||
@@ -1,12 +1,4 @@
|
||||
"""
|
||||
test_intersphinx
|
||||
~~~~~~~~~~~~~~~~
|
||||
|
||||
Test the intersphinx extension.
|
||||
|
||||
:copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
"""Test the intersphinx extension."""
|
||||
|
||||
import http.server
|
||||
import os
|
||||
@@ -524,3 +516,48 @@ def test_inspect_main_url(capsys):
|
||||
stdout, stderr = capsys.readouterr()
|
||||
assert stdout.startswith("c:function\n")
|
||||
assert stderr == ""
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-intersphinx-role')
|
||||
def test_intersphinx_role(app, warning):
|
||||
inv_file = app.srcdir / 'inventory'
|
||||
inv_file.write_bytes(inventory_v2)
|
||||
app.config.intersphinx_mapping = {
|
||||
'inv': ('http://example.org/', inv_file),
|
||||
}
|
||||
app.config.intersphinx_cache_limit = 0
|
||||
app.config.nitpicky = True
|
||||
|
||||
# load the inventory and check if it's done correctly
|
||||
normalize_intersphinx_mapping(app, app.config)
|
||||
load_mappings(app)
|
||||
|
||||
app.build()
|
||||
content = (app.outdir / 'index.html').read_text()
|
||||
wStr = warning.getvalue()
|
||||
|
||||
html = '<a class="reference external" href="http://example.org/{}" title="(in foo v2.0)">'
|
||||
assert html.format('foo.html#module-module1') in content
|
||||
assert html.format('foo.html#module-module2') in content
|
||||
assert "WARNING: external py:mod reference target not found: module3" in wStr
|
||||
assert "WARNING: external py:mod reference target not found: module10" in wStr
|
||||
|
||||
assert html.format('sub/foo.html#module1.func') in content
|
||||
assert "WARNING: external py:meth reference target not found: inv:Foo.bar" in wStr
|
||||
|
||||
assert "WARNING: role for external cross-reference not found: py:nope" in wStr
|
||||
|
||||
# default domain
|
||||
assert html.format('index.html#std_uint8_t') in content
|
||||
assert "WARNING: role for external cross-reference not found: nope" in wStr
|
||||
|
||||
# std roles without domain prefix
|
||||
assert html.format('docname.html') in content
|
||||
assert html.format('index.html#cmdoption-ls-l') in content
|
||||
|
||||
# explicit inventory
|
||||
assert html.format('cfunc.html#CFunc') in content
|
||||
assert "WARNING: inventory for external cross-reference not found: invNope" in wStr
|
||||
|
||||
# explicit title
|
||||
assert html.format('index.html#foons') in content
|
||||
|
||||
@@ -1,12 +1,4 @@
|
||||
"""
|
||||
test_ext_math
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
Test math extensions.
|
||||
|
||||
:copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
"""Test math extensions."""
|
||||
|
||||
import re
|
||||
import subprocess
|
||||
|
||||
@@ -1,13 +1,4 @@
|
||||
"""
|
||||
test_napoleon
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
Tests for :mod:`sphinx.ext.napoleon.__init__` module.
|
||||
|
||||
|
||||
:copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
"""Tests for :mod:`sphinx.ext.napoleon.__init__` module."""
|
||||
|
||||
import sys
|
||||
from collections import namedtuple
|
||||
@@ -101,9 +92,9 @@ class SetupTest(TestCase):
|
||||
def test_add_config_values(self):
|
||||
app = mock.Mock(Sphinx)
|
||||
setup(app)
|
||||
for name, (default, rebuild) in Config._config_values.items():
|
||||
for name in Config._config_values:
|
||||
has_config = False
|
||||
for method_name, args, kwargs in app.method_calls:
|
||||
for method_name, args, _kwargs in app.method_calls:
|
||||
if(method_name == 'add_config_value' and
|
||||
args[0] == name):
|
||||
has_config = True
|
||||
@@ -112,7 +103,7 @@ class SetupTest(TestCase):
|
||||
|
||||
has_process_docstring = False
|
||||
has_skip_member = False
|
||||
for method_name, args, kwargs in app.method_calls:
|
||||
for method_name, args, _kwargs in app.method_calls:
|
||||
if method_name == 'connect':
|
||||
if(args[0] == 'autodoc-process-docstring' and
|
||||
args[1] == _process_docstring):
|
||||
|
||||
@@ -1,13 +1,4 @@
|
||||
"""
|
||||
test_napoleon_docstring
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Tests for :mod:`sphinx.ext.napoleon.docstring` module.
|
||||
|
||||
|
||||
:copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
"""Tests for :mod:`sphinx.ext.napoleon.docstring` module."""
|
||||
|
||||
import re
|
||||
import sys
|
||||
@@ -267,6 +258,18 @@ class GoogleDocstringTest(BaseDocstringTest):
|
||||
"""
|
||||
Single line summary
|
||||
|
||||
Returns:
|
||||
Extended
|
||||
""",
|
||||
"""
|
||||
Single line summary
|
||||
|
||||
:returns: Extended
|
||||
"""
|
||||
), (
|
||||
"""
|
||||
Single line summary
|
||||
|
||||
Args:
|
||||
arg1(str):Extended
|
||||
description of arg1
|
||||
@@ -470,6 +473,22 @@ Attributes:
|
||||
super-dooper attribute
|
||||
|
||||
:type: numpy.ndarray
|
||||
"""
|
||||
|
||||
def test_attributes_with_use_ivar(self):
|
||||
docstring = """\
|
||||
Attributes:
|
||||
foo (int): blah blah
|
||||
bar (str): blah blah
|
||||
"""
|
||||
|
||||
config = Config(napoleon_use_ivar=True)
|
||||
actual = str(GoogleDocstring(docstring, config, obj=self.__class__))
|
||||
expected = """\
|
||||
:ivar foo: blah blah
|
||||
:vartype foo: int
|
||||
:ivar bar: blah blah
|
||||
:vartype bar: str
|
||||
"""
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
|
||||
@@ -1,13 +1,4 @@
|
||||
"""
|
||||
test_napoleon_iterators
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Tests for :mod:`sphinx.ext.napoleon.iterators` module.
|
||||
|
||||
|
||||
:copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
"""Tests for :mod:`sphinx.ext.napoleon.iterators` module."""
|
||||
|
||||
from unittest import TestCase
|
||||
|
||||
|
||||
@@ -1,12 +1,4 @@
|
||||
"""
|
||||
test_ext_todo
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
Test sphinx.ext.todo extension.
|
||||
|
||||
:copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
"""Test sphinx.ext.todo extension."""
|
||||
|
||||
import re
|
||||
|
||||
|
||||
@@ -1,12 +1,4 @@
|
||||
"""
|
||||
test_ext_viewcode
|
||||
~~~~~~~~~~~~~~~~~
|
||||
|
||||
Test sphinx.ext.viewcode extension.
|
||||
|
||||
:copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
"""Test sphinx.ext.viewcode extension."""
|
||||
|
||||
import re
|
||||
|
||||
|
||||
@@ -1,12 +1,4 @@
|
||||
"""
|
||||
test_extension
|
||||
~~~~~~~~~~~~~~
|
||||
|
||||
Test sphinx.extesion module.
|
||||
|
||||
:copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
"""Test sphinx.extension module."""
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@@ -1,12 +1,4 @@
|
||||
"""
|
||||
test_highlighting
|
||||
~~~~~~~~~~~~~~~~~
|
||||
|
||||
Test the Pygments highlighting bridge.
|
||||
|
||||
:copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
"""Test the Pygments highlighting bridge."""
|
||||
|
||||
from unittest import mock
|
||||
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
"""
|
||||
test_intl
|
||||
~~~~~~~~~
|
||||
"""Test message patching for internationalization purposes.
|
||||
|
||||
Test message patching for internationalization purposes. Runs the text
|
||||
builder in the test root.
|
||||
|
||||
:copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
Runs the text builder in the test root.
|
||||
"""
|
||||
|
||||
import os
|
||||
@@ -47,7 +41,7 @@ def write_mo(pathname, po):
|
||||
@pytest.fixture(autouse=True)
|
||||
def setup_intl(app_params):
|
||||
srcdir = path(app_params.kwargs['srcdir'])
|
||||
for dirpath, dirs, files in os.walk(srcdir):
|
||||
for dirpath, _dirs, files in os.walk(srcdir):
|
||||
dirpath = path(dirpath)
|
||||
for f in [f for f in files if f.endswith('.po')]:
|
||||
po = dirpath / f
|
||||
@@ -192,6 +186,32 @@ def test_text_inconsistency_warnings(app, warning):
|
||||
assert_re_search(expected_citation_warning_expr, warnings)
|
||||
|
||||
|
||||
@sphinx_intl
|
||||
@pytest.mark.sphinx('text')
|
||||
@pytest.mark.test_params(shared_result='test_intl_basic')
|
||||
def test_noqa(app, warning):
|
||||
app.build()
|
||||
result = (app.outdir / 'noqa.txt').read_text()
|
||||
expect = r"""FIRST SECTION
|
||||
*************
|
||||
|
||||
TRANSLATED TEXT WITHOUT REFERENCE.
|
||||
|
||||
TEST noqa WHITESPACE INSENSITIVITY.
|
||||
|
||||
"#noqa" IS ESCAPED AT THE END OF THIS STRING. #noqa
|
||||
|
||||
|
||||
NEXT SECTION WITH PARAGRAPH TO TEST BARE noqa
|
||||
*********************************************
|
||||
|
||||
Some text, again referring to the section: NEXT SECTION WITH PARAGRAPH
|
||||
TO TEST BARE noqa.
|
||||
"""
|
||||
assert result == expect
|
||||
assert "next-section" not in getwarning(warning)
|
||||
|
||||
|
||||
@sphinx_intl
|
||||
@pytest.mark.sphinx('text')
|
||||
@pytest.mark.test_params(shared_result='test_intl_basic')
|
||||
@@ -241,13 +261,29 @@ def test_text_glossary_term(app, warning):
|
||||
app.build()
|
||||
# --- glossary terms: regression test for #1090
|
||||
result = (app.outdir / 'glossary_terms.txt').read_text()
|
||||
expect = ("18. I18N WITH GLOSSARY TERMS"
|
||||
"\n****************************\n"
|
||||
"\nSOME NEW TERM"
|
||||
"\n THE CORRESPONDING GLOSSARY\n"
|
||||
"\nSOME OTHER NEW TERM"
|
||||
"\n THE CORRESPONDING GLOSSARY #2\n"
|
||||
"\nLINK TO *SOME NEW TERM*.\n")
|
||||
expect = (r"""18. I18N WITH GLOSSARY TERMS
|
||||
****************************
|
||||
|
||||
SOME NEW TERM
|
||||
THE CORRESPONDING GLOSSARY
|
||||
|
||||
SOME OTHER NEW TERM
|
||||
THE CORRESPONDING GLOSSARY #2
|
||||
|
||||
LINK TO *SOME NEW TERM*.
|
||||
|
||||
TRANSLATED GLOSSARY SHOULD BE SORTED BY TRANSLATED TERMS:
|
||||
|
||||
TRANSLATED TERM XXX
|
||||
DEFINE XXX
|
||||
|
||||
TRANSLATED TERM YYY
|
||||
DEFINE YYY
|
||||
|
||||
TRANSLATED TERM ZZZ
|
||||
VVV
|
||||
DEFINE ZZZ
|
||||
""")
|
||||
assert result == expect
|
||||
warnings = getwarning(warning)
|
||||
assert 'term not in glossary' not in warnings
|
||||
@@ -1170,6 +1206,9 @@ def test_additional_targets_should_be_translated(app):
|
||||
"""<span class="c1"># SYS IMPORTING</span>""")
|
||||
assert_count(expected_expr, result, 1)
|
||||
|
||||
# '#noqa' should remain in literal blocks.
|
||||
assert_count("#noqa", result, 1)
|
||||
|
||||
# [raw.txt]
|
||||
|
||||
result = (app.outdir / 'raw.html').read_text()
|
||||
|
||||
@@ -1,12 +1,4 @@
|
||||
"""
|
||||
test_locale
|
||||
~~~~~~~~~~
|
||||
|
||||
Test locale.
|
||||
|
||||
:copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
"""Test locale."""
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@@ -1,12 +1,4 @@
|
||||
"""
|
||||
test_markup
|
||||
~~~~~~~~~~~
|
||||
|
||||
Test various Sphinx-specific markup extensions.
|
||||
|
||||
:copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
"""Test various Sphinx-specific markup extensions."""
|
||||
|
||||
import re
|
||||
|
||||
@@ -17,6 +9,7 @@ from docutils.parsers.rst import Parser as RstParser
|
||||
from sphinx import addnodes
|
||||
from sphinx.builders.html.transforms import KeyboardTransform
|
||||
from sphinx.builders.latex import LaTeXBuilder
|
||||
from sphinx.environment import default_settings
|
||||
from sphinx.roles import XRefRole
|
||||
from sphinx.testing.util import Struct, assert_node
|
||||
from sphinx.transforms import SphinxSmartQuotes
|
||||
@@ -30,13 +23,13 @@ from sphinx.writers.latex import LaTeXTranslator, LaTeXWriter
|
||||
def settings(app):
|
||||
texescape.init() # otherwise done by the latex builder
|
||||
optparser = frontend.OptionParser(
|
||||
components=(RstParser, HTMLWriter, LaTeXWriter))
|
||||
components=(RstParser, HTMLWriter, LaTeXWriter),
|
||||
defaults=default_settings)
|
||||
settings = optparser.get_default_values()
|
||||
settings.smart_quotes = True
|
||||
settings.env = app.builder.env
|
||||
settings.env.temp_data['docname'] = 'dummy'
|
||||
settings.contentsname = 'dummy'
|
||||
settings.rfc_base_url = 'http://datatracker.ietf.org/doc/html/'
|
||||
domain_context = sphinx_domains(settings.env)
|
||||
domain_context.enable()
|
||||
yield settings
|
||||
@@ -67,7 +60,7 @@ def parse(new_document):
|
||||
parser = RstParser()
|
||||
parser.parse(rst, document)
|
||||
SphinxSmartQuotes(document, startnode=None).apply()
|
||||
for msg in document.traverse(nodes.system_message):
|
||||
for msg in list(document.findall(nodes.system_message)):
|
||||
if msg['level'] == 1:
|
||||
msg.replace_self([])
|
||||
return document
|
||||
@@ -157,10 +150,10 @@ def get_verifier(verify, verify_re):
|
||||
'verify',
|
||||
':pep:`8`',
|
||||
('<p><span class="target" id="index-0"></span><a class="pep reference external" '
|
||||
'href="http://www.python.org/dev/peps/pep-0008"><strong>PEP 8</strong></a></p>'),
|
||||
'href="https://peps.python.org/pep-0008/"><strong>PEP 8</strong></a></p>'),
|
||||
('\\sphinxAtStartPar\n'
|
||||
'\\index{Python Enhancement Proposals@\\spxentry{Python Enhancement Proposals}'
|
||||
'!PEP 8@\\spxentry{PEP 8}}\\sphinxhref{http://www.python.org/dev/peps/pep-0008}'
|
||||
'!PEP 8@\\spxentry{PEP 8}}\\sphinxhref{https://peps.python.org/pep-0008/}'
|
||||
'{\\sphinxstylestrong{PEP 8}}')
|
||||
),
|
||||
(
|
||||
@@ -168,12 +161,12 @@ def get_verifier(verify, verify_re):
|
||||
'verify',
|
||||
':pep:`8#id1`',
|
||||
('<p><span class="target" id="index-0"></span><a class="pep reference external" '
|
||||
'href="http://www.python.org/dev/peps/pep-0008#id1">'
|
||||
'href="https://peps.python.org/pep-0008/#id1">'
|
||||
'<strong>PEP 8#id1</strong></a></p>'),
|
||||
('\\sphinxAtStartPar\n'
|
||||
'\\index{Python Enhancement Proposals@\\spxentry{Python Enhancement Proposals}'
|
||||
'!PEP 8\\#id1@\\spxentry{PEP 8\\#id1}}\\sphinxhref'
|
||||
'{http://www.python.org/dev/peps/pep-0008\\#id1}'
|
||||
'{https://peps.python.org/pep-0008/\\#id1}'
|
||||
'{\\sphinxstylestrong{PEP 8\\#id1}}')
|
||||
),
|
||||
(
|
||||
@@ -181,10 +174,10 @@ def get_verifier(verify, verify_re):
|
||||
'verify',
|
||||
':rfc:`2324`',
|
||||
('<p><span class="target" id="index-0"></span><a class="rfc reference external" '
|
||||
'href="http://datatracker.ietf.org/doc/html/rfc2324.html"><strong>RFC 2324</strong></a></p>'),
|
||||
'href="https://datatracker.ietf.org/doc/html/rfc2324.html"><strong>RFC 2324</strong></a></p>'),
|
||||
('\\sphinxAtStartPar\n'
|
||||
'\\index{RFC@\\spxentry{RFC}!RFC 2324@\\spxentry{RFC 2324}}'
|
||||
'\\sphinxhref{http://datatracker.ietf.org/doc/html/rfc2324.html}'
|
||||
'\\sphinxhref{https://datatracker.ietf.org/doc/html/rfc2324.html}'
|
||||
'{\\sphinxstylestrong{RFC 2324}}')
|
||||
),
|
||||
(
|
||||
@@ -192,11 +185,11 @@ def get_verifier(verify, verify_re):
|
||||
'verify',
|
||||
':rfc:`2324#id1`',
|
||||
('<p><span class="target" id="index-0"></span><a class="rfc reference external" '
|
||||
'href="http://datatracker.ietf.org/doc/html/rfc2324.html#id1">'
|
||||
'href="https://datatracker.ietf.org/doc/html/rfc2324.html#id1">'
|
||||
'<strong>RFC 2324#id1</strong></a></p>'),
|
||||
('\\sphinxAtStartPar\n'
|
||||
'\\index{RFC@\\spxentry{RFC}!RFC 2324\\#id1@\\spxentry{RFC 2324\\#id1}}'
|
||||
'\\sphinxhref{http://datatracker.ietf.org/doc/html/rfc2324.html\\#id1}'
|
||||
'\\sphinxhref{https://datatracker.ietf.org/doc/html/rfc2324.html\\#id1}'
|
||||
'{\\sphinxstylestrong{RFC 2324\\#id1}}')
|
||||
),
|
||||
(
|
||||
|
||||
@@ -1,12 +1,4 @@
|
||||
"""
|
||||
test_metadata
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
Test our handling of metadata in files with bibliographic metadata.
|
||||
|
||||
:copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
"""Test our handling of metadata in files with bibliographic metadata."""
|
||||
|
||||
# adapted from an example of bibliographic metadata at
|
||||
# https://docutils.sourceforge.io/docs/user/rst/demo.txt
|
||||
|
||||
@@ -1,12 +1,4 @@
|
||||
"""
|
||||
test_sphinx_parsers
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Tests parsers module.
|
||||
|
||||
:copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
"""Tests parsers module."""
|
||||
|
||||
from unittest.mock import Mock, patch
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user