From 8e5ac6f2d4e52eea95e5a6fc2905ce511ac4956e Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sun, 2 Aug 2020 18:49:36 +0200 Subject: Add documentation comments Light documentation for our various functions and types. --- github-suggestion/src/suggestion.rs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'github-suggestion/src/suggestion.rs') diff --git a/github-suggestion/src/suggestion.rs b/github-suggestion/src/suggestion.rs index 2c92e6a..48fcb0c 100644 --- a/github-suggestion/src/suggestion.rs +++ b/github-suggestion/src/suggestion.rs @@ -40,6 +40,7 @@ enum LineEnding { CrLf, } +/// A suggestion comment extracted from the GitHub API. #[derive(Debug, Deserialize)] pub struct Suggestion { #[serde(rename = "diff_hunk")] @@ -60,12 +61,14 @@ pub struct Suggestion { } impl Suggestion { + /// Get the suggestion diff for the current repository. pub fn diff(&self) -> Result { let repo = Repository::open(".")?; self.diff_with_repo(&repo) } + /// Get the suggestion diff for `repo`. fn diff_with_repo(&self, repo: &Repository) -> Result { let commit = repo.find_commit(self.commit.parse()?)?; @@ -104,6 +107,7 @@ impl Suggestion { ) } + /// Extract suggestion code from a comment body. fn suggestion_with_line_ending( &self, line_ending: &LineEnding, @@ -120,6 +124,7 @@ impl Suggestion { Ok(s) } + /// Apply the suggestion to the current repository. pub fn apply(&self) -> Result<(), Error> { let repo = Repository::open(".")?; @@ -135,6 +140,7 @@ impl Suggestion { Ok(()) } + /// Apply the patch in `reader` to `writer`. fn apply_to( &self, reader: R, -- cgit v1.2.3