Added missing docs

This commit is contained in:
Armin Ronacher 2021-01-31 19:35:20 +01:00
parent 7abcdc09d8
commit 158c28784d
6 changed files with 25 additions and 1 deletions

View file

@ -9,27 +9,40 @@ use std::ops::Range;
pub enum DiffOp { pub enum DiffOp {
/// A segment is equal (see [`DiffHook::equal`]) /// A segment is equal (see [`DiffHook::equal`])
Equal { Equal {
/// The starting index in the old sequence.
old_index: usize, old_index: usize,
/// The starting index in the new sequence.
new_index: usize, new_index: usize,
/// The length of the segment.
len: usize, len: usize,
}, },
/// A segment was deleted (see [`DiffHook::delete`]) /// A segment was deleted (see [`DiffHook::delete`])
Delete { Delete {
/// The starting index in the old sequence.
old_index: usize, old_index: usize,
/// The length of the old segment.
old_len: usize, old_len: usize,
/// The starting index in the new sequence.
new_index: usize, new_index: usize,
}, },
/// A segment was inserted (see [`DiffHook::insert`]) /// A segment was inserted (see [`DiffHook::insert`])
Insert { Insert {
/// The starting index in the old sequence.
old_index: usize, old_index: usize,
/// The starting index in the new sequence.
new_index: usize, new_index: usize,
/// The length of the new segment.
new_len: usize, new_len: usize,
}, },
/// A segment was replaced (see [`DiffHook::replace`]) /// A segment was replaced (see [`DiffHook::replace`])
Replace { Replace {
/// The starting index in the old sequence.
old_index: usize, old_index: usize,
/// The length of the old segment.
old_len: usize, old_len: usize,
/// The starting index in the new sequence.
new_index: usize, new_index: usize,
/// The length of the new segment.
new_len: usize, new_len: usize,
}, },
} }
@ -37,9 +50,13 @@ pub enum DiffOp {
/// The tag of a diff operation. /// The tag of a diff operation.
#[derive(Debug, PartialEq, Eq, Hash, Clone, Copy, Ord, PartialOrd)] #[derive(Debug, PartialEq, Eq, Hash, Clone, Copy, Ord, PartialOrd)]
pub enum DiffTag { pub enum DiffTag {
/// The diff op encodes an equal segment.
Equal, Equal,
/// The diff op encodes a deleted segment.
Delete, Delete,
/// The diff op encodes an inserted segment.
Insert, Insert,
/// The diff op encodes a replaced segment.
Replace, Replace,
} }

View file

@ -1,6 +1,7 @@
/// A trait for reacting to an edit script from the "old" version to /// A trait for reacting to an edit script from the "old" version to
/// the "new" version. /// the "new" version.
pub trait DiffHook: Sized { pub trait DiffHook: Sized {
/// The error produced from the hook methods.
type Error; type Error;
/// Called when lines with indices `old_index` (in the old version) and /// Called when lines with indices `old_index` (in the old version) and

View file

@ -34,7 +34,9 @@ pub mod patience;
/// An enum representing a diffing algorithm. /// An enum representing a diffing algorithm.
#[derive(Clone, Copy, Hash, PartialEq, Eq, PartialOrd, Ord, Debug)] #[derive(Clone, Copy, Hash, PartialEq, Eq, PartialOrd, Ord, Debug)]
pub enum Algorithm { pub enum Algorithm {
/// Picks the myers algorithm from [`myers`]
Myers, Myers,
/// Picks the patience algorithm from [`patience`]
Patience, Patience,
} }

View file

@ -43,5 +43,6 @@
//! is particularly useful when working with text containing emojis. //! is particularly useful when working with text containing emojis.
//! * `text`: this feature is enabled by default and enables the [`text`] module. //! * `text`: this feature is enabled by default and enables the [`text`] module.
//! If the crate is used without default features it's removed. //! If the crate is used without default features it's removed.
#![warn(missing_docs)]
pub mod algorithms; pub mod algorithms;
pub mod text; pub mod text;

View file

@ -215,8 +215,11 @@ pub struct TextDiff<'old, 'new, 'bufs> {
/// The tag of a change. /// The tag of a change.
#[derive(Debug, PartialEq, Eq, Hash, Clone, Copy, Ord, PartialOrd)] #[derive(Debug, PartialEq, Eq, Hash, Clone, Copy, Ord, PartialOrd)]
pub enum ChangeTag { pub enum ChangeTag {
/// The change indicates equality (not a change)
Equal, Equal,
/// The change indicates deleted text.
Delete, Delete,
/// The change indicates inserted text.
Insert, Insert,
} }

View file

@ -223,7 +223,7 @@ impl<'diff, 'old, 'new, 'bufs> fmt::Display for UnifiedDiffHunk<'diff, 'old, 'ne
if self.missing_newline_hint { if self.missing_newline_hint {
writeln!(f, "\n\\ No newline at end of file")?; writeln!(f, "\n\\ No newline at end of file")?;
} else { } else {
writeln!(f, "")?; writeln!(f)?;
} }
} }
} }