pub struct Docs {
docs: String,
docs_source_map: Vec<DocsSourceMapLine>,
outline_mod: Option<(HirFileId, usize)>,
inline_file: HirFileId,
prefix_len: TextSize,
inline_inner_docs_start: Option<TextSize>,
outline_inner_docs_start: Option<TextSize>,
macro_calls: ThinVec<(AstId<MacroCall>, MacroCallId)>,
}Fields§
§docs: StringThe concatenated string of all #[doc = "..."] attributes and documentation comments.
docs_source_map: Vec<DocsSourceMapLine>A sorted map from an offset in docs to an offset in the source code.
outline_mod: Option<(HirFileId, usize)>If the item is an outlined module (mod foo;), docs_source_map stores the concatenated
list of the outline and inline docs (outline first). Then, this field contains the [HirFileId]
of the outline declaration, and the index in docs from which the inline docs
begin.
inline_file: HirFileId§prefix_len: TextSizeThe size of the prepended prefix, which does not map to real doc comments.
inline_inner_docs_start: Option<TextSize>The offset in docs from which the docs are inner attributes/comments.
outline_inner_docs_start: Option<TextSize>Like inline_inner_docs_start, but for outline_mod. This can happen only when merging Docs
(as outline modules don’t have inner attributes).
macro_calls: ThinVec<(AstId<MacroCall>, MacroCallId)>All macro calls in #[doc = ...] attributes, recursively.
Implementations§
Source§impl Docs
impl Docs
pub fn docs(&self) -> &str
pub fn into_docs(self) -> String
pub fn macro_calls( &self, ) -> impl Iterator<Item = (AstId<MacroCall>, MacroCallId)>
fn is_empty(&self) -> bool
pub fn find_ast_range( &self, string_range: TextRange, ) -> Option<(InFile<TextRange>, IsInnerDoc)>
pub fn shift_by(&mut self, offset: TextSize)
pub fn prepend_str(&mut self, s: &str)
pub fn append_str(&mut self, s: &str)
pub fn append(&mut self, other: &Docs)
fn extend_with_doc_comment(&mut self, comment: DocComment, indent: &mut Indent)
fn extend_with_doc_attr(&mut self, value: String, indent: &mut Indent)
fn extend_with_doc_str( &mut self, doc: &str, offset_in_ast: TextSize, comment_kind: DocCommentKind, indent: &mut Indent, )
fn extend_with_unmapped_doc_str(&mut self, doc: &str, indent: &mut Indent)
Sourcefn push_doc_lines(
&mut self,
doc: &str,
ast_offset: Option<TextSize>,
comment_kind: DocCommentKind,
indent: &mut Indent,
)
fn push_doc_lines( &mut self, doc: &str, ast_offset: Option<TextSize>, comment_kind: DocCommentKind, indent: &mut Indent, )
Beautifies doc and appends the result to self.docs, one line at a time via
Docs::push_doc_line. Mirrors rustc’s beautify_doc_string, delegating to
get_vertical_trim and get_horizontal_trim for the multi-line case.
Individual /// line comments always reach us as a single-line doc, so the
!doc.contains('\n') fast path fires and the multi-line logic never runs on them.
Desugared #[doc = "..."] strings and macro-expanded docs also route through here
with shape = CommentShape::Line, matching rustc.
Unlike rustc’s version, which joins the beautified lines into a new interned Symbol,
this port pushes each line individually via Docs::push_doc_line and pairs it with
its byte offset relative to doc’s start so the source-map records accurate per-line
offsets.
Sourcefn push_doc_line(
&mut self,
line: &str,
ast_offset: Option<TextSize>,
comment_kind: DocCommentKind,
indent: &mut Indent,
)
fn push_doc_line( &mut self, line: &str, ast_offset: Option<TextSize>, comment_kind: DocCommentKind, indent: &mut Indent, )
Appends a single beautified line to self.docs and records its source-map row.
fn remove_indent(&mut self, indent: &Indent)
fn remove_last_newline(&mut self)
fn shrink_to_fit(&mut self)
Trait Implementations§
impl Eq for Docs
impl StructuralPartialEq for Docs
Auto Trait Implementations§
impl Freeze for Docs
impl RefUnwindSafe for Docs
impl Send for Docs
impl Sync for Docs
impl Unpin for Docs
impl UnsafeUnpin for Docs
impl UnwindSafe for Docs
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,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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