From ddb8aaf4a1ddb5d8a943f3f261d7c50f761ec5f6 Mon Sep 17 00:00:00 2001 From: Dmitry Dygalo Date: Thu, 19 Sep 2024 08:38:01 +0200 Subject: [PATCH] docs: Add extra links Signed-off-by: Dmitry Dygalo --- crates/jsonschema/src/compilation/mod.rs | 6 +++--- crates/jsonschema/src/error.rs | 2 +- crates/jsonschema/src/keywords/custom.rs | 7 ++++--- crates/jsonschema/src/lib.rs | 6 +++--- crates/jsonschema/src/output.rs | 4 ++-- crates/jsonschema/src/paths.rs | 4 ++-- crates/jsonschema/src/primitive_type.rs | 4 ++-- crates/jsonschema/src/schemas.rs | 4 ++-- 8 files changed, 19 insertions(+), 18 deletions(-) diff --git a/crates/jsonschema/src/compilation/mod.rs b/crates/jsonschema/src/compilation/mod.rs index e8581933..ae2958a8 100644 --- a/crates/jsonschema/src/compilation/mod.rs +++ b/crates/jsonschema/src/compilation/mod.rs @@ -45,7 +45,7 @@ pub(crate) static DEFAULT_SCOPE: Lazy = 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. /// @@ -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. /// diff --git a/crates/jsonschema/src/error.rs b/crates/jsonschema/src/error.rs index b31d90dc..32007326 100644 --- a/crates/jsonschema/src/error.rs +++ b/crates/jsonschema/src/error.rs @@ -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 diff --git a/crates/jsonschema/src/keywords/custom.rs b/crates/jsonschema/src/keywords/custom.rs index 4a9dcfa8..08132453 100644 --- a/crates/jsonschema/src/keywords/custom.rs +++ b/crates/jsonschema/src/keywords/custom.rs @@ -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. @@ -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; } diff --git a/crates/jsonschema/src/lib.rs b/crates/jsonschema/src/lib.rs index c68efa32..5be99dfa 100644 --- a/crates/jsonschema/src/lib.rs +++ b/crates/jsonschema/src/lib.rs @@ -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; @@ -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; @@ -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; diff --git a/crates/jsonschema/src/output.rs b/crates/jsonschema/src/output.rs index 91a47205..da0c442d 100644 --- a/crates/jsonschema/src/output.rs +++ b/crates/jsonschema/src/output.rs @@ -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 @@ -313,7 +313,7 @@ impl<'a> From 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); diff --git a/crates/jsonschema/src/paths.rs b/crates/jsonschema/src/paths.rs index 84af1805..4c867f8d 100644 --- a/crates/jsonschema/src/paths.rs +++ b/crates/jsonschema/src/paths.rs @@ -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. @@ -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. /// diff --git a/crates/jsonschema/src/primitive_type.rs b/crates/jsonschema/src/primitive_type.rs index eeb76123..9bce19fa 100644 --- a/crates/jsonschema/src/primitive_type.rs +++ b/crates/jsonschema/src/primitive_type.rs @@ -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, @@ -134,7 +134,7 @@ impl From> 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, diff --git a/crates/jsonschema/src/schemas.rs b/crates/jsonschema/src/schemas.rs index 4d2b0265..03c88810 100644 --- a/crates/jsonschema/src/schemas.rs +++ b/crates/jsonschema/src/schemas.rs @@ -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 { match url.trim_end_matches('#') { @@ -146,7 +146,7 @@ pub(crate) fn draft_from_url(url: &str) -> Option { } } -/// Get the `Draft` from a JSON Schema. +/// Get the [`Draft`] from a JSON Schema. #[inline] pub(crate) fn draft_from_schema(schema: &Value) -> Option { schema