diff --git a/src/config.rs b/src/config.rs index 26a08ad..352811f 100644 --- a/src/config.rs +++ b/src/config.rs @@ -85,7 +85,7 @@ impl Config { /// # Examples /// /// ``` - /// use risp::config::Config; + /// use risp::Config; /// use std::path::Path; /// /// let (law_id, builder, parser) = Config::load(Path::new("data/configs/abgb.toml")).unwrap(); diff --git a/src/law/mod.rs b/src/law/mod.rs index 2a21c34..904b625 100644 --- a/src/law/mod.rs +++ b/src/law/mod.rs @@ -14,6 +14,8 @@ // See the Licence for the specific language governing permissions and // limitations under the Licence. +//! Represents a parsed law text. + use log::{debug, info}; use serde::{Deserialize, Serialize}; use std::{ @@ -168,7 +170,12 @@ impl From for Vec { } } -/// Is used to generate a law struct. It's organized mainly by classifier. +/// A `Builder` struct for constructing a `Law` structure. +/// +/// This struct is designed to facilitate the building of a `Law`'s structure, primarily organized by +/// a set of classifiers. Each classifier represents a hierarchical level within the law, such as +/// chapters, sections, or articles. The builder pattern is used to incrementally construct the +/// law, allowing for the addition of headers, paragraphs, and notes in a structured manner. #[derive(Debug)] pub struct Builder { name: String, @@ -281,7 +288,7 @@ impl Builder { /// # Examples /// /// ``` - /// use risp::{config::Config, law::{Law, Heading}}; + /// use risp::{Config, law::{Law, Heading}}; /// use std::path::Path; /// /// let (_, mut builder, _) = Config::load(Path::new("data/configs/abgb.toml")).unwrap(); @@ -374,7 +381,7 @@ impl Builder { /// /// # Examples /// ``` - /// use risp::{config::Config, law::{Law, Heading}}; + /// use risp::{Config, law::{Law, Heading}}; /// use std::path::Path; /// /// let (_, mut builder, _) = Config::load(Path::new("data/configs/abgb.toml")).unwrap(); @@ -434,7 +441,7 @@ impl Builder { /// Assuming `law` is a mutable reference to an instance of a law struct: /// /// ``` - /// use risp::{config::Config, law::{Law, Heading, Content, HeadingContent, Section}}; + /// use risp::{Config, law::{Law, Heading, Content, HeadingContent, Section}}; /// use std::path::Path; /// /// let (_, mut builder, _) = Config::load(Path::new("data/configs/abgb.toml")).unwrap(); @@ -601,11 +608,42 @@ impl From<&str> for ClassifierInstance { pub(crate) type ClassifierApplicable = Arc bool>; #[derive(Clone)] +/// Represents a structural element within a legal document, such as a chapter, section, or +/// article. +/// +/// A `Classifier` is used to categorize parts of a legal document into hierarchical levels, aiding +/// in the organization and navigation of the content. It can represent various structural elements +/// like chapters, sections, articles, etc., depending on the specific needs of the legal document +/// being processed. +/// +/// # Examples +/// +/// ``` +/// use std::{sync::Arc, rc::Rc, cell::RefCell}; +/// use risp::law::Classifier; +/// +/// fn starts_with(classifier_name: &str, title: &str) -> bool { +/// title.starts_with(classifier_name) +/// } +/// +/// let chapter_classifier = Classifier::new("Chapter", Arc::new(starts_with)); +/// +/// let chapter_classifier = chapter_classifier.root(); +/// ``` pub struct Classifier { - pub name: String, // Hauptstück, Theil, Abschnitt, ol + /// The name or title of the classifier (e.g., "Hauptstück", "Theil", "Abschnitt"). + pub name: String, + pub(crate) used_for_fn: ClassifierApplicable, + instances: Vec, + + /// Child classifiers. This enables a hierarchical structure where classifiers can contain + /// nested levels of other classifiers. pub child: Vec>>, + + /// Specifies whether this classifier is a root element of the document structure. Root + /// classifiers are typically top-level elements like major divisions or parts of a document. pub root: bool, } @@ -616,6 +654,7 @@ impl PartialEq for Classifier { } impl Classifier { + /// Constructs a new `Classifier` with the specified name and applicability function. pub fn new(name: &str, used_for_fn: ClassifierApplicable) -> Self { Self { name: name.into(), @@ -627,6 +666,7 @@ impl Classifier { } #[must_use] + /// Marks the classifier as a root element, returning a modified instance of the classifier. pub fn root(self) -> Self { Self { root: true, ..self } } diff --git a/src/lib.rs b/src/lib.rs index de6390f..7a515b8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -14,8 +14,12 @@ // See the Licence for the specific language governing permissions and // limitations under the Licence. -pub mod config; -pub mod misc; +mod config; +pub use config::Config; + +mod misc; +pub use misc::clear_cache; +pub use misc::Error; pub mod law; pub mod overview; diff --git a/src/main.rs b/src/main.rs index 0217fdd..0b74d5e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -18,9 +18,9 @@ use std::sync::Arc; use clap::{command, Parser}; use risp::{ - config::Config, + clear_cache, law::{responsible::always_true, Classifier, Law}, - misc::clear_cache, + Config, }; #[derive(Parser, Debug)] diff --git a/src/paragraph/mod.rs b/src/paragraph/mod.rs index eac1cc5..bb7daab 100644 --- a/src/paragraph/mod.rs +++ b/src/paragraph/mod.rs @@ -14,7 +14,7 @@ // See the Licence for the specific language governing permissions and // limitations under the Licence. -//! Deals with getting all paragraphs for a given law text +//! Deals with getting the content of a single paragraph. mod parser; @@ -101,7 +101,7 @@ impl Parser { /// # Example Usage /// /// ``` - /// use risp::{config::Config, law::{Law, Heading, Content, Section, HeadingContent}}; + /// use risp::{Config, law::{Law, Heading, Content, Section, HeadingContent}}; /// use std::path::Path; /// /// let (_, mut builder, parser) = Config::load(Path::new("data/configs/abgb.toml")).unwrap();