Skip to content

Commit

Permalink
docs: Add extra links
Browse files Browse the repository at this point in the history
Signed-off-by: Dmitry Dygalo <dmitry@dygalo.dev>
  • Loading branch information
Stranger6667 committed Sep 19, 2024
1 parent 3c84921 commit ddb8aaf
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 18 deletions.
6 changes: 3 additions & 3 deletions crates/jsonschema/src/compilation/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pub(crate) static DEFAULT_SCOPE: Lazy<Url> =
fn deprecated_features_used() {}

impl Validator {
/// Create a default `ValidationOptions` for configuring JSON Schema validation.
/// Create a default [`ValidationOptions`] for configuring JSON Schema validation.
///
/// Use this to set the draft version and other validation parameters.
///
Expand Down Expand Up @@ -91,14 +91,14 @@ impl Validator {
}
/// Run validation against `instance` but return a boolean result instead of an iterator.
/// It is useful for cases, where it is important to only know the fact if the data is valid or not.
/// This approach is much faster, than `validate`.
/// This approach is much faster, than [`Validator::validate`].
#[must_use]
#[inline]
pub fn is_valid(&self, instance: &Value) -> bool {
self.node.is_valid(instance)
}

/// Apply the schema and return an `Output`. No actual work is done at this point, the
/// Apply the schema and return an [`Output`]. No actual work is done at this point, the
/// evaluation of the schema is deferred until a method is called on the `Output`. This is
/// because different output formats will have different performance characteristics.
///
Expand Down
2 changes: 1 addition & 1 deletion crates/jsonschema/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub struct ValidationError<'a> {
pub schema_path: JsonPointer,
}

/// An iterator over instances of `ValidationError` that represent validation error for the
/// An iterator over instances of [`ValidationError`] that represent validation error for the
/// input instance.
///
/// # Examples
Expand Down
7 changes: 4 additions & 3 deletions crates/jsonschema/src/keywords/custom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl Validate for CustomKeyword {

/// Trait that allows implementing custom validation for keywords.
pub trait Keyword: Send + Sync {
/// Validate [instance](Value) according to a custom specification
/// Validate instance according to a custom specification.
///
/// A custom keyword validator may be used when a validation that cannot be
/// easily or efficiently expressed in JSON schema.
Expand All @@ -49,8 +49,9 @@ pub trait Keyword: Send + Sync {
instance: &'instance Value,
instance_path: &JsonPointerNode,
) -> ErrorIterator<'instance>;
/// Validate [instance](Value) and return a boolean result.
/// Could be potentilly faster than `validate` method.
/// Validate instance and return a boolean result.
///
/// Could be potentilly faster than [`Keyword::validate`] method.
fn is_valid(&self, instance: &Value) -> bool;
}

Expand Down
6 changes: 3 additions & 3 deletions crates/jsonschema/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
//!
//! The `jsonschema` crate offers two main approaches to validation: one-off validation and reusable validators.
//!
//! For simple use cases where you need to validate an instance against a schema once, use the `is_valid` function:
//! For simple use cases where you need to validate an instance against a schema once, use the [`is_valid`] function:
//!
//! ```rust
//! use serde_json::json;
Expand Down Expand Up @@ -88,7 +88,7 @@
//! # }
//! ```
//!
//! You can also use the convenience `is_valid` function for quick validation:
//! You can also use the convenience [`is_valid`] function for quick validation:
//!
//! ```rust
//! use serde_json::json;
Expand Down Expand Up @@ -445,7 +445,7 @@
//! ### Notes on Custom Format Validators
//!
//! - Custom format validators are only called for string instances.
//! - Format validation can be disabled globally or per-draft using `ValidationOptions`.
//! - Format validation can be disabled globally or per-draft using [`ValidationOptions`].
//! Ensure format validation is enabled if you're using custom formats.
mod compilation;
mod content_encoding;
Expand Down
4 changes: 2 additions & 2 deletions crates/jsonschema/src/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ impl<'a, 'b> Output<'a, 'b> {
/// and where in the instance). The difference between the
/// `BasicOutput::Valid` and `BasicOutput::Invalid` cases is the value which
/// is associated with each `OutputUnit`. For `Valid` outputs the value is
/// an annotation, whilst for `Invalid` outputs it's an `ErrorDescription`
/// an annotation, whilst for `Invalid` outputs it's an [`ErrorDescription`]
/// (a `String` really).
///
/// # Examples
Expand Down Expand Up @@ -313,7 +313,7 @@ impl<'a> From<serde_json::Value> for Annotations<'a> {
}
}

/// An error associated with an `OutputUnit`
/// An error associated with an [`OutputUnit`]
#[derive(serde::Serialize, Debug, Clone, PartialEq, Eq)]
pub struct ErrorDescription(String);

Expand Down
4 changes: 2 additions & 2 deletions crates/jsonschema/src/paths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ pub enum PathChunk {
Keyword(&'static str),
}

/// A borrowed variant of `PathChunk`.
/// A borrowed variant of [`PathChunk`].
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum PathChunkRef<'a> {
/// Property name within a JSON object.
Expand All @@ -123,7 +123,7 @@ pub enum PathChunkRef<'a> {

/// A node in a linked list representing a JSON pointer.
///
/// `JsonPointerNode` is used to build a JSON pointer incrementally during the JSON Schema validation process.
/// [`JsonPointerNode`] is used to build a JSON pointer incrementally during the JSON Schema validation process.
/// Each node contains a segment of the JSON pointer and a reference to its parent node, forming
/// a linked list.
///
Expand Down
4 changes: 2 additions & 2 deletions crates/jsonschema/src/primitive_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ fn bit_map_representation_primitive_type(bit_representation: u8) -> PrimitiveTyp
}
}

/// Compact representation of multiple `PrimitiveType`
/// Compact representation of multiple [`PrimitiveType`]
#[derive(Clone, Copy, Debug)]
pub struct PrimitiveTypesBitMap {
inner: u8,
Expand Down Expand Up @@ -134,7 +134,7 @@ impl From<Vec<PrimitiveType>> for PrimitiveTypesBitMap {
}
}

/// Iterator over all `PrimitiveType` present in a `PrimitiveTypesBitMap`
/// Iterator over all [`PrimitiveType`] present in a [`PrimitiveTypesBitMap`]
#[derive(Debug)]
pub struct PrimitiveTypesBitMapIterator {
idx: u8,
Expand Down
4 changes: 2 additions & 2 deletions crates/jsonschema/src/schemas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ impl Draft {
}
}

/// Get the `Draft` from a JSON Schema URL.
/// Get the [`Draft`] from a JSON Schema URL.
#[inline]
pub(crate) fn draft_from_url(url: &str) -> Option<Draft> {
match url.trim_end_matches('#') {
Expand All @@ -146,7 +146,7 @@ pub(crate) fn draft_from_url(url: &str) -> Option<Draft> {
}
}

/// Get the `Draft` from a JSON Schema.
/// Get the [`Draft`] from a JSON Schema.
#[inline]
pub(crate) fn draft_from_schema(schema: &Value) -> Option<Draft> {
schema
Expand Down

0 comments on commit ddb8aaf

Please sign in to comment.