package documentation

Utility functions for Sphinx.

Unknown Field: copyright
Copyright 2007-2022 by the Sphinx team, see AUTHORS.
Unknown Field: license
BSD, see LICENSE for details.
Module docutils sphinx.util.docutils ~~~~~~~~~~~~~~~~~~~~
Module logging sphinx.util.logging ~~~~~~~~~~~~~~~~~~~
Module build​_phase sphinx.util.build_phase ~~~~~~~~~~~~~~~~~~~~~~~
Module cfamily sphinx.util.cfamily ~~~~~~~~~~~~~~~~~~~
Module compat sphinx.util.compat ~~~~~~~~~~~~~~~~~~
Module console sphinx.util.console ~~~~~~~~~~~~~~~~~~~
Module docfields sphinx.util.docfields ~~~~~~~~~~~~~~~~~~~~~
Module docstrings sphinx.util.docstrings ~~~~~~~~~~~~~~~~~~~~~~
Module fileutil sphinx.util.fileutil ~~~~~~~~~~~~~~~~~~~~
Module i18n sphinx.util.i18n ~~~~~~~~~~~~~~~~
Module images sphinx.util.images ~~~~~~~~~~~~~~~~~~
Module inspect sphinx.util.inspect ~~~~~~~~~~~~~~~~~~~
Module inventory sphinx.util.inventory ~~~~~~~~~~~~~~~~~~~~~
Module jsdump sphinx.util.jsdump ~~~~~~~~~~~~~~~~~~
Module matching sphinx.util.matching ~~~~~~~~~~~~~~~~~~~~
Module math sphinx.util.math ~~~~~~~~~~~~~~~~
Module nodes sphinx.util.nodes ~~~~~~~~~~~~~~~~~
Module osutil sphinx.util.osutil ~~~~~~~~~~~~~~~~~~
Module parallel sphinx.util.parallel ~~~~~~~~~~~~~~~~~~~~
Module png sphinx.util.png ~~~~~~~~~~~~~~~
Module pycompat sphinx.util.pycompat ~~~~~~~~~~~~~~~~~~~~
Module requests sphinx.util.requests ~~~~~~~~~~~~~~~~~~~~
Module rst sphinx.util.rst ~~~~~~~~~~~~~~~
Module smartypants sphinx.util.smartypants ~~~~~~~~~~~~~~~~~~~~~~~
Package stemmer sphinx.util.stemmer ~~~~~~~~~~~~~~~~~~~
Module tags sphinx.util.tags ~~~~~~~~~~~~~~~~
Module template sphinx.util.template ~~~~~~~~~~~~~~~~~~~~
Module texescape sphinx.util.texescape ~~~~~~~~~~~~~~~~~~~~~
Module typing sphinx.util.typing ~~~~~~~~~~~~~~~~~~

From __init__.py:

Variable logger Undocumented
Variable url​_re Undocumented
Variable ws​_re Undocumented
Class ​Download​Files A special dictionary for download files.
Class ​Filename​Uniq​Dict A dictionary that automatically generates unique names for its keys, interpreted as filenames, and keeps track of a set of docnames they appear in. Used for images and downloadable files in the environment.
Class progress​_message Undocumented
Class ​Skip​Progress​Message Undocumented
Class ​Tee File-like object writing to two streams.
Class ​Unicode​Decode​Error​Handler Custom error handler for open() that warns and replaces.
Function display​_chunk Undocumented
Function docname​_join Undocumented
Function encode​_uri Undocumented
Function epoch​_to​_rfc1123 Convert datetime format epoch to RFC1123.
Function force​_decode Forcibly get a unicode string out of a bytestring.
Function format​_exception​_cut​_frames Format an exception with traceback, but only the last x frames.
Function get​_filetype Undocumented
Function get​_full​_modname Undocumented
Function get​_matching​_files Get all file names in a directory, recursively.
Function import​_object Import python object by qualname.
Function isurl Check url is URL or not.
Function md5 Wrapper around hashlib.md5
Function old​_status​_iterator Undocumented
Function parselinenos Parse a line number spec (such as "1,2,4-6") and return a list of wanted line numbers.
Function path​_stabilize Normalize path separator and unicode string
Function rfc1123​_to​_epoch Undocumented
Function rpartition Similar to str.rpartition from 2.5, but doesn't return the separator.
Function save​_traceback Save the current exception's traceback in a temporary file.
Function sha1 Wrapper around hashlib.sha1
Function split​_full​_qualified​_name Split full qualified name to a pair of modname and qualname.
Function split​_index​_msg Undocumented
Function split​_into Split an index entry into a given number of parts at semicolons.
Function status​_iterator Undocumented
Function xmlname​_checker Undocumented
Constant ​_DEBUG​_HEADER Undocumented
Variable ​_coding​_re Undocumented
logger =

Undocumented

ws_re: Pattern =

Undocumented

url_re: Pattern =

Undocumented

def docname_join(basedocname, docname):

Undocumented

Parameters
basedocname:strUndocumented
docname:strUndocumented
Returns
strUndocumented
def path_stabilize(filepath):
Normalize path separator and unicode string
Parameters
filepath:strUndocumented
Returns
strUndocumented
def get_matching_files(dirname, exclude_matchers=()):

Get all file names in a directory, recursively.

Exclude files and dirs matching some matcher in exclude_matchers.

Parameters
dirname:strUndocumented
exclude​_matchers:Tuple[PathMatcher, ...]Undocumented
Returns
Iterable[str]Undocumented
def get_filetype(source_suffix, filename):

Undocumented

Parameters
source​_suffix:Dict[str, str]Undocumented
filename:strUndocumented
Returns
strUndocumented
def md5(data=b'', **kwargs):

Wrapper around hashlib.md5

Attempt call with 'usedforsecurity=False' if we get a ValueError, which happens when OpenSSL FIPS mode is enabled: ValueError: error:060800A3:digital envelope routines:EVP_DigestInit_ex:disabled for fips

See: https://github.com/sphinx-doc/sphinx/issues/7611

def sha1(data=b'', **kwargs):

Wrapper around hashlib.sha1

Attempt call with 'usedforsecurity=False' if we get a ValueError

See: https://github.com/sphinx-doc/sphinx/issues/7611

_DEBUG_HEADER: str =

Undocumented

Value
'''# Sphinx version: %s
# Python version: %s (%s)
# Docutils version: %s %s
# Jinja2 version: %s
# Last messages:
%s
# Loaded extensions:
...
def save_traceback(app):
Save the current exception's traceback in a temporary file.
Parameters
app:SphinxUndocumented
Returns
strUndocumented
def get_full_modname(modname, attribute):

Undocumented

Parameters
modname:strUndocumented
attribute:strUndocumented
Returns
strUndocumented
_coding_re =

Undocumented

def parselinenos(spec, total):
Parse a line number spec (such as "1,2,4-6") and return a list of wanted line numbers.
Parameters
spec:strUndocumented
total:intUndocumented
Returns
List[int]Undocumented
def force_decode(string, encoding):
Forcibly get a unicode string out of a bytestring.
Parameters
string:strUndocumented
encoding:strUndocumented
Returns
strUndocumented
def rpartition(s, t):
Similar to str.rpartition from 2.5, but doesn't return the separator.
Parameters
s:strUndocumented
t:strUndocumented
Returns
Tuple[str, str]Undocumented
def split_into(n, type, value):
Split an index entry into a given number of parts at semicolons.
Parameters
n:intUndocumented
type:strUndocumented
value:strUndocumented
Returns
List[str]Undocumented
def split_index_msg(type, value):

Undocumented

Parameters
type:strUndocumented
value:strUndocumented
Returns
List[str]Undocumented
def format_exception_cut_frames(x=1):
Format an exception with traceback, but only the last x frames.
Parameters
x:intUndocumented
Returns
strUndocumented
def import_object(objname, source=None):
Import python object by qualname.
Parameters
objname:strUndocumented
source:strUndocumented
Returns
AnyUndocumented
def split_full_qualified_name(name):

Split full qualified name to a pair of modname and qualname.

A qualname is an abbreviation for "Qualified name" introduced at PEP-3155 (https://www.python.org/dev/peps/pep-3155/). It is a dotted path name from the module top-level.

A "full" qualified name means a string containing both module name and qualified name.

Note

This function actually imports the module to check its existence. Therefore you need to mock 3rd party modules if needed before calling this function.

Parameters
name:strUndocumented
Returns
Tuple[Optional[str], str]Undocumented
def encode_uri(uri):

Undocumented

Parameters
uri:strUndocumented
Returns
strUndocumented
def isurl(url):
Check url is URL or not.
Parameters
url:strUndocumented
Returns
boolUndocumented
def display_chunk(chunk):

Undocumented

Parameters
chunk:AnyUndocumented
Returns
strUndocumented
def old_status_iterator(iterable, summary, color='darkgreen', stringify_func=display_chunk):

Undocumented

Parameters
iterable:IterableUndocumented
summary:strUndocumented
color:strUndocumented
stringify​_func:Callable[[Any], str]Undocumented
Returns
IteratorUndocumented
def status_iterator(iterable, summary, color='darkgreen', length=0, verbosity=0, stringify_func=display_chunk):

Undocumented

Parameters
iterable:IterableUndocumented
summary:strUndocumented
color:strUndocumented
length:intUndocumented
verbosity:intUndocumented
stringify​_func:Callable[[Any], str]Undocumented
Returns
IterableUndocumented
def epoch_to_rfc1123(epoch):
Convert datetime format epoch to RFC1123.
Parameters
epoch:floatUndocumented
Returns
strUndocumented
def rfc1123_to_epoch(rfc1123):

Undocumented

Parameters
rfc1123:strUndocumented
Returns
floatUndocumented
def xmlname_checker():

Undocumented

Returns
PatternUndocumented