Skip to content

Commit

Permalink
#74 doc formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Jan 11, 2023
1 parent 6f5bfcd commit c3c1c7f
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 9 deletions.
12 changes: 9 additions & 3 deletions src/alerts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ use anyhow::Result;
pub type Alert = fn(g: &Sodg, vx: Vec<u32>) -> Vec<String>;

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:
///
/// ```
Expand Down Expand Up @@ -58,15 +60,19 @@ 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<()> {
self.alerts_active = true;
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<u32>) -> Result<()> {
if self.alerts_active {
Expand Down
1 change: 1 addition & 0 deletions src/hex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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:
///
/// ```
Expand Down
4 changes: 3 additions & 1 deletion src/inspect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> {
let v = self
.find(0, loc, &mut DeadRelay::default())
Expand Down
4 changes: 3 additions & 1 deletion src/next.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 4 additions & 1 deletion src/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 `"𝜎"`.
///
Expand Down Expand Up @@ -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:
Expand Down
4 changes: 3 additions & 1 deletion src/script.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion src/serialization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<usize> {
let start = Instant::now();
Expand Down
4 changes: 3 additions & 1 deletion src/xml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit c3c1c7f

Please sign in to comment.