Offline, privacy-first grammar checker. Fast, open-source, Rust-powered
docs(harper.js): added comments to public types
Elijah Potterce796556f0d3
diff --git a/harper-wasm/src/lib.rs b/harper-wasm/src/lib.rsindex 20a0dbfae..8448aac2d 100644--- a/harper-wasm/src/lib.rs+++ b/harper-wasm/src/lib.rs@@ -155,17 +155,22 @@ pub fn apply_suggestion(Ok(source.iter().collect())}+/// A suggestion to fix a Lint.#[derive(Debug, Serialize, Deserialize)]#[wasm_bindgen]pub struct Suggestion {inner: harper_core::linting::Suggestion,}+/// Tags the variant of suggestion.#[derive(Debug, Serialize, Deserialize)]#[wasm_bindgen]pub enum SuggestionKind {+ /// Replace the problematic text.Replace = 0,+ /// Remove the problematic text.Remove = 1,+ /// Insert additional text after the error.InsertAfter = 2,}@@ -195,6 +200,9 @@ impl Suggestion {}}+/// An error found in provided text.+///+/// May include zero or more suggestions that may fix the problematic text.#[derive(Debug, Deserialize, Serialize)]#[wasm_bindgen]pub struct Lint {@@ -218,10 +226,12 @@ impl Lint {self.inner.lint_kind.to_string()}+ /// Equivalent to calling `.length` on the result of `suggestions()`.pub fn suggestion_count(&self) -> usize {self.inner.suggestions.len()}+ /// Get an array of any suggestions that may resolve the issue.pub fn suggestions(&self) -> Vec<Suggestion> {self.inner.suggestions@@ -230,15 +240,18 @@ impl Lint {.collect()}+ /// Get the location of the problematic text.pub fn span(&self) -> Span {self.inner.span.into()}+ /// Get a description of the error.pub fn message(&self) -> String {self.inner.message.clone()}}+/// A struct that represents two character indices in a string: a start and an end.#[derive(Debug, Clone, Copy, Serialize, Deserialize)]#[wasm_bindgen]pub struct Span {diff --git a/packages/harper.js/src/WorkerLinter/index.ts b/packages/harper.js/src/WorkerLinter/index.tsindex 7710140c7..b83da95ab 100644--- a/packages/harper.js/src/WorkerLinter/index.ts+++ b/packages/harper.js/src/WorkerLinter/index.ts@@ -15,8 +15,7 @@ type RequestItem = {/** A Linter that spins up a dedicated web worker to do processing on a separate thread.* Main benefit: this Linter will not block the event loop for large documents.*- * NOTE: This class will not work properly in Node. In that case, just use `LocalLinter`.- * Also requires top-level await to work. */+ * NOTE: This class will not work properly in Node. In that case, just use `LocalLinter`. */export default class WorkerLinter implements Linter {private worker;private requestQueue: RequestItem[];diff --git a/packages/harper.js/src/main.ts b/packages/harper.js/src/main.tsindex b043b11d3..aa556afe0 100644--- a/packages/harper.js/src/main.ts+++ b/packages/harper.js/src/main.ts@@ -6,4 +6,7 @@ import WorkerLinter from './WorkerLinter';export { LocalLinter, WorkerLinter, SuggestionKind };export type { Linter, Lint, Span, Suggestion };++/** A linting rule configuration dependent on upstream Harper's available rules.+ * This is a record, since you shouldn't hard-code the existence of any particular rules and should generalize based on this struct. */export type LintConfig = Record<string, boolean | undefined>;