Skip to content

Commit

Permalink
Re-export the modules under the global namespace to make the imports …
Browse files Browse the repository at this point in the history
…less verbose
  • Loading branch information
d0rianb committed Aug 14, 2024
1 parent ed2f452 commit dc8a63f
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
11 changes: 4 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ The library is split into 2 main components:
The lexer scans the document and returns a `Vec<Token>` which represent the RTF file in a code-understandable manner.
These tokens can then be passed to the parser to transcript it to a real document : `RtfDocument`.
```rust
use rtf_parser::lexer::Lexer;
use rtf_parser::tokens::Token;
use rtf_parser::parser::Parser;
use rtf_parser::document::RtfDocument;
use rtf_parser::{ Lexer, Token, Parser, RtfDocument };

fn main() -> Result<(), Box<dyn Error>> {
let tokens: Vec<Token> = Lexer::scan("<rtf>")?;
Expand All @@ -40,7 +37,7 @@ fn main() -> Result<(), Box<dyn Error>> {
or in a more concise way :

```rust
use rtf_parser::document::RtfDocument;
use rtf_parser::RtfDocument;

fn main() -> Result<(), Box<dyn Error>> {
let doc: RtfDocument = RtfDocument::try_from("<rtf>")?;
Expand Down Expand Up @@ -104,8 +101,8 @@ fn main() -> Result<(), Box<dyn Error>> {
## Examples
A complete example of rtf parsing is presented below :
```rust
use rtf_parser::lexer::Lexer;
use rtf_parser::parser::Parser;
use rtf_parser::Lexer;
use rtf_parser::Parser;

fn main() -> Result<(), Box<dyn Error>> {
let rtf_text = r#"{ \rtf1\ansi{\fonttbl\f0\fswiss Helvetica;}\f0\pard Voici du texte en {\b gras}.\par }"#;
Expand Down
4 changes: 1 addition & 3 deletions examples/bench.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
use std::time::Instant;

use rtf_parser::header::StyleSheet;
use rtf_parser::lexer::Lexer;
use rtf_parser::parser::Parser;
use rtf_parser::{Lexer, Parser, StyleSheet};

fn main() {
let start = Instant::now();
Expand Down
4 changes: 1 addition & 3 deletions examples/load_file.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
extern crate rtf_parser;
use rtf_parser::header::StyleSheet;
use rtf_parser::lexer::Lexer;
use rtf_parser::parser::Parser;
use rtf_parser::{Lexer, Parser, StyleSheet};

fn main() {
let rtf_text = include_str!("../resources/tests/file-sample_500kB.rtf");
Expand Down
8 changes: 8 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,11 @@ pub mod paragraph;
pub mod parser;
pub mod tokens;
mod utils;

// Re-export all the symbols to the global rtf-parser namespace
pub use document::*;
pub use header::*;
pub use lexer::*;
pub use paragraph::*;
pub use parser::*;
pub use tokens::*;

0 comments on commit dc8a63f

Please sign in to comment.