Expand description
Language detection and the file readers.
Enums§
- Skip
Reason - Why
read_file_with_eol_classifieddeclined to hand a file’s bytes to the metric engine.
Functions§
- get_
language_ for_ file - Detects the language of a code using the extension of a file.
- guess_
language - Guesses the language of a code.
- is_
generated - Returns
truewhenbuflooks like generated code: its leading window (first ~50 lines or first 5 KiB, whichever is smaller) contains a known marker phrase. Matching is case-insensitive for the marker and never allocates on the negative path. - normalize_
eol - Normalises an in-memory source buffer to match the
read_file_with_eolon-disk path: all CR-only and CRLF line endings become LF, and the buffer is guaranteed to end with exactly one\n. - normalize_
line_ endings - Normalises all CR-only and CRLF line endings to LF throughout the buffer,
then ensures the buffer ends with exactly one
\n. - read_
file - Reads a file, normalising all CR-only and CRLF line endings to LF.
- read_
file_ with_ eol - Reads a file, normalising all CR-only and CRLF line endings to LF, and ensures
the buffer ends with exactly one
\n. ReturnsNonefor readable files ≤ 3 bytes or files that appear to be non-UTF-8. - read_
file_ with_ eol_ classified - Reads a file exactly as
read_file_with_eoldoes, but names the reason when the file is skipped instead of collapsing every skip intoNone. - write_
file - Writes data to a file.