From 158c28784de5ace75097d70eaa2814de6b588512 Mon Sep 17 00:00:00 2001 From: Armin Ronacher Date: Sun, 31 Jan 2021 19:35:20 +0100 Subject: [PATCH] Added missing docs --- src/algorithms/capture.rs | 17 +++++++++++++++++ src/algorithms/hook.rs | 1 + src/algorithms/mod.rs | 2 ++ src/lib.rs | 1 + src/text/mod.rs | 3 +++ src/text/udiff.rs | 2 +- 6 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/algorithms/capture.rs b/src/algorithms/capture.rs index f2663bf..e97925e 100644 --- a/src/algorithms/capture.rs +++ b/src/algorithms/capture.rs @@ -9,27 +9,40 @@ use std::ops::Range; pub enum DiffOp { /// A segment is equal (see [`DiffHook::equal`]) Equal { + /// The starting index in the old sequence. old_index: usize, + /// The starting index in the new sequence. new_index: usize, + /// The length of the segment. len: usize, }, /// A segment was deleted (see [`DiffHook::delete`]) Delete { + /// The starting index in the old sequence. old_index: usize, + /// The length of the old segment. old_len: usize, + /// The starting index in the new sequence. new_index: usize, }, /// A segment was inserted (see [`DiffHook::insert`]) Insert { + /// The starting index in the old sequence. old_index: usize, + /// The starting index in the new sequence. new_index: usize, + /// The length of the new segment. new_len: usize, }, /// A segment was replaced (see [`DiffHook::replace`]) Replace { + /// The starting index in the old sequence. old_index: usize, + /// The length of the old segment. old_len: usize, + /// The starting index in the new sequence. new_index: usize, + /// The length of the new segment. new_len: usize, }, } @@ -37,9 +50,13 @@ pub enum DiffOp { /// The tag of a diff operation. #[derive(Debug, PartialEq, Eq, Hash, Clone, Copy, Ord, PartialOrd)] pub enum DiffTag { + /// The diff op encodes an equal segment. Equal, + /// The diff op encodes a deleted segment. Delete, + /// The diff op encodes an inserted segment. Insert, + /// The diff op encodes a replaced segment. Replace, } diff --git a/src/algorithms/hook.rs b/src/algorithms/hook.rs index 3666340..8106bcd 100644 --- a/src/algorithms/hook.rs +++ b/src/algorithms/hook.rs @@ -1,6 +1,7 @@ /// A trait for reacting to an edit script from the "old" version to /// the "new" version. pub trait DiffHook: Sized { + /// The error produced from the hook methods. type Error; /// Called when lines with indices `old_index` (in the old version) and diff --git a/src/algorithms/mod.rs b/src/algorithms/mod.rs index 3a870ef..04c8ec2 100644 --- a/src/algorithms/mod.rs +++ b/src/algorithms/mod.rs @@ -34,7 +34,9 @@ pub mod patience; /// An enum representing a diffing algorithm. #[derive(Clone, Copy, Hash, PartialEq, Eq, PartialOrd, Ord, Debug)] pub enum Algorithm { + /// Picks the myers algorithm from [`myers`] Myers, + /// Picks the patience algorithm from [`patience`] Patience, } diff --git a/src/lib.rs b/src/lib.rs index 4703aaa..5ed2b69 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -43,5 +43,6 @@ //! is particularly useful when working with text containing emojis. //! * `text`: this feature is enabled by default and enables the [`text`] module. //! If the crate is used without default features it's removed. +#![warn(missing_docs)] pub mod algorithms; pub mod text; diff --git a/src/text/mod.rs b/src/text/mod.rs index 238e401..5c204de 100644 --- a/src/text/mod.rs +++ b/src/text/mod.rs @@ -215,8 +215,11 @@ pub struct TextDiff<'old, 'new, 'bufs> { /// The tag of a change. #[derive(Debug, PartialEq, Eq, Hash, Clone, Copy, Ord, PartialOrd)] pub enum ChangeTag { + /// The change indicates equality (not a change) Equal, + /// The change indicates deleted text. Delete, + /// The change indicates inserted text. Insert, } diff --git a/src/text/udiff.rs b/src/text/udiff.rs index 8c58a89..303d62e 100644 --- a/src/text/udiff.rs +++ b/src/text/udiff.rs @@ -223,7 +223,7 @@ impl<'diff, 'old, 'new, 'bufs> fmt::Display for UnifiedDiffHunk<'diff, 'old, 'ne if self.missing_newline_hint { writeln!(f, "\n\\ No newline at end of file")?; } else { - writeln!(f, "")?; + writeln!(f)?; } } }