pub struct CheckableChunk { /* private fields */ }
Expand description
A chunk of documentation that is supposed to be checked.
Implementations§
Source§impl CheckableChunk
impl CheckableChunk
Sourcepub fn from_literalset(set: LiteralSet) -> Self
pub fn from_literalset(set: LiteralSet) -> Self
Specific to rust source code, either as part of doc test comments or file scope.
Sourcepub fn from_str(
content: &str,
source_mapping: IndexMap<Range, Span>,
variant: CommentVariant,
) -> Self
pub fn from_str( content: &str, source_mapping: IndexMap<Range, Span>, variant: CommentVariant, ) -> Self
Load content from string, may contain common mark content.
Sourcepub fn from_string(
content: String,
source_mapping: IndexMap<Range, Span>,
variant: CommentVariant,
) -> Self
pub fn from_string( content: String, source_mapping: IndexMap<Range, Span>, variant: CommentVariant, ) -> Self
Load content from string, may contain common mark content.
Sourcepub fn find_spans(&self, range: Range) -> IndexMap<Range, Span>
pub fn find_spans(&self, range: Range) -> IndexMap<Range, Span>
Find which part of the range maps to which span. Note that Range can very well be split into multiple fragments where each of them can be mapped to a potentially non-continuous span.
Example:
0..40 -> [
(0,10) => (1,0)->(3,5),
(10,12) => (3,6)->(3,7),
(13,17) => (4,0)->(4,3),
]
Sourcepub fn find_covered_spans(&self, range: Range) -> impl Iterator<Item = &Span>
pub fn find_covered_spans(&self, range: Range) -> impl Iterator<Item = &Span>
Extract all spans which at least partially overlap with range, i.e. report all spans that either
- contain
range.start
- contain
range.end
- are totally enclosed in
range
Example:
Below setup results in [s2, s3, s4]
|-- s1 --|-- s2 --|-- s3 --|-- s4 --|
|----- range -----|
Attention:
For large #[doc="long multiline text"]
comments, the covered span
might be large (i.e. just one single) which leads to a surprising result
of just one span for a relatively small input range
.
Below setup results in [s0]
|---...--- s0 ----------------------...---|
|--- range ---|
Sourcepub fn find_covered_lines(&self, range: Range) -> Vec<Range> ⓘ
pub fn find_covered_lines(&self, range: Range) -> Vec<Range> ⓘ
Yields a set of ranges covering all spanned lines (the full line).
Sourcepub fn extract_line_lengths(&self) -> Result<Vec<usize>>
pub fn extract_line_lengths(&self) -> Result<Vec<usize>>
Extract the overall length of all covered lines as they appear in the origin.
Sourcepub fn display(&self, range: Range) -> ChunkDisplay<'_>
pub fn display(&self, range: Range) -> ChunkDisplay<'_>
Get the display wrapper type to be used with i.e. format!(..)
.
Sourcepub fn fragment_count(&self) -> usize
pub fn fragment_count(&self) -> usize
Number of fragments.
A fragment is a continuous sub-string which is not split up any further.
Sourcepub fn erase_cmark(&self, ignores: &Ignores) -> PlainOverlay<'_>
pub fn erase_cmark(&self, ignores: &Ignores) -> PlainOverlay<'_>
Obtain an accessor object containing mapping and string representation, removing the markdown annotations.
Sourcepub fn len_in_chars(&self) -> usize
pub fn len_in_chars(&self) -> usize
Obtain the length in characters.
Sourcepub fn variant(&self) -> CommentVariant
pub fn variant(&self) -> CommentVariant
The variant type of comment.
Trait Implementations§
Source§impl Clone for CheckableChunk
impl Clone for CheckableChunk
Source§fn clone(&self) -> CheckableChunk
fn clone(&self) -> CheckableChunk
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for CheckableChunk
impl Debug for CheckableChunk
Source§impl Hash for CheckableChunk
impl Hash for CheckableChunk
Source§impl PartialEq for CheckableChunk
impl PartialEq for CheckableChunk
impl Eq for CheckableChunk
impl StructuralPartialEq for CheckableChunk
Auto Trait Implementations§
impl Freeze for CheckableChunk
impl RefUnwindSafe for CheckableChunk
impl Send for CheckableChunk
impl Sync for CheckableChunk
impl Unpin for CheckableChunk
impl UnwindSafe for CheckableChunk
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more