Skip to content

Commit

Permalink
ilex: Unbreak docs
Browse files Browse the repository at this point in the history
  • Loading branch information
mcy committed Jan 2, 2025
1 parent 66b9328 commit 408588e
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 9 deletions.
6 changes: 4 additions & 2 deletions ilex/src/file/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ use crate::report;
use crate::report::Fatal;
use crate::report::Report;

#[cfg(doc)]
use crate::Span;

/// A source context, which owns source code files.
///
/// A `Context` contains the full text of all the loaded source files, which
/// [`SpanId`]s ultimately refer to. Most [`SpanId`] operations need their
/// corresponding `Context` available.
/// [`Span`]s ultimately refer to.
#[derive(Default)]
pub struct Context {
state: Arc<RwLock<State>>,
Expand Down
4 changes: 2 additions & 2 deletions ilex/src/file/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ pub trait Spanned<'ctx> {
/// Returns the span in this syntax element.
fn span(&self) -> Span<'ctx>;

/// Forwards to [`SpanId::file()`].
/// Forwards to [`Span::file()`].
fn file(&self) -> File<'ctx> {
self.span().file()
}
Expand All @@ -327,7 +327,7 @@ pub trait Spanned<'ctx> {
self.span().len()
}

/// Forwards to [`SpanId::text()`].
/// Forwards to [`Span::text()`].
fn text(&self) -> &'ctx str {
self.span().text()
}
Expand Down
7 changes: 5 additions & 2 deletions ilex/src/report/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//!
//! This module contains types for generating an *error report*: a collection of
//! diagnostics that describe why an operation failed in detail. Diagnostics
//! are basically fancy compiler errors: they use [`SpanId`]s to present faulty
//! are basically fancy compiler errors: they use [`Span`]s to present faulty
//! input in context.
//!
//! The [`Report`] type is a reference-counted list of diagnostics, which is
Expand All @@ -28,10 +28,13 @@ pub use builtin::Expected;
pub use diagnostic::Diagnostic;
use diagnostic::Kind;

#[cfg(doc)]
use crate::Span;

/// A collection of errors can may built up over the course of an operation.
///
/// To construct a report, see [`Context::new_report()`]. The context that
/// constructs a report is the only one whose [`SpanId`]s should be passed into
/// constructs a report is the only one whose [`Span`]s should be passed into
/// it; doing otherwise will result in unspecified output (or probably a panic).
pub struct Report {
ctx: Context,
Expand Down
2 changes: 1 addition & 1 deletion ilex/src/rule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1060,7 +1060,7 @@ impl TryFrom<Any> for Digital {
///
/// Comments do not generate tokens, unlike most rules. Instead, they are
/// attached to the span of a token, and can be inspected through
/// [`Span::comments()`][crate::Span::comments].
/// [`Token::comments()`][crate::Token::comments].
#[derive(Debug)]
pub struct Comment {
pub(crate) bracket: Bracket,
Expand Down
2 changes: 1 addition & 1 deletion ilex/src/token/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1000,7 +1000,7 @@ impl<'lex> Quoted<'lex> {
/// Returns the raw content of this token.
///
/// There are two kinds of content: either a literal span of Unicode scalars
/// (represented as a [`SpanId`] pointing to those characters) or a single
/// (represented as a [`Span`] pointing to those characters) or a single
/// escape, potentially with some side data.
///
/// It is up to the user of the library to decode these two content types into
Expand Down
2 changes: 1 addition & 1 deletion ilex/src/token/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ pub struct Comments<'lex> {
}

impl<'lex> Comments<'lex> {
/// Adapts this iterator to return just the text contents of each [`SpanId`].
/// Adapts this iterator to return just the text contents of each [`Span`].
pub fn as_strings(self) -> impl Iterator<Item = &'lex str> + 'lex {
self.map(Span::text)
}
Expand Down

0 comments on commit 408588e

Please sign in to comment.