Fix rustdoc warnings.

This requires making the `input` mod public, as some items in
`char_traits` are referenced in `Input`'s function doccomments.
The items have been exposed in `input` directly, rather than in a
`saphyr::input::char_traits` submod.
This commit is contained in:
Ethiraric 2024-10-13 16:21:37 +02:00
parent 9e3317c179
commit 979f8eabf9
3 changed files with 45 additions and 21 deletions

View file

@ -2,25 +2,29 @@
/// Check whether the character is nil (`\0`). /// Check whether the character is nil (`\0`).
#[inline] #[inline]
pub(crate) fn is_z(c: char) -> bool { #[must_use]
pub fn is_z(c: char) -> bool {
c == '\0' c == '\0'
} }
/// Check whether the character is a line break (`\r` or `\n`). /// Check whether the character is a line break (`\r` or `\n`).
#[inline] #[inline]
pub(crate) fn is_break(c: char) -> bool { #[must_use]
pub fn is_break(c: char) -> bool {
c == '\n' || c == '\r' c == '\n' || c == '\r'
} }
/// Check whether the character is nil or a line break (`\0`, `\r`, `\n`). /// Check whether the character is nil or a line break (`\0`, `\r`, `\n`).
#[inline] #[inline]
pub(crate) fn is_breakz(c: char) -> bool { #[must_use]
pub fn is_breakz(c: char) -> bool {
is_break(c) || is_z(c) is_break(c) || is_z(c)
} }
/// Check whether the character is a whitespace (` ` or `\t`). /// Check whether the character is a whitespace (` ` or `\t`).
#[inline] #[inline]
pub(crate) fn is_blank(c: char) -> bool { #[must_use]
pub fn is_blank(c: char) -> bool {
c == ' ' || c == '\t' c == ' ' || c == '\t'
} }
@ -28,31 +32,36 @@ pub(crate) fn is_blank(c: char) -> bool {
/// ///
/// `\0`, ` `, `\t`, `\n`, `\r` /// `\0`, ` `, `\t`, `\n`, `\r`
#[inline] #[inline]
pub(crate) fn is_blank_or_breakz(c: char) -> bool { #[must_use]
pub fn is_blank_or_breakz(c: char) -> bool {
is_blank(c) || is_breakz(c) is_blank(c) || is_breakz(c)
} }
/// Check whether the character is an ascii digit. /// Check whether the character is an ascii digit.
#[inline] #[inline]
pub(crate) fn is_digit(c: char) -> bool { #[must_use]
pub fn is_digit(c: char) -> bool {
c.is_ascii_digit() c.is_ascii_digit()
} }
/// Check whether the character is a digit, letter, `_` or `-`. /// Check whether the character is a digit, letter, `_` or `-`.
#[inline] #[inline]
pub(crate) fn is_alpha(c: char) -> bool { #[must_use]
pub fn is_alpha(c: char) -> bool {
matches!(c, '0'..='9' | 'a'..='z' | 'A'..='Z' | '_' | '-') matches!(c, '0'..='9' | 'a'..='z' | 'A'..='Z' | '_' | '-')
} }
/// Check whether the character is a hexadecimal character (case insensitive). /// Check whether the character is a hexadecimal character (case insensitive).
#[inline] #[inline]
pub(crate) fn is_hex(c: char) -> bool { #[must_use]
pub fn is_hex(c: char) -> bool {
c.is_ascii_digit() || ('a'..='f').contains(&c) || ('A'..='F').contains(&c) c.is_ascii_digit() || ('a'..='f').contains(&c) || ('A'..='F').contains(&c)
} }
/// Convert the hexadecimal digit to an integer. /// Convert the hexadecimal digit to an integer.
#[inline] #[inline]
pub(crate) fn as_hex(c: char) -> u32 { #[must_use]
pub fn as_hex(c: char) -> u32 {
match c { match c {
'0'..='9' => (c as u32) - ('0' as u32), '0'..='9' => (c as u32) - ('0' as u32),
'a'..='f' => (c as u32) - ('a' as u32) + 10, 'a'..='f' => (c as u32) - ('a' as u32) + 10,
@ -63,49 +72,57 @@ pub(crate) fn as_hex(c: char) -> u32 {
/// Check whether the character is a YAML flow character (one of `,[]{}`). /// Check whether the character is a YAML flow character (one of `,[]{}`).
#[inline] #[inline]
pub(crate) fn is_flow(c: char) -> bool { #[must_use]
pub fn is_flow(c: char) -> bool {
matches!(c, ',' | '[' | ']' | '{' | '}') matches!(c, ',' | '[' | ']' | '{' | '}')
} }
/// Check whether the character is the BOM character. /// Check whether the character is the BOM character.
#[inline] #[inline]
pub(crate) fn is_bom(c: char) -> bool { #[must_use]
pub fn is_bom(c: char) -> bool {
c == '\u{FEFF}' c == '\u{FEFF}'
} }
/// Check whether the character is a YAML non-breaking character. /// Check whether the character is a YAML non-breaking character.
#[inline] #[inline]
pub(crate) fn is_yaml_non_break(c: char) -> bool { #[must_use]
pub fn is_yaml_non_break(c: char) -> bool {
// TODO(ethiraric, 28/12/2023): is_printable // TODO(ethiraric, 28/12/2023): is_printable
!is_break(c) && !is_bom(c) !is_break(c) && !is_bom(c)
} }
/// Check whether the character is NOT a YAML whitespace (` ` / `\t`). /// Check whether the character is NOT a YAML whitespace (` ` / `\t`).
#[inline] #[inline]
pub(crate) fn is_yaml_non_space(c: char) -> bool { #[must_use]
pub fn is_yaml_non_space(c: char) -> bool {
is_yaml_non_break(c) && !is_blank(c) is_yaml_non_break(c) && !is_blank(c)
} }
/// Check whether the character is a valid YAML anchor name character. /// Check whether the character is a valid YAML anchor name character.
#[inline] #[inline]
pub(crate) fn is_anchor_char(c: char) -> bool { #[must_use]
pub fn is_anchor_char(c: char) -> bool {
is_yaml_non_space(c) && !is_flow(c) && !is_z(c) is_yaml_non_space(c) && !is_flow(c) && !is_z(c)
} }
/// Check whether the character is a valid word character. /// Check whether the character is a valid word character.
#[inline] #[inline]
pub(crate) fn is_word_char(c: char) -> bool { #[must_use]
pub fn is_word_char(c: char) -> bool {
is_alpha(c) && c != '_' is_alpha(c) && c != '_'
} }
/// Check whether the character is a valid URI character. /// Check whether the character is a valid URI character.
#[inline] #[inline]
pub(crate) fn is_uri_char(c: char) -> bool { #[must_use]
pub fn is_uri_char(c: char) -> bool {
is_word_char(c) || "#;/?:@&=+$,_.!~*\'()[]%".contains(c) is_word_char(c) || "#;/?:@&=+$,_.!~*\'()[]%".contains(c)
} }
/// Check whether the character is a valid tag character. /// Check whether the character is a valid tag character.
#[inline] #[inline]
pub(crate) fn is_tag_char(c: char) -> bool { #[must_use]
pub fn is_tag_char(c: char) -> bool {
is_uri_char(c) && !is_flow(c) && c != '!' is_uri_char(c) && !is_flow(c) && c != '!'
} }

View file

@ -1,10 +1,15 @@
pub mod buffered; //! Utilities to create a source of input to the parser.
pub mod str; //!
//! [`Input`] must be implemented for the parser to fetch input. Make sure your needs aren't
//! covered by the [`BufferedInput`].
pub(crate) mod buffered;
pub(crate) mod str;
#[allow(clippy::module_name_repetitions)] #[allow(clippy::module_name_repetitions)]
pub use buffered::BufferedInput; pub use buffered::BufferedInput;
use crate::char_traits::{ pub use crate::char_traits::{
is_alpha, is_blank, is_blank_or_breakz, is_break, is_breakz, is_digit, is_flow, is_z, is_alpha, is_blank, is_blank_or_breakz, is_break, is_breakz, is_digit, is_flow, is_z,
}; };
@ -440,6 +445,7 @@ impl SkipTabs {
/// Whether tabs were found while skipping whitespace. /// Whether tabs were found while skipping whitespace.
/// ///
/// This function must be called after a call to `skip_ws_to_eol`. /// This function must be called after a call to `skip_ws_to_eol`.
#[must_use]
pub fn found_tabs(self) -> bool { pub fn found_tabs(self) -> bool {
matches!(self, SkipTabs::Result(true, _)) matches!(self, SkipTabs::Result(true, _))
} }
@ -447,6 +453,7 @@ impl SkipTabs {
/// Whether a valid YAML whitespace has been found in skipped-over content. /// Whether a valid YAML whitespace has been found in skipped-over content.
/// ///
/// This function must be called after a call to `skip_ws_to_eol`. /// This function must be called after a call to `skip_ws_to_eol`.
#[must_use]
pub fn has_valid_yaml_ws(self) -> bool { pub fn has_valid_yaml_ws(self) -> bool {
matches!(self, SkipTabs::Result(_, true)) matches!(self, SkipTabs::Result(_, true))
} }

View file

@ -35,7 +35,7 @@
mod char_traits; mod char_traits;
#[macro_use] #[macro_use]
mod debug; mod debug;
mod input; pub mod input;
mod parser; mod parser;
mod scanner; mod scanner;