Struct doc_chunks::chunk::CheckableChunk
source · pub struct CheckableChunk { /* private fields */ }
Expand description
A chunk of documentation that is supposed to be checked.
Implementations
sourceimpl 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<'a>(
&'a self,
range: Range
) -> impl Iterator<Item = &'a Span>
pub fn find_covered_spans<'a>(
&'a self,
range: Range
) -> impl Iterator<Item = &'a 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<'i>(&'i self, range: Range) -> Vec<Range> ⓘ
pub fn find_covered_lines<'i>(&'i 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) -> PlainOverlay<'_>
pub fn erase_cmark(&self) -> 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
sourceimpl Clone for CheckableChunk
impl Clone for CheckableChunk
sourcefn clone(&self) -> CheckableChunk
fn clone(&self) -> CheckableChunk
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresourceimpl Debug for CheckableChunk
impl Debug for CheckableChunk
sourceimpl Hash for CheckableChunk
impl Hash for CheckableChunk
sourceimpl PartialEq<CheckableChunk> for CheckableChunk
impl PartialEq<CheckableChunk> for CheckableChunk
sourcefn eq(&self, other: &CheckableChunk) -> bool
fn eq(&self, other: &CheckableChunk) -> bool
impl Eq for CheckableChunk
impl StructuralEq for CheckableChunk
impl StructuralPartialEq for CheckableChunk
Auto Trait Implementations
impl RefUnwindSafe for CheckableChunk
impl Send for CheckableChunk
impl Sync for CheckableChunk
impl Unpin for CheckableChunk
impl UnwindSafe for CheckableChunk
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
sourceimpl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.