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 | sphinx/environment/collectors/metadata.py | .py | """The metadata collector components for sphinx.environment."""
from __future__ import annotations
from typing import TYPE_CHECKING, cast
from docutils import nodes
from sphinx.environment.collectors import EnvironmentCollector
if TYPE_CHECKING:
from collections.abc import Set
from sphinx.application impo... | 79 | 2,820 |
sphinx | sphinx/environment/collectors/__init__.py | .py | """The data collector components for sphinx.environment."""
from __future__ import annotations
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from collections.abc import Set
from docutils import nodes
from sphinx.application import Sphinx
from sphinx.environment import BuildEnvironment
class ... | 103 | 3,219 |
sphinx | sphinx/environment/collectors/dependencies.py | .py | """The dependencies collector components for sphinx.environment."""
from __future__ import annotations
from pathlib import Path
from typing import TYPE_CHECKING
from sphinx.environment.collectors import EnvironmentCollector
from sphinx.util.osutil import _relative_path, fs_encoding
if TYPE_CHECKING:
from collec... | 61 | 1,876 |
sphinx | sphinx/environment/collectors/asset.py | .py | """The image collector for sphinx.environment."""
from __future__ import annotations
import os
import os.path
from glob import glob
from pathlib import Path
from typing import TYPE_CHECKING
from docutils import nodes
from sphinx import addnodes
from sphinx.environment.collectors import EnvironmentCollector
from sph... | 186 | 6,925 |
sphinx | sphinx/environment/collectors/toctree.py | .py | """Toctree collector for sphinx.environment."""
from __future__ import annotations
from typing import TYPE_CHECKING, cast
from docutils import nodes
from sphinx import addnodes
from sphinx.domains.std import StandardDomain
from sphinx.environment.adapters.toctree import note_toctree
from sphinx.environment.collecto... | 400 | 17,543 |
sphinx | sphinx/environment/adapters/asset.py | .py | """Assets adapter for sphinx.environment."""
from __future__ import annotations
from typing import TYPE_CHECKING
from sphinx.util._pathlib import _StrPath
if TYPE_CHECKING:
from sphinx.environment import BuildEnvironment
class ImageAdapter:
def __init__(self, env: BuildEnvironment) -> None:
self.e... | 23 | 573 |
sphinx | sphinx/environment/adapters/toctree.py | .py | """Toctree adapter for sphinx.environment."""
from __future__ import annotations
import warnings
from typing import TYPE_CHECKING
from docutils import nodes
from docutils.nodes import Element
from sphinx import addnodes
from sphinx.deprecation import RemovedInSphinx11Warning
from sphinx.locale import __
from sphinx... | 625 | 20,457 |
sphinx | sphinx/environment/adapters/indexentries.py | .py | """Index entries adapters for sphinx.environment."""
from __future__ import annotations
import re
import unicodedata
from itertools import groupby
from typing import TYPE_CHECKING
from sphinx.errors import NoUri
from sphinx.locale import _, __
from sphinx.util import logging
from sphinx.util.index_entries import _sp... | 268 | 9,688 |
sphinx | sphinx/transforms/references.py | .py | """Docutils transforms used by Sphinx."""
from __future__ import annotations
from typing import TYPE_CHECKING
from docutils.transforms.references import DanglingReferences
from sphinx.transforms import SphinxTransform
if TYPE_CHECKING:
from typing import Any
from sphinx.application import Sphinx
from ... | 53 | 1,438 |
sphinx | sphinx/transforms/i18n.py | .py | """Docutils transforms used by Sphinx when reading documents."""
from __future__ import annotations
from operator import attrgetter
from re import DOTALL, match
from textwrap import indent
from typing import TYPE_CHECKING, Any
import docutils.utils
from docutils import nodes
from sphinx import addnodes
from sphinx.... | 721 | 28,201 |
sphinx | sphinx/transforms/__init__.py | .py | """Docutils transforms used by Sphinx when reading documents."""
from __future__ import annotations
import re
import unicodedata
from typing import TYPE_CHECKING, cast
from docutils import nodes
from docutils.transforms import Transform, Transformer
from docutils.transforms.parts import ContentsFilter
from docutils.... | 540 | 18,811 |
sphinx | sphinx/transforms/compact_bullet_list.py | .py | """Docutils transforms used by Sphinx when reading documents."""
from __future__ import annotations
from typing import TYPE_CHECKING, cast
from docutils import nodes
from sphinx import addnodes
from sphinx.transforms import SphinxTransform
if TYPE_CHECKING:
from typing import Any
from docutils.nodes impor... | 95 | 2,861 |
sphinx | sphinx/transforms/post_transforms/__init__.py | .py | """Docutils transforms used by Sphinx."""
from __future__ import annotations
import re
from itertools import starmap
from typing import TYPE_CHECKING, cast
from docutils import nodes
from sphinx import addnodes
from sphinx.errors import NoUri
from sphinx.locale import __
from sphinx.transforms import SphinxTransfor... | 404 | 14,445 |
sphinx | sphinx/transforms/post_transforms/images.py | .py | """Docutils transforms used by Sphinx."""
from __future__ import annotations
import os
import re
from hashlib import sha1
from math import ceil
from pathlib import Path
from typing import TYPE_CHECKING
from docutils import nodes
from sphinx.locale import __
from sphinx.transforms import SphinxTransform
from sphinx.... | 303 | 10,845 |
sphinx | sphinx/transforms/post_transforms/code.py | .py | """transforms for code-blocks."""
from __future__ import annotations
import sys
from typing import TYPE_CHECKING, NamedTuple
from docutils import nodes
from pygments.lexers import PythonConsoleLexer, guess_lexer
from sphinx import addnodes
from sphinx.ext import doctest
from sphinx.transforms import SphinxTransform... | 144 | 4,534 |
sphinx | sphinx/util/docutils.py | .py | """Utility functions for docutils."""
from __future__ import annotations
import os
import re
import warnings
from contextlib import contextmanager, nullcontext
from copy import copy
from pathlib import Path
from typing import TYPE_CHECKING
import docutils
import docutils.frontend
import docutils.writers
from docutil... | 952 | 31,825 |
sphinx | sphinx/util/rst.py | .py | """reStructuredText helper functions."""
from __future__ import annotations
import re
from collections import defaultdict
from contextlib import contextmanager
from typing import TYPE_CHECKING
from unicodedata import east_asian_width
from docutils.parsers.rst import roles
from docutils.parsers.rst.languages import e... | 116 | 3,500 |
sphinx | sphinx/util/inventory.py | .py | """Inventory utility functions for Sphinx."""
from __future__ import annotations
import posixpath
import re
import warnings
import zlib
from typing import TYPE_CHECKING
from sphinx.deprecation import RemovedInSphinx10Warning
from sphinx.locale import __
from sphinx.util import logging
BUFSIZE = 16 * 1024
logger = l... | 333 | 12,533 |
sphinx | sphinx/util/template.py | .py | """Templates utility functions for Sphinx."""
from __future__ import annotations
import os
from functools import partial
from pathlib import Path
from typing import TYPE_CHECKING
from jinja2 import TemplateNotFound
from jinja2.loaders import BaseLoader
from jinja2.sandbox import SandboxedEnvironment
from sphinx imp... | 164 | 5,365 |
sphinx | sphinx/util/logging.py | .py | """Logging utility functions for Sphinx."""
from __future__ import annotations
import logging
import logging.handlers
import os.path
from collections import defaultdict
from contextlib import contextmanager, nullcontext
from typing import TYPE_CHECKING
from docutils import nodes
from docutils.utils import get_source... | 647 | 19,746 |
sphinx | sphinx/util/display.py | .py | from __future__ import annotations
import functools
from sphinx._cli.util.colour import bold, terminal_supports_colour
from sphinx.locale import __
from sphinx.util import logging
TYPE_CHECKING = False
if TYPE_CHECKING:
from collections.abc import Callable, Iterable, Iterator
from types import TracebackType
... | 96 | 3,050 |
sphinx | sphinx/util/http_date.py | .py | """Convert times to and from HTTP-date serialisations.
Reference: https://www.rfc-editor.org/rfc/rfc7231#section-7.1.1.1
"""
from __future__ import annotations
import time
from email.utils import parsedate_tz
_WEEKDAY_NAME = ('Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun')
_MONTH_NAME = ('', # Placeholder for ind... | 46 | 1,508 |
sphinx | sphinx/util/_io.py | .py | from __future__ import annotations
from typing import TYPE_CHECKING
from sphinx._cli.util.errors import strip_escape_sequences
if TYPE_CHECKING:
from typing import Protocol
class SupportsWrite(Protocol):
def write(self, text: str, /) -> int | None: ...
class TeeStripANSI:
"""File-like object w... | 34 | 950 |
sphinx | sphinx/util/_inventory_file_reader.py | .py | from __future__ import annotations
import zlib
from typing import TYPE_CHECKING
from sphinx.util import logging
BUFSIZE = 16 * 1024
logger = logging.getLogger(__name__)
if TYPE_CHECKING:
from collections.abc import Iterator
from typing import Protocol
# Readable file stream for inventory loading
cl... | 77 | 2,027 |
sphinx | sphinx/util/_files.py | .py | from __future__ import annotations
import hashlib
from pathlib import Path
from typing import TYPE_CHECKING
from sphinx.util._pathlib import _StrPath
if TYPE_CHECKING:
import os
from collections.abc import Set
class FilenameUniqDict(dict[str, tuple[set[str], str]]): # NoQA: FURB189
"""A dictionary tha... | 97 | 3,152 |
sphinx | sphinx/util/_pathlib.py | .py | """What follows is awful and will be gone in Sphinx 10.
Instances of _StrPath should not be constructed except in Sphinx itself.
Consumers of Sphinx APIs should prefer using ``pathlib.Path`` objects
where possible. _StrPath objects can be treated as equivalent to ``Path``,
save that ``_StrPath.replace`` is overridden ... | 182 | 6,711 |
sphinx | sphinx/util/nodes.py | .py | """Docutils node-related utility functions for Sphinx."""
from __future__ import annotations
import contextlib
import re
import unicodedata
from io import StringIO
from typing import TYPE_CHECKING, Any, cast
from docutils import nodes
from docutils.nodes import Node
from sphinx import addnodes
from sphinx.locale im... | 785 | 26,552 |
sphinx | sphinx/util/parallel.py | .py | """Parallel building utilities."""
from __future__ import annotations
import os
import time
import traceback
from math import sqrt
from typing import TYPE_CHECKING
try:
import multiprocessing
HAS_MULTIPROCESSING = True
except ImportError:
HAS_MULTIPROCESSING = False
from sphinx.errors import SphinxPara... | 170 | 5,649 |
sphinx | sphinx/util/i18n.py | .py | """Builder superclass for all builders."""
from __future__ import annotations
import os
import os.path
import re
from datetime import datetime
from typing import TYPE_CHECKING
import babel.dates
from babel.messages.mofile import write_mo
from babel.messages.pofile import read_po
from sphinx.errors import SphinxErro... | 344 | 11,917 |
sphinx | sphinx/util/fileutil.py | .py | """File utility functions for Sphinx."""
from __future__ import annotations
import os
import posixpath
from pathlib import Path
from typing import TYPE_CHECKING
from sphinx.locale import __
from sphinx.util import logging
from sphinx.util.osutil import _relative_path, copyfile, ensuredir
if TYPE_CHECKING:
from ... | 169 | 5,707 |
sphinx | sphinx/util/__init__.py | .py | """Utility functions for Sphinx."""
from __future__ import annotations
import os
import posixpath
import re
TYPE_CHECKING = False
if TYPE_CHECKING:
import hashlib
from collections.abc import Callable
from types import ModuleType
from typing import Any
# Generally useful regular expressions.
ws_re: r... | 137 | 3,379 |
sphinx | sphinx/util/inspect.py | .py | """Helpers for inspecting Python modules."""
from __future__ import annotations
import ast
import builtins
import contextlib
import enum
import inspect
import re
import sys
import types
import typing
from collections.abc import Mapping
from functools import cached_property, partial, partialmethod, singledispatchmetho... | 1,101 | 38,422 |
sphinx | sphinx/util/docstrings.py | .py | """Utilities for docstring processing."""
from __future__ import annotations
import re
import sys
from docutils.parsers.rst.states import Body
field_list_item_re = re.compile(Body.patterns['field_marker'])
def separate_metadata(s: str | None) -> tuple[str | None, dict[str, str]]:
"""Separate docstring into me... | 89 | 2,944 |
sphinx | sphinx/util/_lines.py | .py | from __future__ import annotations
def parse_line_num_spec(spec: str, total: int) -> list[int]:
"""Parse a line number spec (such as "1,2,4-6") and return a list of
wanted line numbers.
"""
items = []
parts = spec.split(',')
for part in parts:
try:
begend = part.strip().spl... | 30 | 1,071 |
sphinx | sphinx/util/_uri.py | .py | from __future__ import annotations
from urllib.parse import parse_qsl, quote_plus, urlencode, urlsplit, urlunsplit
def encode_uri(uri: str) -> str:
scheme, netloc, url, query, fragment = urlsplit(uri)
netloc = netloc.encode('idna').decode('ascii')
url = quote_plus(url.encode(), '/')
query = urlencode... | 17 | 540 |
sphinx | sphinx/util/math.py | .py | """Utility functions for math."""
from __future__ import annotations
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from docutils import nodes
from sphinx.writers.html5 import HTML5Translator
def get_node_equation_number(writer: HTML5Translator, node: nodes.math_block) -> str:
if writer.builder.co... | 63 | 1,958 |
sphinx | sphinx/util/console.py | .py | """Format colored console output."""
from __future__ import annotations
import shutil
import sphinx._cli.util.colour
from sphinx._cli.util.colour import ( # NoQA: F401
_create_input_mode_colour_func,
black,
blink,
blue,
bold,
brown,
colourise,
darkblue,
darkgray,
darkgreen,
... | 77 | 1,806 |
sphinx | sphinx/util/_timestamps.py | .py | from __future__ import annotations
import time
def _format_rfc3339_microseconds(timestamp: int, /) -> str:
"""Return an RFC 3339 formatted string representing the given timestamp.
:param timestamp: The timestamp to format, in microseconds.
"""
seconds, fraction = divmod(timestamp, 10**6)
time_tu... | 14 | 431 |
sphinx | sphinx/util/_importer.py | .py | from __future__ import annotations
from importlib import import_module
from typing import TYPE_CHECKING
from sphinx.errors import ExtensionError
if TYPE_CHECKING:
from typing import Any
def import_object(object_name: str, /, source: str = '') -> Any:
"""Import python object by qualname."""
obj_path = o... | 31 | 941 |
sphinx | sphinx/util/matching.py | .py | """Pattern-matching utility functions for Sphinx."""
from __future__ import annotations
import os.path
import re
import unicodedata
from pathlib import Path
from typing import TYPE_CHECKING
from sphinx.util.osutil import canon_path
if TYPE_CHECKING:
from collections.abc import Callable, Iterable, Iterator
def... | 179 | 5,593 |
sphinx | sphinx/util/build_phase.py | .py | """Build phase of Sphinx application."""
from __future__ import annotations
from enum import IntEnum
class BuildPhase(IntEnum):
"""Build phase of Sphinx application."""
INITIALIZATION = 1
READING = 2
CONSISTENCY_CHECK = 3
RESOLVING = 3
WRITING = 4
| 16 | 277 |
sphinx | sphinx/util/texescape.py | .py | """TeX escaping helper."""
from __future__ import annotations
import re
tex_replacements = [
# map TeX special chars
('$', r'\$'),
('%', r'\%'),
('&', r'\&'),
('#', r'\#'),
('_', r'\_'),
('{', r'\{'),
('}', r'\}'),
('\\', r'\textbackslash{}'),
('~', r'\textasciitilde{}'),
... | 156 | 5,579 |
sphinx | sphinx/util/images.py | .py | """Image utility functions for Sphinx."""
from __future__ import annotations
import base64
from pathlib import Path
from typing import TYPE_CHECKING, NamedTuple, overload
from urllib.parse import unquote_to_bytes
import imagesize
if TYPE_CHECKING:
from os import PathLike
try:
from PIL import Image
PIL... | 160 | 4,106 |
sphinx | sphinx/util/parsing.py | .py | """Docutils utility functions for parsing text."""
from __future__ import annotations
import contextlib
from typing import TYPE_CHECKING
from docutils.nodes import Element
from docutils.statemachine import StringList, string2lines
if TYPE_CHECKING:
from collections.abc import Iterator
from docutils.nodes i... | 100 | 3,539 |
sphinx | sphinx/util/tags.py | .py | from __future__ import annotations
from typing import TYPE_CHECKING
import jinja2.environment
import jinja2.nodes
import jinja2.parser
if TYPE_CHECKING:
from collections.abc import Collection, Iterator
_ENV = jinja2.environment.Environment()
class BooleanParser(jinja2.parser.Parser):
"""Only allow conditi... | 103 | 3,583 |
sphinx | sphinx/util/index_entries.py | .py | from __future__ import annotations
def split_index_msg(entry_type: str, value: str) -> list[str]:
# new entry types must be listed in util/nodes.py!
if entry_type == 'single':
try:
return _split_into(2, 'single', value)
except ValueError:
return _split_into(1, 'single',... | 28 | 995 |
sphinx | sphinx/util/requests.py | .py | """Simple requests package loader"""
from __future__ import annotations
import warnings
from typing import TYPE_CHECKING
from urllib.parse import urljoin, urlsplit
import requests
from urllib3.exceptions import InsecureRequestWarning
import sphinx
if TYPE_CHECKING:
import re
from collections.abc import Seq... | 112 | 3,655 |
sphinx | sphinx/util/typing.py | .py | """The composite types for Sphinx."""
from __future__ import annotations
import dataclasses
import sys
import types
import typing
from collections.abc import Callable, Sequence
from typing import TYPE_CHECKING, TypeAliasType
from docutils import nodes
from docutils.parsers.rst.states import Inliner
from sphinx.util... | 641 | 26,013 |
sphinx | sphinx/util/docfields.py | .py | """Utility code for "Doc fields".
"Doc fields" are reST field lists in object descriptions that will
be domain-specifically transformed to a more appealing presentation.
"""
from __future__ import annotations
import contextlib
from typing import TYPE_CHECKING, cast
from docutils import nodes
from sphinx import add... | 511 | 18,273 |
sphinx | sphinx/util/_serialise.py | .py | """Serialise objects to a stable representation."""
from __future__ import annotations
import hashlib
import json
import types
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from typing import Any
def stable_hash(obj: Any) -> str:
"""Return a stable hash for a Python data structure.
We can't just ... | 56 | 1,992 |
sphinx | sphinx/util/png.py | .py | """PNG image manipulation helpers."""
from __future__ import annotations
import binascii
import struct
from typing import TYPE_CHECKING
if TYPE_CHECKING:
import os
LEN_IEND = 12
LEN_DEPTH = 22
DEPTH_CHUNK_LEN = struct.pack('!i', 10)
DEPTH_CHUNK_START = b'tEXtDepth\x00'
IEND_CHUNK = b'\x00\x00\x00\x00IEND\xae\x... | 48 | 1,548 |
sphinx | sphinx/util/osutil.py | .py | """Operating system-related utility functions for Sphinx."""
from __future__ import annotations
import contextlib
import filecmp
import os
import os.path
import re
import shutil
import sys
import unicodedata
from io import StringIO
from pathlib import Path
from typing import TYPE_CHECKING
from sphinx.locale import _... | 268 | 8,210 |
sphinx | sphinx/util/cfamily.py | .py | """Utility functions common to the C and C++ domains."""
from __future__ import annotations
import re
from copy import deepcopy
from typing import TYPE_CHECKING
from docutils import nodes
from sphinx import addnodes
from sphinx.util import logging
if TYPE_CHECKING:
from collections.abc import Callable, Sequenc... | 526 | 16,892 |
sphinx | sphinx/pycode/parser.py | .py | """Utilities parsing and analyzing Python code."""
from __future__ import annotations
import ast
import contextlib
import functools
import inspect
import itertools
import operator
import re
import tokenize
from token import DEDENT, INDENT, NAME, NEWLINE, NUMBER, OP, STRING
from tokenize import COMMENT, NL
from typing... | 628 | 22,880 |
sphinx | sphinx/pycode/ast.py | .py | """Helpers for AST (Abstract Syntax Tree)."""
from __future__ import annotations
import ast
from typing import TYPE_CHECKING, overload
if TYPE_CHECKING:
from typing import NoReturn
OPERATORS: dict[type[ast.AST], str] = {
ast.Add: '+',
ast.And: 'and',
ast.BitAnd: '&',
ast.BitOr: '|',
ast.BitX... | 210 | 7,043 |
sphinx | sphinx/pycode/__init__.py | .py | """Utilities parsing and analyzing Python code."""
from __future__ import annotations
import tokenize
from importlib import import_module
from typing import TYPE_CHECKING
from sphinx.errors import PycodeError
from sphinx.pycode.parser import Parser
from sphinx.util._pathlib import _StrPath
if TYPE_CHECKING:
imp... | 171 | 6,156 |
sphinx | sphinx/ext/autosectionlabel.py | .py | """Allow reference sections by :ref: role using its title."""
from __future__ import annotations
from types import NoneType
from typing import TYPE_CHECKING, cast
from docutils import nodes
import sphinx
from sphinx.locale import __
from sphinx.util import logging
from sphinx.util.nodes import clean_astext
if TYPE... | 87 | 2,573 |
sphinx | sphinx/ext/githubpages.py | .py | """To publish HTML docs at GitHub Pages, create .nojekyll file."""
from __future__ import annotations
import urllib.parse
from typing import TYPE_CHECKING
import sphinx
if TYPE_CHECKING:
from sphinx.application import Sphinx
from sphinx.environment import BuildEnvironment
from sphinx.util.typing import ... | 59 | 1,983 |
sphinx | sphinx/ext/ifconfig.py | .py | """Provides the ``ifconfig`` directive.
The ``ifconfig`` directive enables writing documentation
that is included depending on configuration variables.
Usage::
.. ifconfig:: releaselevel in ('alpha', 'beta', 'rc')
This stuff is only included in the built docs for unstable versions.
The argument for ``if... | 86 | 2,512 |
sphinx | sphinx/ext/coverage.py | .py | """Check Python modules and C API for coverage.
Mostly written by Josip Dzolonga for the Google Highly Open Participation
contest.
"""
from __future__ import annotations
import glob
import inspect
import os.path
import pickle
import pkgutil
import re
import sys
from importlib import import_module
from typing import ... | 558 | 22,563 |
sphinx | sphinx/ext/imgconverter.py | .py | """Image converter extension for Sphinx"""
from __future__ import annotations
import subprocess
import sys
from subprocess import CalledProcessError
from typing import TYPE_CHECKING
import sphinx
from sphinx.errors import ExtensionError
from sphinx.locale import __
from sphinx.transforms.post_transforms.images impor... | 120 | 4,083 |
sphinx | sphinx/ext/viewcode.py | .py | """Add links to module code in Python object descriptions."""
from __future__ import annotations
import importlib
import operator
import posixpath
import traceback
from types import NoneType
from typing import TYPE_CHECKING, cast
from docutils import nodes
from docutils.nodes import Element
import sphinx
from sphin... | 418 | 15,350 |
sphinx | sphinx/ext/linkcode.py | .py | """Add external links to module code in Python object descriptions."""
from __future__ import annotations
from types import FunctionType, NoneType
from typing import TYPE_CHECKING
from docutils import nodes
import sphinx
from sphinx import addnodes
from sphinx.errors import SphinxError
from sphinx.locale import _
... | 101 | 3,040 |
sphinx | sphinx/ext/inheritance_diagram.py | .py | r"""Defines a docutils directive for inserting inheritance diagrams.
Provide the directive with one or more classes or modules (separated
by whitespace). For modules, all of the classes in that module will
be used.
Example::
Given the following classes:
class A: pass
class B(A): pass
class C(A): pass
... | 570 | 19,094 |
sphinx | sphinx/ext/imgmath.py | .py | """Render math in HTML via dvipng or dvisvgm."""
from __future__ import annotations
__all__ = ()
import base64
import contextlib
import os
import os.path
import re
import shutil
import subprocess
import tempfile
from hashlib import sha1
from pathlib import Path
from subprocess import CalledProcessError
from typing i... | 423 | 15,226 |
sphinx | sphinx/ext/todo.py | .py | """Allow todos to be inserted into your documentation.
Inclusion of todos can be switched of by a configuration variable.
The todolist directive collects all todos of your project and lists them along
with a backlink to the original location.
"""
from __future__ import annotations
import functools
import operator
fr... | 251 | 8,019 |
sphinx | sphinx/ext/duration.py | .py | """Measure document reading durations."""
from __future__ import annotations
import json
import time
from itertools import islice
from operator import itemgetter
from types import NoneType
from typing import TYPE_CHECKING
import sphinx
from sphinx.domains import Domain
from sphinx.locale import __
from sphinx.util i... | 176 | 5,743 |
sphinx | sphinx/ext/graphviz.py | .py | """Allow graphviz-formatted graphs to be included inline in generated documents."""
from __future__ import annotations
import os.path
import re
import subprocess
import xml.etree.ElementTree as ET
from hashlib import sha1
from itertools import chain
from subprocess import CalledProcessError
from typing import TYPE_CH... | 537 | 18,061 |
sphinx | sphinx/ext/mathjax.py | .py | """Allow `MathJax`_ to be used to display math in Sphinx's HTML writer.
This requires the MathJax JavaScript library on your webserver/computer.
.. _MathJax: https://www.mathjax.org/
"""
from __future__ import annotations
import json
from types import NoneType
from typing import TYPE_CHECKING, cast
from docutils i... | 179 | 6,790 |
sphinx | sphinx/ext/doctest.py | .py | """Mimic doctest in Sphinx.
The extension automatically execute code snippets and checks their results.
"""
from __future__ import annotations
import doctest
import os.path
import re
import sys
import time
from io import StringIO
from typing import TYPE_CHECKING
from docutils import nodes
from docutils.parsers.rst ... | 665 | 24,608 |
sphinx | sphinx/ext/extlinks.py | .py | """Extension to save typing and prevent hard-coding of base URLs in reST files.
This adds a new config value called ``extlinks`` that is created like this::
extlinks = {'exmpl': ('https://example.invalid/%s.html', caption), ...}
Now you can use e.g. :exmpl:`foo` in your documents. This will create a
link to ``ht... | 140 | 4,879 |
sphinx | sphinx/ext/autosummary/generate.py | .py | """Generates reST source files for autosummary.
Usable as a library or script to generate automatic RST source files for
items referred to in autosummary:: directives.
Each generated RST file contains a single auto*:: directive which
extracts the docstring of the referred item.
Example Makefile rule::
generate:
... | 993 | 31,629 |
sphinx | sphinx/ext/autosummary/__init__.py | .py | """Extension that adds an autosummary:: directive.
The directive can be used to generate function/method/attribute/etc. summary
lists, similar to those output eg. by Epydoc and other API doc generation tools.
An :autolink: role is also provided.
autosummary directive
---------------------
The autosummary directive ... | 930 | 32,089 |
sphinx | sphinx/ext/intersphinx/_load.py | .py | """This module contains the code for loading intersphinx inventories."""
from __future__ import annotations
import concurrent.futures
import dataclasses
import os.path
import posixpath
import time
from operator import itemgetter
from typing import TYPE_CHECKING
from urllib.parse import urlsplit, urlunsplit
from sphi... | 483 | 16,852 |
sphinx | sphinx/ext/intersphinx/_cli.py | .py | """This module provides contains the code for intersphinx command-line utilities."""
from __future__ import annotations
import sys
from pathlib import Path
from sphinx.ext.intersphinx._load import (
_fetch_inventory_data,
_InvConfig,
_load_inventory,
)
def inspect_main(argv: list[str], /) -> int:
"... | 58 | 1,647 |
sphinx | sphinx/ext/intersphinx/__main__.py | .py | """Command line interface for the intersphinx extension."""
from __future__ import annotations
import logging as _logging
import sys
from sphinx.ext.intersphinx._cli import inspect_main
_logging.basicConfig()
raise SystemExit(inspect_main(sys.argv[1:]))
| 13 | 259 |
sphinx | sphinx/ext/intersphinx/__init__.py | .py | """Insert links to objects documented in remote Sphinx documentation.
This works as follows:
* Each Sphinx HTML build creates a file named "objects.inv" that contains a
mapping from object names to URIs relative to the HTML set's root.
* Projects using the Intersphinx extension can specify links to such mapping
... | 111 | 3,661 |
sphinx | sphinx/ext/intersphinx/_resolve.py | .py | """This module provides logic for resolving references to intersphinx targets."""
from __future__ import annotations
import re
from pathlib import Path
from typing import TYPE_CHECKING, cast
from docutils import nodes
from sphinx.addnodes import pending_xref
from sphinx.errors import ExtensionError
from sphinx.ext.... | 580 | 21,092 |
sphinx | sphinx/ext/intersphinx/_shared.py | .py | """This module contains code shared between intersphinx modules."""
from __future__ import annotations
from typing import TYPE_CHECKING
from sphinx.util import logging
if TYPE_CHECKING:
from collections.abc import Sequence
from typing import Any, Final, NoReturn
from sphinx.environment import BuildEnvi... | 149 | 5,473 |
sphinx | sphinx/ext/napoleon/__init__.py | .py | """Support for NumPy and Google style docstrings."""
from __future__ import annotations
from types import NoneType
from typing import TYPE_CHECKING
import sphinx
from sphinx.application import Sphinx
from sphinx.ext.napoleon.docstring import GoogleDocstring, NumpyDocstring
from sphinx.util import inspect
if TYPE_CH... | 510 | 18,761 |
sphinx | sphinx/ext/napoleon/docstring.py | .py | """Classes for docstring parsing and formatting."""
from __future__ import annotations
import collections
import contextlib
import inspect
import re
from functools import partial
from itertools import starmap
from typing import TYPE_CHECKING, Any
from sphinx.locale import _, __
from sphinx.util import logging
from s... | 1,438 | 51,058 |
sphinx | sphinx/ext/autodoc/_renderer.py | .py | from __future__ import annotations
from typing import TYPE_CHECKING
from sphinx.ext.autodoc._property_types import (
_AssignStatementProperties,
_ClassDefProperties,
_FunctionDefProperties,
_TypeStatementProperties,
)
from sphinx.ext.autodoc._sentinels import SUPPRESS
from sphinx.locale import _
if T... | 177 | 6,066 |
sphinx | sphinx/ext/autodoc/_sentinels.py | .py | from __future__ import annotations
TYPE_CHECKING = False
if TYPE_CHECKING:
from typing import Final, Literal, NoReturn, Self, _SpecialForm
class _Sentinel:
"""Create a unique sentinel object."""
__slots__ = ('_name',)
_name: str
def __new__(cls, name: str, /) -> Self:
sentinel = super(... | 107 | 3,430 |
sphinx | sphinx/ext/autodoc/preserve_defaults.py | .py | """Preserve function defaults.
Preserve the default argument values of function signatures in source code
and keep them not evaluated for readability.
"""
from __future__ import annotations
from typing import TYPE_CHECKING
from sphinx.ext.autodoc._dynamic._preserve_defaults import (
DefaultValue, # NoQA: F401
... | 33 | 853 |
sphinx | sphinx/ext/autodoc/_directive_options.py | .py | from __future__ import annotations
import warnings
from typing import TYPE_CHECKING
from docutils.utils import assemble_option_dict
from sphinx.deprecation import RemovedInSphinx11Warning
from sphinx.ext.autodoc._sentinels import ALL, EMPTY, SUPPRESS
from sphinx.locale import __
if TYPE_CHECKING:
from collectio... | 351 | 12,252 |
sphinx | sphinx/ext/autodoc/_names.py | .py | """Importer utilities for autodoc"""
from __future__ import annotations
import re
from typing import TYPE_CHECKING
from sphinx.ext.autodoc._shared import LOGGER
from sphinx.locale import __
if TYPE_CHECKING:
from collections.abc import Mapping, Sequence
from sphinx.environment import _CurrentDocument
f... | 182 | 6,260 |
sphinx | sphinx/ext/autodoc/typehints.py | .py | """Generating content for autodoc using typehints"""
from __future__ import annotations
import re
from typing import TYPE_CHECKING, cast
from docutils import nodes
from sphinx import addnodes
from sphinx.ext.autodoc._dynamic._type_annotations import _record_typehints
if TYPE_CHECKING:
from collections.abc impo... | 216 | 7,355 |
sphinx | sphinx/ext/autodoc/__init__.py | .py | """Extension to create automatic documentation from code docstrings.
Automatically insert docstrings for functions, classes or whole modules into
the doctree, thus avoiding duplication between docstrings and documentation
for those who like elaborate docstrings.
"""
from __future__ import annotations
from typing imp... | 254 | 7,667 |
sphinx | sphinx/ext/autodoc/_shared.py | .py | """Shared utilities for autodoc that don't have a better home."""
from __future__ import annotations
from typing import TYPE_CHECKING
from sphinx.util import logging
from sphinx.util.inspect import safe_getattr
if TYPE_CHECKING:
from collections.abc import Callable, Mapping, Sequence
from typing import Any,... | 163 | 6,256 |
sphinx | sphinx/ext/autodoc/directive.py | .py | from __future__ import annotations
from collections.abc import Callable
from typing import TYPE_CHECKING
from docutils.statemachine import StringList
from docutils.utils import assemble_option_dict
from sphinx.ext.autodoc._legacy_class_based._directive_options import Options
from sphinx.ext.autodoc._shared import LO... | 179 | 5,913 |
sphinx | sphinx/ext/autodoc/_directive.py | .py | from __future__ import annotations
from typing import TYPE_CHECKING
from docutils import nodes
from sphinx.ext.autodoc._directive_options import _process_documenter_options
from sphinx.ext.autodoc._generate import _auto_document_object
from sphinx.ext.autodoc._shared import LOGGER, _AutodocAttrGetter, _AutodocConfig... | 119 | 4,317 |
sphinx | sphinx/ext/autodoc/_generate.py | .py | from __future__ import annotations
import sys
from typing import TYPE_CHECKING
from docutils.statemachine import StringList
from sphinx.errors import PycodeError
from sphinx.ext.autodoc._dynamic._loader import _load_object_by_name
from sphinx.ext.autodoc._dynamic._member_finder import _gather_members
from sphinx.ext... | 407 | 14,182 |
sphinx | sphinx/ext/autodoc/mock.py | .py | from __future__ import annotations
from sphinx.ext.autodoc._dynamic._mock import (
MockFinder, # NoQA: F401
MockLoader, # NoQA: F401
_make_subclass, # NoQA: F401
_MockModule, # NoQA: F401
_MockObject, # NoQA: F401
ismock, # NoQA: F401
ismockmodule, # NoQA: F401
mock, # NoQA: F40... | 14 | 354 |
sphinx | sphinx/ext/autodoc/_property_types.py | .py | from __future__ import annotations
import dataclasses
from sphinx.ext.autodoc._sentinels import RUNTIME_INSTANCE_ATTRIBUTE, UNINITIALIZED_ATTR
TYPE_CHECKING = False
if TYPE_CHECKING:
from collections.abc import Sequence
from pathlib import Path
from typing import Any, Literal
from sphinx.ext.autodoc... | 241 | 6,528 |
sphinx | sphinx/ext/autodoc/importer.py | .py | """Importer utilities for autodoc"""
from __future__ import annotations
import traceback
from importlib.machinery import EXTENSION_SUFFIXES
from typing import TYPE_CHECKING, NamedTuple
from sphinx.errors import PycodeError
from sphinx.ext.autodoc._dynamic._importer import (
_find_type_stub_spec, # NoQA: F401
... | 324 | 11,656 |
sphinx | sphinx/ext/autodoc/type_comment.py | .py | """Update annotations info of living objects using type_comments."""
from __future__ import annotations
from typing import TYPE_CHECKING
from sphinx.ext.autodoc._dynamic._type_comments import (
_update_annotations_using_type_comments,
not_suppressed, # NoQA: F401
signature_from_ast, # NoQA: F401
)
if ... | 27 | 679 |
sphinx | sphinx/ext/autodoc/_event_listeners.py | .py | """Some useful event listener factories for autodoc-process-docstring."""
from __future__ import annotations
import re
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from collections.abc import Sequence
from typing import Any, Protocol
from sphinx.application import Sphinx
from sphinx.ext.autodo... | 170 | 5,009 |
sphinx | sphinx/ext/autodoc/_legacy_class_based/_sentinels.py | .py | from __future__ import annotations
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from typing import Any
class _All:
"""A special value for :*-members: that matches to any member."""
def __contains__(self, item: Any) -> bool:
return True
def append(self, item: Any) -> None:
pas... | 32 | 627 |
sphinx | sphinx/ext/autodoc/_legacy_class_based/_directive_options.py | .py | from __future__ import annotations
from typing import Any
from sphinx.ext.autodoc._legacy_class_based._sentinels import ALL, EMPTY, SUPPRESS
from sphinx.locale import __
def identity(x: Any) -> Any:
return x
def members_option(arg: Any) -> object | list[str]:
"""Used to convert the :members: option to aut... | 101 | 2,938 |
sphinx | sphinx/ext/autodoc/_legacy_class_based/_documenters.py | .py | from __future__ import annotations
import functools
import operator
import re
import sys
from inspect import Parameter, Signature
from typing import TYPE_CHECKING, NewType, TypeVar
from docutils.statemachine import StringList
from sphinx.errors import PycodeError
from sphinx.ext.autodoc._dynamic._mock import ismock,... | 2,929 | 112,530 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.