repo
stringclasses
454 values
file_path
stringlengths
5
201
extension
stringclasses
1 value
content
stringlengths
8
509k
num_lines
int64
3
16.9k
size_bytes
int64
8
511k
sphinx
tests/test_builders/test_build_latex.py
.py
"""Test the build process with LaTeX builder with the test root.""" from __future__ import annotations import http.server import os import re import subprocess from contextlib import chdir from pathlib import Path from shutil import copyfile from subprocess import CalledProcessError from types import NoneType from ty...
2,326
82,814
sphinx
tests/test_builders/test_build_changes.py
.py
"""Test the ChangesBuilder class.""" from __future__ import annotations from typing import TYPE_CHECKING import pytest if TYPE_CHECKING: from sphinx.testing.util import SphinxTestApp @pytest.mark.sphinx('changes', testroot='changes') def test_build(app: SphinxTestApp) -> None: app.build() # TODO: Use...
47
1,355
sphinx
tests/test_builders/test_build_html_download.py
.py
from __future__ import annotations import hashlib import re from typing import TYPE_CHECKING import pytest if TYPE_CHECKING: from sphinx.testing.util import SphinxTestApp @pytest.mark.sphinx('html', testroot='root') def test_html_download(app: SphinxTestApp) -> None: app.build() # subdir/includes.html...
83
2,982
sphinx
tests/test_builders/test_build_html_copyright.py
.py
from __future__ import annotations import time from typing import TYPE_CHECKING import pytest from sphinx.testing.util import SphinxTestApp if TYPE_CHECKING: from collections.abc import Iterator from sphinx.testing.util import SphinxTestApp LT = time.localtime() LT_NEW = (2009, *LT[1:], LT.tm_zone, LT.tm_...
110
3,728
sphinx
tests/test_builders/test_build_html_assets.py
.py
"""Test the HTML builder and check output against XPath.""" from __future__ import annotations import re from pathlib import Path from typing import TYPE_CHECKING import pytest import sphinx.builders.html from sphinx.builders.html._assets import _file_checksum from sphinx.errors import ThemeError if TYPE_CHECKING:...
206
7,555
sphinx
tests/test_builders/test_build_html_toctree.py
.py
"""Test the HTML builder and check output against XPath.""" from __future__ import annotations import re from typing import TYPE_CHECKING from unittest.mock import patch import pytest from sphinx.builders.html import StandaloneHTMLBuilder from tests.test_builders.xpath_html_util import _intradocument_hyperlink_che...
108
4,177
sphinx
tests/test_builders/test_build_texinfo.py
.py
"""Test the build process with Texinfo builder with the test root.""" from __future__ import annotations import re import subprocess from pathlib import Path from subprocess import CalledProcessError from typing import TYPE_CHECKING from unittest.mock import Mock import pytest from sphinx.builders.texinfo import de...
155
5,553
sphinx
tests/test_builders/test_build_all.py
.py
"""Test all builders. This test skips building docs for some builders that have independent testcases. (html, changes, epub, latex, texinfo and manpage) """ from __future__ import annotations import shutil from typing import TYPE_CHECKING from unittest import mock import pytest from sphinx.testing.util import Sphi...
100
2,599
sphinx
tests/test_builders/test_build.py
.py
"""Test all builders.""" from __future__ import annotations from typing import TYPE_CHECKING import pytest from docutils import nodes from sphinx.errors import SphinxError from tests.utils import extract_element, extract_node if TYPE_CHECKING: from collections.abc import Callable from pathlib import Path ...
121
4,249
sphinx
tests/test_builders/test_build_warnings.py
.py
from __future__ import annotations import os import re import sys import traceback from typing import TYPE_CHECKING import pytest from sphinx._cli.util.errors import strip_escape_sequences from sphinx.errors import SphinxError if TYPE_CHECKING: from collections.abc import Callable from pathlib import Path ...
141
4,830
sphinx
tests/test_builders/test_build_dirhtml.py
.py
"""Test dirhtml builder.""" from __future__ import annotations import posixpath from typing import TYPE_CHECKING import pytest from sphinx.util.inventory import InventoryFile, _InventoryItem if TYPE_CHECKING: from sphinx.testing.util import SphinxTestApp @pytest.mark.sphinx('dirhtml', testroot='builder-dirht...
68
2,069
sphinx
tests/test_builders/test_build_gettext.py
.py
"""Test the build process with gettext builder with the test root.""" from __future__ import annotations import gettext import re import subprocess from contextlib import chdir from pathlib import Path from subprocess import CalledProcessError from typing import TYPE_CHECKING import pytest from sphinx.builders.gett...
352
11,272
sphinx
tests/test_builders/test_build_epub.py
.py
"""Test the HTML builder and check output against XPath.""" from __future__ import annotations import os import re import subprocess import xml.etree.ElementTree as ET from collections import Counter from pathlib import Path from subprocess import CalledProcessError from typing import TYPE_CHECKING import pytest fr...
688
23,782
sphinx
tests/test_builders/xpath_html_util.py
.py
from __future__ import annotations from typing import TYPE_CHECKING if TYPE_CHECKING: from collections.abc import Sequence from xml.etree.ElementTree import Element def _intradocument_hyperlink_check(nodes: Sequence[Element]) -> None: """Confirm that a series of nodes are all HTML hyperlinks to the curr...
20
809
sphinx
tests/test_builders/test_build_manpage.py
.py
"""Test the build process with manpage builder with the test root.""" from __future__ import annotations from typing import TYPE_CHECKING import pytest from sphinx.builders.manpage import default_man_pages from sphinx.config import Config if TYPE_CHECKING: from sphinx.testing.util import SphinxTestApp @pytes...
108
2,814
sphinx
tests/test_builders/test_build_html_numfig.py
.py
"""Test the HTML builder and check output against XPath.""" from __future__ import annotations import re from typing import TYPE_CHECKING import pytest from tests.test_builders.xpath_data import FIGURE_CAPTION from tests.test_builders.xpath_util import check_xpath if TYPE_CHECKING: from collections.abc import ...
1,146
35,121
sphinx
tests/test_builders/test_build_html_maths.py
.py
from __future__ import annotations from typing import TYPE_CHECKING import pytest from sphinx.builders.html import StandaloneHTMLBuilder from sphinx.errors import ConfigError if TYPE_CHECKING: from collections.abc import Callable from sphinx.testing.fixtures import _app_params from sphinx.testing.util ...
100
3,006
sphinx
tests/test_builders/test_build_html_tocdepth.py
.py
"""Test the HTML builder and check output against XPath.""" from __future__ import annotations from typing import TYPE_CHECKING import pytest from tests.test_builders.xpath_html_util import _intradocument_hyperlink_check from tests.test_builders.xpath_util import check_xpath if TYPE_CHECKING: from collections....
137
5,492
sphinx
tests/test_builders/test_build_html_code.py
.py
from __future__ import annotations from typing import TYPE_CHECKING import pygments import pytest if TYPE_CHECKING: from sphinx.testing.util import SphinxTestApp @pytest.mark.sphinx( 'html', testroot='reST-code-block', confoverrides={'html_codeblock_linenos_style': 'table'}, ) def test_html_codeblo...
73
2,189
sphinx
tests/test_builders/test_build_html_5_output.py
.py
"""Test the HTML builder and check output against XPath.""" from __future__ import annotations import re from typing import TYPE_CHECKING import pytest from docutils import nodes from tests.test_builders.xpath_util import check_xpath if TYPE_CHECKING: from collections.abc import Callable, Iterable from pat...
568
21,427
sphinx
tests/test_builders/test_build_linkcheck.py
.py
"""Test the build process with manpage builder with the test root.""" from __future__ import annotations import json import re import sys import textwrap import time import wsgiref.handlers from base64 import b64encode from http.server import BaseHTTPRequestHandler from io import StringIO from queue import Queue from...
1,525
49,866
sphinx
tests/test_builders/test_build_text.py
.py
"""Test the build process with Text builder with the test root.""" from __future__ import annotations from typing import TYPE_CHECKING import pytest from docutils.utils import column_width from sphinx.testing.util import SphinxTestApp from sphinx.writers.text import MAXWIDTH, Cell, Table if TYPE_CHECKING: from...
267
8,976
sphinx
tests/test_builders/test_build_html.py
.py
"""Test the HTML builder and check output against XPath.""" from __future__ import annotations import os import posixpath import re from typing import TYPE_CHECKING import pytest from docutils import nodes from docutils.parsers import rst from docutils.readers import standalone from docutils.writers import html5_pol...
852
26,532
sphinx
tests/test_builders/test_build_html_highlight.py
.py
from __future__ import annotations from typing import TYPE_CHECKING from unittest.mock import ANY, call, patch import pytest from sphinx.builders.html import StandaloneHTMLBuilder if TYPE_CHECKING: from sphinx.testing.util import SphinxTestApp @pytest.mark.sphinx('html', testroot='basic', confoverrides={'html...
132
3,797
sphinx
tests/test_builders/conftest.py
.py
from __future__ import annotations from typing import TYPE_CHECKING import pytest from sphinx.testing.util import etree_parse if TYPE_CHECKING: from collections.abc import Callable, Iterator from pathlib import Path from xml.etree.ElementTree import ElementTree _etree_cache: dict[Path, ElementTree] = {...
29
639
sphinx
tests/test_theming/test_theming.py
.py
"""Test the Theme class.""" from __future__ import annotations import shutil from pathlib import Path from typing import TYPE_CHECKING from xml.etree.ElementTree import ParseError import pytest from defusedxml.ElementTree import parse as xml_parse import sphinx.builders.html from sphinx.builders.html import Standal...
269
8,311
sphinx
tests/test_theming/test_templating.py
.py
"""Test templating.""" from __future__ import annotations from typing import TYPE_CHECKING import pytest if TYPE_CHECKING: from collections.abc import Callable from sphinx.testing.fixtures import _app_params from sphinx.testing.util import SphinxTestApp @pytest.mark.sphinx('html', testroot='templatin...
61
1,740
sphinx
tests/test_theming/test_html_theme.py
.py
from __future__ import annotations from typing import TYPE_CHECKING import pytest if TYPE_CHECKING: from sphinx.testing.util import SphinxTestApp @pytest.mark.sphinx('html', testroot='theming') def test_theme_options(app: SphinxTestApp) -> None: app.build() result = (app.outdir / '_static' / 'document...
51
1,447
sphinx
tests/test_extensions/test_ext_graphviz.py
.py
"""Test sphinx.ext.graphviz extension.""" from __future__ import annotations import re import sys from typing import TYPE_CHECKING import pytest from sphinx.ext.graphviz import ClickableMapDefinition if TYPE_CHECKING: from sphinx.testing.util import SphinxTestApp @pytest.mark.sphinx('html', testroot='ext-gra...
221
8,575
sphinx
tests/test_extensions/test_ext_todo.py
.py
"""Test sphinx.ext.todo extension.""" from __future__ import annotations import re from typing import TYPE_CHECKING import pytest if TYPE_CHECKING: from sphinx.application import Sphinx from sphinx.ext.todo import todo_node from sphinx.testing.util import SphinxTestApp @pytest.mark.sphinx( 'html',...
129
3,985
sphinx
tests/test_extensions/test_ext_extlinks.py
.py
from __future__ import annotations from typing import TYPE_CHECKING import pytest if TYPE_CHECKING: from sphinx.testing.util import SphinxTestApp @pytest.mark.sphinx( 'html', testroot='ext-extlinks-hardcoded-urls', confoverrides={'extlinks_detect_hardcoded_links': False}, ) def test_extlinks_detect...
61
2,310
sphinx
tests/test_extensions/test_ext_ifconfig.py
.py
"""Test sphinx.ext.ifconfig extension.""" from __future__ import annotations from typing import TYPE_CHECKING import docutils.utils import pytest from sphinx import addnodes from sphinx.testing import restructuredtext if TYPE_CHECKING: from sphinx.testing.util import SphinxTestApp @pytest.mark.sphinx('text',...
35
1,031
sphinx
tests/test_extensions/test_ext_math.py
.py
"""Test math extensions.""" from __future__ import annotations import re import shutil import subprocess import warnings from typing import TYPE_CHECKING import pytest from docutils import nodes from sphinx.ext.mathjax import MATHJAX_URL from sphinx.testing.util import assert_node from tests.utils import extract_n...
628
18,777
sphinx
tests/test_extensions/test_ext_autosectionlabel.py
.py
"""Test sphinx.ext.autosectionlabel extension.""" from __future__ import annotations import re from typing import TYPE_CHECKING import pytest if TYPE_CHECKING: from sphinx.testing.util import SphinxTestApp @pytest.mark.sphinx('html', testroot='ext-autosectionlabel') def test_autosectionlabel_html(app: SphinxT...
108
3,457
sphinx
tests/test_extensions/test_ext_viewcode.py
.py
"""Test sphinx.ext.viewcode extension.""" from __future__ import annotations import re import shutil from typing import TYPE_CHECKING import pygments import pytest if TYPE_CHECKING: from sphinx.application import Sphinx from sphinx.testing.util import SphinxTestApp def check_viewcode_output(app: SphinxTes...
196
6,912
sphinx
tests/test_extensions/test_ext_doctest.py
.py
"""Test the doctest extension.""" from __future__ import annotations import os from collections import Counter from typing import TYPE_CHECKING import pytest from docutils import nodes from packaging.specifiers import InvalidSpecifier from packaging.version import InvalidVersion from sphinx.ext.doctest import DocTe...
204
7,501
sphinx
tests/test_extensions/test_ext_apidoc.py
.py
"""Test the sphinx.apidoc module.""" from __future__ import annotations from collections import namedtuple from typing import TYPE_CHECKING import pytest import sphinx.ext.apidoc._generate from sphinx.ext.apidoc._cli import main as apidoc_main if TYPE_CHECKING: from pathlib import Path from sphinx.testing...
801
24,742
sphinx
tests/test_extensions/test_ext_inheritance_diagram.py
.py
"""Test sphinx.ext.inheritance_diagram extension.""" from __future__ import annotations import re import sys import zlib from pathlib import Path from typing import TYPE_CHECKING import pytest from docutils import nodes from sphinx.ext.inheritance_diagram import ( InheritanceDiagram, InheritanceException, ...
387
14,626
sphinx
tests/test_extensions/test_ext_duration.py
.py
"""Test sphinx.ext.duration extension.""" from __future__ import annotations import json import re from pathlib import Path from typing import TYPE_CHECKING import pytest if TYPE_CHECKING: from sphinx.testing.util import SphinxTestApp @pytest.mark.sphinx( 'dummy', testroot='basic', confoverrides={...
163
4,285
sphinx
tests/test_extensions/test_ext_githubpages.py
.py
"""Test sphinx.ext.githubpages extension.""" from __future__ import annotations from typing import TYPE_CHECKING import pytest from sphinx.testing.util import SphinxTestApp if TYPE_CHECKING: from sphinx.testing.util import SphinxTestApp @pytest.mark.sphinx('html', testroot='ext-githubpages') def test_githubp...
42
1,158
sphinx
tests/test_extensions/test_ext_coverage.py
.py
"""Test the coverage builder.""" from __future__ import annotations import pickle from typing import TYPE_CHECKING import pytest if TYPE_CHECKING: from sphinx.testing.util import SphinxTestApp @pytest.mark.sphinx('coverage', testroot='root') def test_build(app: SphinxTestApp) -> None: app.build(force_all=...
132
4,252
sphinx
tests/test_extensions/test_extension.py
.py
"""Test sphinx.extension module.""" from __future__ import annotations from typing import TYPE_CHECKING import pytest from sphinx.errors import VersionRequirementError from sphinx.extension import Extension, verify_needs_extensions if TYPE_CHECKING: from sphinx.testing.util import SphinxTestApp @pytest.mark....
36
1,092
sphinx
tests/test_ext_imgconverter/test_ext_imgmockconverter.py
.py
"""Test image converter with identical basenames""" from __future__ import annotations from typing import TYPE_CHECKING import pytest if TYPE_CHECKING: from sphinx.testing.util import SphinxTestApp @pytest.mark.sphinx('latex', testroot='ext-imgmockconverter') def test_ext_imgmockconverter(app: SphinxTestApp) ...
25
767
sphinx
tests/test_ext_imgconverter/test_ext_imgconverter.py
.py
"""Test sphinx.ext.imgconverter extension.""" from __future__ import annotations import subprocess from typing import TYPE_CHECKING import pytest if TYPE_CHECKING: from sphinx.testing.util import SphinxTestApp @pytest.fixture def _if_converter_found(app: SphinxTestApp) -> None: image_converter = getattr(a...
46
1,364
sphinx
tests/test_transforms/test_transforms_post_transforms_code.py
.py
from __future__ import annotations from typing import TYPE_CHECKING import pytest if TYPE_CHECKING: from sphinx.testing.util import SphinxTestApp @pytest.mark.sphinx('html', testroot='trim_doctest_flags') def test_trim_doctest_flags_html(app: SphinxTestApp) -> None: app.build() result = (app.outdir / ...
57
1,648
sphinx
tests/test_transforms/test_transforms_post_transforms_images.py
.py
from __future__ import annotations from types import SimpleNamespace from typing import TYPE_CHECKING from docutils import nodes from sphinx.transforms.post_transforms.images import ImageConverter from sphinx.util.docutils import new_document if TYPE_CHECKING: from pathlib import Path WEBP_DATA = ( b'RIFF\...
53
2,373
sphinx
tests/test_transforms/test_transforms_post_transforms.py
.py
"""Tests the post_transforms""" from __future__ import annotations import logging from typing import TYPE_CHECKING import pytest from docutils import nodes from sphinx import addnodes from sphinx.addnodes import SIG_ELEMENTS from sphinx.testing.util import SphinxTestApp, assert_node from sphinx.transforms.post_tran...
332
12,686
sphinx
tests/test_transforms/test_transforms_move_module_targets.py
.py
from __future__ import annotations from typing import TYPE_CHECKING import pytest from docutils import nodes from sphinx import addnodes from sphinx.testing.util import SphinxTestApp from sphinx.transforms import MoveModuleTargets if TYPE_CHECKING: from pathlib import Path CONTENT_PY = """\ move-module-targets...
90
2,828
sphinx
tests/test_transforms/test_unreferenced_footnotes.py
.py
"""Test the ``UnreferencedFootnotesDetector`` transform.""" from __future__ import annotations from typing import TYPE_CHECKING from sphinx._cli.util.errors import strip_escape_sequences from sphinx.testing.util import SphinxTestApp if TYPE_CHECKING: from pathlib import Path from sphinx.testing.util import...
51
1,698
sphinx
tests/test_transforms/test_transforms_reorder_nodes.py
.py
"""Tests the transformations""" from __future__ import annotations from typing import TYPE_CHECKING import pytest from docutils import nodes from sphinx import addnodes from sphinx.testing import restructuredtext from sphinx.testing.util import assert_node if TYPE_CHECKING: from sphinx.testing.util import Sphi...
148
4,386
sphinx
tests/test_ext_autodoc/test_ext_autodoc_names.py
.py
"""Test the autodoc extension. This mainly tests name resolution & parsing.""" from __future__ import annotations import logging from sphinx.environment import _CurrentDocument from sphinx.ext.autodoc._names import _parse_name TYPE_CHECKING = False if TYPE_CHECKING: from collections.abc import Mapping from...
101
3,613
sphinx
tests/test_ext_autodoc/test_ext_autodoc_events.py
.py
"""Test the autodoc extension. This tests mainly for autodoc events""" from __future__ import annotations from typing import TYPE_CHECKING import pytest from sphinx.ext.autodoc import between, cut_lines from tests.test_ext_autodoc.autodoc_util import FakeEvents, do_autodoc if TYPE_CHECKING: from typing impor...
172
4,364
sphinx
tests/test_ext_autodoc/test_ext_autodoc_importer.py
.py
from __future__ import annotations import sys from pathlib import Path from sphinx.ext.autodoc._dynamic._importer import _import_module def test_import_native_module_stubs(rootdir: Path) -> None: fish_licence_root = rootdir / 'test-ext-apidoc-duplicates' sys_path = list(sys.path) sys.path.insert(0, str...
23
698
sphinx
tests/test_ext_autodoc/test_ext_autodoc_autofunction.py
.py
"""Test the autodoc extension. This tests mainly the Documenters; the auto directives are tested in a test source file translated by test_build. """ from __future__ import annotations import pytest from tests.test_ext_autodoc.autodoc_util import do_autodoc pytestmark = pytest.mark.usefixtures('inject_autodoc_root_...
202
5,231
sphinx
tests/test_ext_autodoc/test_ext_autodoc_signatures.py
.py
"""Test the autodoc extension. This mainly tests the signature utilities.""" from __future__ import annotations from typing import Generic, TypeVar import pytest from sphinx.ext.autodoc._directive_options import _AutoDocumenterOptions from sphinx.ext.autodoc._dynamic._docstrings import _get_docstring_lines from sp...
358
10,935
sphinx
tests/test_ext_autodoc/test_ext_autodoc_private_members.py
.py
"""Test the autodoc extension. This tests mainly for private-members option.""" from __future__ import annotations import pytest from sphinx.ext.autodoc._shared import _AutodocConfig from tests.test_ext_autodoc.autodoc_util import do_autodoc pytestmark = pytest.mark.usefixtures('inject_autodoc_root_into_sys_path'...
165
4,507
sphinx
tests/test_ext_autodoc/test_ext_autodoc_typehints.py
.py
"""Test the autodoc extension.""" from __future__ import annotations from contextlib import contextmanager from typing import TYPE_CHECKING import pytest from sphinx.ext.autodoc._shared import _AutodocConfig from sphinx.testing import restructuredtext from tests.test_ext_autodoc.autodoc_util import do_autodoc if ...
843
25,064
sphinx
tests/test_ext_autodoc/test_ext_autodoc_autoattribute.py
.py
"""Test the autodoc extension. This tests mainly the Documenters; the auto directives are tested in a test source file translated by test_build. """ from __future__ import annotations import pytest from tests.test_ext_autodoc.autodoc_util import do_autodoc pytestmark = pytest.mark.usefixtures('inject_autodoc_root_...
169
4,231
sphinx
tests/test_ext_autodoc/autodoc_util.py
.py
from __future__ import annotations from types import SimpleNamespace from typing import TYPE_CHECKING from sphinx.environment import _CurrentDocument from sphinx.events import EventManager from sphinx.ext.autodoc._directive_options import _process_documenter_options from sphinx.ext.autodoc._generate import _auto_docu...
84
2,539
sphinx
tests/test_ext_autodoc/test_ext_autodoc_mock.py
.py
"""Test the autodoc extension.""" from __future__ import annotations import abc import sys from importlib import import_module from typing import Generic, TypeVar import pytest from sphinx.ext.autodoc._dynamic._mock import ( _MockModule, _MockObject, ismock, mock, undecorate, ) def test_MockMo...
190
5,264
sphinx
tests/test_ext_autodoc/test_ext_autodoc_preserve_defaults.py
.py
"""Test the autodoc extension.""" from __future__ import annotations import pytest from sphinx.ext.autodoc._shared import _AutodocConfig from tests.test_ext_autodoc.autodoc_util import do_autodoc pytestmark = pytest.mark.usefixtures('inject_autodoc_root_into_sys_path') def test_preserve_defaults() -> None: c...
205
6,289
sphinx
tests/test_ext_autodoc/test_ext_autodoc.py
.py
"""Test the autodoc extension. This tests mainly the Documenters; the auto directives are tested in a test source file translated by test_build. """ from __future__ import annotations import itertools import logging import pathlib import sys from typing import TYPE_CHECKING from warnings import catch_warnings impor...
3,222
99,802
sphinx
tests/test_ext_autodoc/test_ext_autodoc_autoclass.py
.py
"""Test the autodoc extension. This tests mainly the Documenters; the auto directives are tested in a test source file translated by test_build. """ from __future__ import annotations import sys import typing import pytest from tests.test_ext_autodoc.autodoc_util import FakeEvents, do_autodoc TYPE_CHECKING = Fals...
589
15,344
sphinx
tests/test_ext_autodoc/test_ext_autodoc_configs.py
.py
"""Test the autodoc extension. This tests mainly for config variables""" from __future__ import annotations import logging import platform import sys import pytest from sphinx.ext.autodoc._shared import _AutodocConfig from tests.test_ext_autodoc.autodoc_util import do_autodoc pytestmark = pytest.mark.usefixtures...
1,010
31,126
sphinx
tests/test_ext_autodoc/test_ext_autodoc_automodule.py
.py
"""Test the autodoc extension. This tests mainly the Documenters; the auto directives are tested in a test source file translated by test_build. """ from __future__ import annotations import inspect import sys import typing import pytest from sphinx.ext.autodoc._dynamic._mock import _MockObject from sphinx.ext.aut...
240
6,409
sphinx
tests/test_ext_autodoc/test_ext_autodoc_autodata.py
.py
"""Test the autodoc extension. This tests mainly the Documenters; the auto directives are tested in a test source file translated by test_build. """ from __future__ import annotations import pytest from tests.test_ext_autodoc.autodoc_util import do_autodoc pytestmark = pytest.mark.usefixtures('inject_autodoc_root_...
105
2,409
sphinx
tests/test_ext_autodoc/test_ext_autodoc_autoproperty.py
.py
"""Test the autodoc extension. This tests mainly the Documenters; the auto directives are tested in a test source file translated by test_build. """ from __future__ import annotations import sys import pytest from tests.test_ext_autodoc.autodoc_util import do_autodoc pytestmark = pytest.mark.usefixtures('inject_a...
112
2,846
sphinx
tests/test_ext_autodoc/conftest.py
.py
from __future__ import annotations import sys import pytest from tests.utils import TEST_ROOTS_DIR TYPE_CHECKING = False if TYPE_CHECKING: from collections.abc import Iterator @pytest.fixture(scope='module') def inject_autodoc_root_into_sys_path() -> Iterator[None]: autodoc_root_path = str(TEST_ROOTS_DIR ...
21
461
sphinx
doc/conf.py
.py
# Sphinx documentation build configuration file from __future__ import annotations import os import re from typing import TYPE_CHECKING from sphinx import __display_version__ os.environ['SPHINX_AUTODOC_RELOAD_MODULES'] = '1' extensions = [ 'sphinx.ext.autodoc', 'sphinx.ext.doctest', 'sphinx.ext.todo', ...
373
13,387
sphinx
doc/usage/extensions/example_google.py
.py
"""Example Google style docstrings. This module demonstrates documentation as specified by the `Google Python Style Guide`_. Docstrings may extend over multiple lines. Sections are created with a section header and a colon followed by a block of indented text. Example: Examples can be given using either the ``Exa...
312
9,689
sphinx
doc/usage/extensions/example_numpy.py
.py
"""Example NumPy style docstrings. This module demonstrates documentation as specified by the `NumPy Documentation HOWTO`_. Docstrings may extend over multiple lines. Sections are created with a section header followed by an underline of equal length. Example ------- Examples can be given using either the ``Example``...
352
9,737
sphinx
doc/development/tutorials/examples/recipe.py
.py
from collections import defaultdict from docutils.parsers.rst import directives from sphinx import addnodes from sphinx.application import Sphinx from sphinx.directives import ObjectDescription from sphinx.domains import Domain, Index from sphinx.roles import XRefRole from sphinx.util.nodes import make_refnode from s...
182
5,439
sphinx
doc/development/tutorials/examples/autodoc_intenum.py
.py
from __future__ import annotations from enum import IntEnum from typing import TYPE_CHECKING from sphinx.ext.autodoc import ClassDocumenter, Documenter, bool_option if TYPE_CHECKING: from typing import Any from docutils.statemachine import StringList from sphinx.application import Sphinx from sphin...
64
1,920
sphinx
doc/development/tutorials/examples/todo.py
.py
from docutils import nodes from docutils.parsers.rst import Directive from sphinx.application import Sphinx from sphinx.locale import _ from sphinx.util.docutils import SphinxDirective from sphinx.util.typing import ExtensionMetadata class todo(nodes.Admonition, nodes.Element): pass class todolist(nodes.Genera...
143
4,070
sphinx
doc/development/tutorials/examples/helloworld.py
.py
from __future__ import annotations from docutils import nodes from sphinx.application import Sphinx from sphinx.util.docutils import SphinxDirective, SphinxRole from sphinx.util.typing import ExtensionMetadata class HelloRole(SphinxRole): """A role to say hello!""" def run(self) -> tuple[list[nodes.Node], ...
37
937
sphinx
utils/generate_snowball.py
.py
#!/usr/bin/env python3 """Refresh and update language stemming data from the Snowball project.""" # /// script # requires-python = ">=3.12" # dependencies = [ # "requests>=2.30", # ] # /// from __future__ import annotations import hashlib import shutil import subprocess import sys import tarfile import tempfile...
139
5,021
sphinx
utils/bump_version.py
.py
#!/usr/bin/env python3 from __future__ import annotations import argparse import dataclasses import re import sys import time from contextlib import contextmanager from pathlib import Path from typing import TYPE_CHECKING if TYPE_CHECKING: from collections.abc import Iterator, Sequence from typing import Lit...
210
6,574
sphinx
utils/bump_docker.py
.py
#!/usr/bin/env python3 """Usage: bump_docker.py [VERSION]""" from __future__ import annotations import re import subprocess import sys from pathlib import Path VERSION_PATTERN = r'\d+\.\d+\.\d+' if not sys.argv[1:] or re.match(VERSION_PATTERN, sys.argv[1]) is None: print(__doc__) raise SystemExit(1) VERSI...
58
1,503
sphinx
utils/convert_attestations.py
.py
"""Convert Sigstore attestations to PEP 740. See https://github.com/trailofbits/pypi-attestations. """ # /// script # requires-python = ">=3.12" # dependencies = [ # "pypi-attestations==0.0.28", # ] # /// from __future__ import annotations import json import sys from base64 import b64decode from pathlib import ...
51
1,672
sphinx
utils/babel_runner.py
.py
"""Run babel for translations. Usage: babel_runner.py extract Extract messages from the source code and update the ".pot" template file. babel_runner.py update Update all language catalogues in "sphinx/locale/<language>/LC_MESSAGES" with the current messages in the template file. babel_runner.py compile...
301
9,471
sphinx
utils/generate_js_fixtures.py
.py
#!/usr/bin/env python3 from __future__ import annotations import shutil import subprocess from pathlib import Path SPHINX_ROOT = Path(__file__).resolve().parent.parent TEST_JS_FIXTURES = SPHINX_ROOT / 'tests' / 'js' / 'fixtures' TEST_JS_ROOTS = [ directory for directory in (SPHINX_ROOT / 'tests' / 'js' / 'roo...
41
1,071
sphinx
sphinx/highlighting.py
.py
"""Highlight code blocks using Pygments.""" from __future__ import annotations from functools import partial from importlib import import_module from typing import TYPE_CHECKING import pygments from pygments import highlight from pygments.filters import ErrorToken from pygments.formatters import HtmlFormatter, Latex...
238
7,855
sphinx
sphinx/errors.py
.py
"""Contains SphinxError and a few subclasses.""" from __future__ import annotations class SphinxError(Exception): """Base class for Sphinx errors. This is the base class for "nice" exceptions. When such an exception is raised, Sphinx will abort the build and present the exception category and messa...
140
3,413
sphinx
sphinx/io.py
.py
"""Input/Output files""" from __future__ import annotations import warnings from typing import TYPE_CHECKING from docutils.io import FileInput from docutils.readers import standalone from docutils.transforms.references import DanglingReferences from docutils.writers import UnfilteredWriter from sphinx.deprecation i...
157
4,662
sphinx
sphinx/extension.py
.py
"""Utilities for Sphinx extensions.""" from __future__ import annotations from typing import TYPE_CHECKING from packaging.version import InvalidVersion, Version from sphinx.errors import VersionRequirementError from sphinx.locale import __ from sphinx.util import logging if TYPE_CHECKING: from typing import An...
95
3,192
sphinx
sphinx/application.py
.py
"""Sphinx application class and extensibility interface. Gracefully adapted from the TextPress system by Armin. """ from __future__ import annotations import contextlib import pickle import sys from collections import deque from io import StringIO from pathlib import Path from typing import TYPE_CHECKING, overload ...
1,894
68,593
sphinx
sphinx/addnodes.py
.py
"""Document tree nodes that Sphinx defines on top of those in Docutils.""" from __future__ import annotations from typing import TYPE_CHECKING from docutils import nodes from docutils.nodes import document # NoQA: F401 if TYPE_CHECKING: from collections.abc import Sequence from typing import Any from ...
625
18,539
sphinx
sphinx/__main__.py
.py
"""The Sphinx documentation toolchain.""" from __future__ import annotations import sys from sphinx.cmd.build import main raise SystemExit(main(sys.argv[1:]))
10
163
sphinx
sphinx/__init__.py
.py
"""The Sphinx documentation toolchain.""" # Keep this file executable as-is in Python 3! # (Otherwise getting the version out of it when packaging is impossible.) from __future__ import annotations from sphinx.util._pathlib import _StrPath TYPE_CHECKING = False if TYPE_CHECKING: from typing import Final __vers...
49
1,423
sphinx
sphinx/registry.py
.py
"""Sphinx component registry.""" from __future__ import annotations import traceback from importlib import import_module from importlib.metadata import entry_points from types import MethodType from typing import TYPE_CHECKING from sphinx.domains import ObjType from sphinx.domains.std import GenericObject, Target fr...
628
24,305
sphinx
sphinx/roles.py
.py
"""Handlers for additional ReST roles.""" from __future__ import annotations import re from typing import TYPE_CHECKING import docutils.parsers.rst.directives import docutils.parsers.rst.states from docutils import nodes, utils from sphinx import addnodes from sphinx.locale import _, __ from sphinx.util import ws_r...
650
22,497
sphinx
sphinx/project.py
.py
"""Utility function and classes for Sphinx projects.""" from __future__ import annotations import contextlib import os from pathlib import Path from typing import TYPE_CHECKING from sphinx.locale import __ from sphinx.util import logging from sphinx.util._pathlib import _StrPath from sphinx.util.matching import get_...
129
4,539
sphinx
sphinx/theming.py
.py
"""Theming support for HTML builders.""" from __future__ import annotations __all__ = ('Theme', 'HTMLThemeFactory') import configparser import contextlib import shutil import sys import tempfile import tomllib import warnings from importlib.metadata import entry_points from pathlib import Path from typing import TYP...
580
20,794
sphinx
sphinx/parsers.py
.py
"""A Base class for additional parsers.""" from __future__ import annotations from typing import TYPE_CHECKING import docutils.parsers import docutils.parsers.rst from docutils.parsers.rst import states from docutils.statemachine import StringList from docutils.transforms.universal import SmartQuotes from sphinx.de...
116
3,877
sphinx
sphinx/jinja2glue.py
.py
"""Glue code for the jinja2 templating engine.""" from __future__ import annotations import os from pathlib import Path from pprint import pformat from typing import TYPE_CHECKING from jinja2 import BaseLoader, FileSystemLoader, TemplateNotFound from jinja2.sandbox import SandboxedEnvironment from jinja2.utils impor...
253
8,356
sphinx
sphinx/config.py
.py
"""Build configuration file handling.""" from __future__ import annotations import time import traceback import types from contextlib import chdir from os import getenv from pathlib import Path from typing import TYPE_CHECKING, Any, Literal, NamedTuple from sphinx.errors import ConfigError, ExtensionError from sphin...
915
34,669
sphinx
sphinx/deprecation.py
.py
"""Sphinx deprecation classes and utilities.""" from __future__ import annotations import os import warnings class RemovedInSphinx10Warning(DeprecationWarning): pass class RemovedInSphinx11Warning(PendingDeprecationWarning): pass RemovedInNextVersionWarning = RemovedInSphinx10Warning # By default, all...
90
2,777
sphinx
sphinx/versioning.py
.py
"""Implements the low-level algorithms Sphinx uses for versioning doctrees.""" from __future__ import annotations import pickle from itertools import product, zip_longest from operator import itemgetter from typing import TYPE_CHECKING from uuid import uuid4 from sphinx.transforms import SphinxTransform if TYPE_CHE...
185
6,251
sphinx
sphinx/events.py
.py
"""Sphinx core events. Gracefully adapted from the TextPress system by Armin. """ from __future__ import annotations from collections import defaultdict from operator import attrgetter from typing import TYPE_CHECKING, NamedTuple, overload from sphinx.deprecation import _deprecation_warning from sphinx.errors impor...
486
13,890
sphinx
sphinx/pygments_styles.py
.py
"""Sphinx theme specific highlighting styles.""" from __future__ import annotations from pygments.style import Style from pygments.styles.friendly import FriendlyStyle from pygments.token import ( Comment, Error, Generic, Keyword, Name, Number, Operator, String, Whitespace, ) cla...
96
2,607