From c3c1c7f05080dc6c0b52fb5c068e9461b3cde45e Mon Sep 17 00:00:00 2001 From: Yegor Bugayenko Date: Wed, 11 Jan 2023 11:22:01 +0300 Subject: [PATCH] #74 doc formatting --- src/alerts.rs | 12 +++++++++--- src/hex.rs | 1 + src/inspect.rs | 4 +++- src/next.rs | 4 +++- src/ops.rs | 5 ++++- src/script.rs | 4 +++- src/serialization.rs | 4 +++- src/xml.rs | 4 +++- 8 files changed, 29 insertions(+), 9 deletions(-) diff --git a/src/alerts.rs b/src/alerts.rs index 997e93f..d4ec405 100644 --- a/src/alerts.rs +++ b/src/alerts.rs @@ -27,7 +27,9 @@ use anyhow::Result; pub type Alert = fn(g: &Sodg, vx: Vec) -> Vec; impl Sodg { - /// Attach a new alert to this SODG. For example, you don't want + /// Attach a new alert to this SODG. + /// + /// For example, you don't want /// more than one edge to depart from any vertex: /// /// ``` @@ -58,7 +60,9 @@ impl Sodg { self.alerts_active = false; } - /// Enable all alerts. This function also runs all vertices through + /// Enable all alerts. + /// + /// This function also runs all vertices through /// all checks and returns the list of errors found. If everything /// was fine, an empty vector is returned. pub fn alerts_on(&mut self) -> Result<()> { @@ -66,7 +70,9 @@ impl Sodg { self.validate(self.vertices.keys().cloned().collect()) } - /// Check all alerts for the given list of vertices. If any of them + /// Check all alerts for the given list of vertices. + /// + /// If any of them /// have any issues, `Err` is returned. pub fn validate(&self, vx: Vec) -> Result<()> { if self.alerts_active { diff --git a/src/hex.rs b/src/hex.rs index 9074a5e..069b12d 100644 --- a/src/hex.rs +++ b/src/hex.rs @@ -25,6 +25,7 @@ use std::str::FromStr; /// It is an object-oriented representation of binary data /// in hexadecimal format, which can be put into vertices of the graph. +/// /// You can create it from Rust primitives: /// /// ``` diff --git a/src/inspect.rs b/src/inspect.rs index a101594..27786da 100644 --- a/src/inspect.rs +++ b/src/inspect.rs @@ -26,7 +26,9 @@ use std::collections::HashSet; impl Sodg { /// Finds an object by the provided locator and prints its tree - /// of sub-objects and edges. Mostly used for testing. + /// of sub-objects and edges. + /// + /// The function is mostly used for testing. pub fn inspect(&self, loc: &str) -> Result { let v = self .find(0, loc, &mut DeadRelay::default()) diff --git a/src/next.rs b/src/next.rs index e83cab9..b809a32 100644 --- a/src/next.rs +++ b/src/next.rs @@ -21,7 +21,9 @@ use crate::Sodg; impl Sodg { - /// Get next unique ID of a vertex. This ID will never be + /// Get next unique ID of a vertex. + /// + /// This ID will never be /// returned by `next()` again. Also, this ID will not /// be equal to any of the existing IDs of vertices. pub fn next_id(&mut self) -> u32 { diff --git a/src/ops.rs b/src/ops.rs index b8ef39a..afde626 100644 --- a/src/ops.rs +++ b/src/ops.rs @@ -48,7 +48,9 @@ impl Sodg { Ok(()) } - /// Makes an edge `e1` from vertex `v1` to vertex `v2` and puts `a` label on it. If the + /// Makes an edge `e1` from vertex `v1` to vertex `v2` and puts `a` label on it. + /// + /// If the /// label is not equal to `"ρ"`, makes two backward edges from `v2` to `v1` /// and label them as `"ρ"` an `"𝜎"`. /// @@ -225,6 +227,7 @@ impl Sodg { } /// Get a locator of an edge, if it exists. + /// /// The name of the edge may be a composite of two parts, for example /// `π/Φ.foo` or `foo/ν6.boom.x.y`. The parts are separated by the /// forward slash. This function returns the second part if it exists: diff --git a/src/script.rs b/src/script.rs index 32c5934..fed882d 100644 --- a/src/script.rs +++ b/src/script.rs @@ -46,7 +46,9 @@ pub struct Script { } impl Script { - /// Make a new one, parsing a string with instructions. Instructions + /// Make a new one, parsing a string with instructions. + /// + /// Instructions /// must be separated by semicolon. There are just three of them /// possible: `ADD`, `BIND`, and `PUT`. The arguments must be /// separated by a comma. An argument may either be 1) a positive integer diff --git a/src/serialization.rs b/src/serialization.rs index 9ced8a0..7a3b473 100644 --- a/src/serialization.rs +++ b/src/serialization.rs @@ -27,7 +27,9 @@ use std::path::Path; use std::time::Instant; impl Sodg { - /// Save the entire Sodg into a binary file. The entire Sodg + /// Save the entire Sodg into a binary file. + /// + /// The entire Sodg /// can be restored from the file. Returns the size of the file just saved. pub fn save(&mut self, path: &Path) -> Result { let start = Instant::now(); diff --git a/src/xml.rs b/src/xml.rs index e203ffc..a000ea7 100644 --- a/src/xml.rs +++ b/src/xml.rs @@ -24,7 +24,9 @@ use itertools::Itertools; use xml_builder::{XMLBuilder, XMLElement, XMLVersion}; impl Sodg { - /// Make XML graph. For example, for this code: + /// Make XML graph. + /// + /// For example, for this code: /// /// ``` /// use sodg::Hex;