Skip to content

Commit

Permalink
improve sophia_api::ns documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
pchampin committed Nov 15, 2023
1 parent 88d31df commit 9316eb0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
8 changes: 4 additions & 4 deletions api/src/ns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
//!
//! This module provides:
//! * the [`Namespace`](struct.Namespace.html) type for defining custom dynamic namespace;
//! * the [`namespace`] macro, for defning custom static namespaces;
//! * the [`namespace`](crate::namespace) macro, for defning custom static namespaces;
//! * modules corresponding to the most common namespaces
//! (generated via the [`namespace`] macro).
//! (generated via the [`namespace`](crate::namespace) macro).
//!
//! # Example use
//! ```
Expand All @@ -21,8 +21,8 @@
//!
//! # Datatyped literals
//!
//! Note also that the terms generated via the [`namespace`] macro
//! can be used to easily produced datatyped literals,
//! Note also that the terms generated via the [`namespace`](crate::namespace) macro
//! can be used to easily produce datatyped literals,
//! by simply "multiplying" a string by its datatype:
//!
//! ```
Expand Down
18 changes: 18 additions & 0 deletions api/src/ns/_macro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,24 @@
/// This macro also create a test module to check that all created IRIs are valid.
///
/// This allows to skip those checks at runtime, keeping the initialization of the namespace fast.
///
/// # Example
/// ```
/// # #[macro_use] extern crate sophia_api;
/// # use sophia_iri::IriRef;
/// /// An example namespace module
/// pub mod ex {
/// namespace! {
/// "http://example.org/ns#",
/// Foo,
/// Bar,
/// Baz
/// }
/// }
///
/// assert_eq!(ex::Foo, IriRef::new_unchecked("http://example.org/ns#Foo"));
/// assert_eq!(ex::Bar, IriRef::new_unchecked("http://example.org/ns#Bar"));
/// ```
#[macro_export]
macro_rules! namespace {
($iri_prefix:expr, $($suffix:ident),*; $($r_id:ident, $r_sf:expr),*) => {
Expand Down

0 comments on commit 9316eb0

Please sign in to comment.