From 69fdbee250ebfce135bff2671226097bc536d953 Mon Sep 17 00:00:00 2001 From: Martin Fischer Date: Sat, 12 Aug 2023 11:50:46 +0200 Subject: break!: stop re-exporting reader traits & types This is primarily done to make the rustdoc more readable (by grouping Reader, IntoReader, StringReader and BufReadReader in the reader module). Ideally IntoReader is already implemented for your input type and you don't have to concern yourself with these traits / types at all. --- integration_tests/tests/test_html5lib.rs | 2 +- src/lib.rs | 3 +-- src/machine.rs | 2 +- src/reader.rs | 2 ++ src/spans.rs | 2 +- src/tokenizer.rs | 3 ++- 6 files changed, 8 insertions(+), 6 deletions(-) diff --git a/integration_tests/tests/test_html5lib.rs b/integration_tests/tests/test_html5lib.rs index f5a69c3..209e199 100644 --- a/integration_tests/tests/test_html5lib.rs +++ b/integration_tests/tests/test_html5lib.rs @@ -3,7 +3,7 @@ use std::{fs::File, io::BufReader, path::Path}; use html5lib_tests::{ parse_tests, Error as TestError, InitialState, Output, Test, Token as TestToken, }; -use html5tokenizer::{DefaultEmitter, InternalState, Reader, Token, Tokenizer}; +use html5tokenizer::{reader::Reader, DefaultEmitter, InternalState, Token, Tokenizer}; use pretty_assertions::assert_eq; /// Path to a local checkout of [html5lib-tests], relative to the diff --git a/src/lib.rs b/src/lib.rs index 05e5824..12326ec 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -7,7 +7,7 @@ mod emitter; mod entities; mod error; mod machine; -mod reader; +pub mod reader; pub mod spans; mod tokenizer; mod utils; @@ -17,5 +17,4 @@ pub use utils::State as InternalState; pub use emitter::{Attribute, DefaultEmitter, Doctype, Emitter, EndTag, StartTag, Token}; pub use error::Error; -pub use reader::{BufReadReader, IntoReader, Reader, StringReader}; pub use tokenizer::{State, Tokenizer}; diff --git a/src/machine.rs b/src/machine.rs index 8c062ec..aa07900 100644 --- a/src/machine.rs +++ b/src/machine.rs @@ -3,7 +3,7 @@ use crate::utils::{ ascii_digit_pat, control_pat, ctostr, noncharacter_pat, surrogate_pat, whitespace_pat, ControlToken, State, }; -use crate::{Emitter, Error, Reader, Tokenizer}; +use crate::{reader::Reader, Emitter, Error, Tokenizer}; // Note: This is not implemented as a method on Tokenizer because there's fields on Tokenizer that // should not be available in this method, such as Tokenizer.to_reconsume or the Reader instance diff --git a/src/reader.rs b/src/reader.rs index fa83139..e0161e5 100644 --- a/src/reader.rs +++ b/src/reader.rs @@ -1,3 +1,5 @@ +//! Provides the [`Reader`] trait (and implementations) used by the tokenizer. + use std::convert::Infallible; use std::io::{self, BufRead, BufReader, Read}; diff --git a/src/spans.rs b/src/spans.rs index c3d269d..0a29eb2 100644 --- a/src/spans.rs +++ b/src/spans.rs @@ -12,7 +12,7 @@ use std::ops::Range; -use crate::{IntoReader, Reader}; +use crate::reader::{IntoReader, Reader}; /// A trait to be implemented by readers that track their own position. pub trait GetPos { diff --git a/src/tokenizer.rs b/src/tokenizer.rs index 5abd6ba..62cc6a4 100644 --- a/src/tokenizer.rs +++ b/src/tokenizer.rs @@ -1,8 +1,9 @@ use crate::machine; +use crate::reader::{IntoReader, Reader}; use crate::utils::{ control_pat, noncharacter_pat, surrogate_pat, ControlToken, State as InternalState, }; -use crate::{DefaultEmitter, Emitter, Error, IntoReader, Reader}; +use crate::{DefaultEmitter, Emitter, Error}; // this is a stack that can hold 0 to 2 Ts #[derive(Debug, Default, Clone, Copy)] -- cgit v1.2.3