Skip to main content

Module utils

Module utils 

Source

Structs§

ProjectStats

Functions§

analyze_project
calculate_directory_size
canonicalize_simplified
std::fs::canonicalize with the Windows verbatim prefix taken back off (simplify_verbatim) — the spelling every path comparison, display and %r in this crate speaks.
copy_dir_all
Copy all files and directories from source to destination
copy_dir_recursive
count_cross_references
ensure_dir
Ensure a directory exists, creating it if necessary
format_bytes
format_date
Format a date according to the specified format string and language
format_duration
get_file_mtime
is_source_file
normalize_dot_segments
os.path.normpath over a posix-separated relative path: . and inner .. collapse; a leading .. stays and walks out of the tree (a path that simply will not exist).
path2doc
Project.path2doc (sphinx/project.py:114-128) against Sphinx’s default source_suffix — {'.rst': 'restructuredtext'} (config.py:243): the docname a source file under srcdir maps to, or None for anything else.
quote_url_path
urllib.parse.quote(s) with its default safe='/': every byte of the UTF-8 encoding outside A-Za-z0-9, _.-~ and / becomes %XX (upper-case hex). StandaloneHTMLBuilder.get_target_uri applies it to a docname before appending the link suffix, so my page links as my%20page.html and reads back as one token in an inventory line.
relative_uri
Calculate relative URI from one path to another
relfn2path
BuildEnvironment.relfn2path (environment/__init__.py:454-478): a filename written in a document resolves relative to that document’s directory, unless it is written absolute (/pic.png), in which case it is relative to the source directory. The result is normalized (. and .. collapsed, Sphinx’s os.path.normpath) and joined onto srcdir.
relfn2path_io
The path to actually OPEN for uri written in docname.
relfn2path_rel
The srcdir-relative half of relfn2path: the normalized posix path (relative to the source directory) that uri written in docname refers to. Sphinx’s rel_fn return value.
simplify_verbatim
Drop the \\?\ verbatim prefix that Windows’ GetFinalPathNameByHandle — and so std::fs::canonicalize — puts in front of every canonical path.