pub struct CppDocCodeBlock { /* private fields */ }Expand description
A code block: the lines between @code and @endcode.
Its contents are deliberately not parsed as documentation — std::vector<int> and // comment
inside a snippet are code, and reading them as prose turns the snippet into nonsense. What that
means for a consumer is the opposite of every other doc node: this one’s text is raw, line markers
and all, and get_code_text is the accessor that reads it as code.
Implementations§
Source§impl CppDocCodeBlock
impl CppDocCodeBlock
Sourcepub fn get_code_text(&self) -> String
pub fn get_code_text(&self) -> String
The code, with the comment’s own furniture removed.
One rule, shared with CppDocCommand::get_code_text: per line, a trailing */ goes, a
leading /-run with an optional ! or an opening /* with its */! goes, a * line
marker goes in a block comment, and one space after the marker goes. Lines are joined with
\n, each line’s end is trimmed, and the blank lines at the edges are dropped.
The * marker is stripped only inside a block comment. In a /// comment a leading * is
text — and in a code block it is code: /// *p = 1; dereferences a pointer, and eating the
* would return a snippet that does not compile.
A line that is exactly the block’s @code or @endcode marker is dropped: the node covers
the closing marker (that is where its range ends), and a marker is not code. A block that was
never closed simply has no such line, which is the normal state of a comment being written.
Trait Implementations§
Source§impl Clone for CppDocCodeBlock
impl Clone for CppDocCodeBlock
Source§impl CppAstNode for CppDocCodeBlock
impl CppAstNode for CppDocCodeBlock
fn syntax(&self) -> &CppSyntaxNode
Source§fn can_cast(kind: CppSyntaxKind) -> bool
fn can_cast(kind: CppSyntaxKind) -> bool
Self? Read morefn cast(syntax: CppSyntaxNode) -> Option<Self>
Source§fn child<N: CppAstNode>(&self) -> Option<N>
fn child<N: CppAstNode>(&self) -> Option<N>
N.Source§fn token<N: CppAstToken>(&self) -> Option<N>
fn token<N: CppAstToken>(&self) -> Option<N>
N.Source§fn token_by_kind(&self, kind: CppTokenKind) -> Option<CppGeneralToken>
fn token_by_kind(&self, kind: CppTokenKind) -> Option<CppGeneralToken>
Source§fn children<N: CppAstNode>(&self) -> CppAstChildren<N> ⓘ
fn children<N: CppAstNode>(&self) -> CppAstChildren<N> ⓘ
N.Source§fn tokens<N: CppAstToken>(&self) -> CppAstTokenChildren<N> ⓘ
fn tokens<N: CppAstToken>(&self) -> CppAstTokenChildren<N> ⓘ
N.Source§fn descendants<N: CppAstNode>(&self) -> impl Iterator<Item = N>
fn descendants<N: CppAstNode>(&self) -> impl Iterator<Item = N>
N.Source§fn walk_descendants<N: CppAstNode>(&self) -> impl Iterator<Item = WalkEvent<N>>
fn walk_descendants<N: CppAstNode>(&self) -> impl Iterator<Item = WalkEvent<N>>
N, with enter/leave events.Source§fn ancestors<N: CppAstNode>(&self) -> impl Iterator<Item = N>
fn ancestors<N: CppAstNode>(&self) -> impl Iterator<Item = N>
N, innermost first.Source§fn get_root(&self) -> CppSyntaxNode
fn get_root(&self) -> CppSyntaxNode
Source§fn get_parent<N: CppAstNode>(&self) -> Option<N>
fn get_parent<N: CppAstNode>(&self) -> Option<N>
N.fn get_position(&self) -> TextSize
fn get_range(&self) -> TextRange
Source§fn get_self_or_ancestor<N: CppAstNode>(&self) -> Option<N>
fn get_self_or_ancestor<N: CppAstNode>(&self) -> Option<N>
N, starting from this node itself.Source§fn get_syntax_id(&self) -> CppSyntaxId
fn get_syntax_id(&self) -> CppSyntaxId
CppSyntaxId.Source§impl Debug for CppDocCodeBlock
impl Debug for CppDocCodeBlock
impl Eq for CppDocCodeBlock
Source§impl Hash for CppDocCodeBlock
impl Hash for CppDocCodeBlock
Source§impl PartialEq for CppDocCodeBlock
impl PartialEq for CppDocCodeBlock
impl StructuralPartialEq for CppDocCodeBlock
Auto Trait Implementations§
impl !RefUnwindSafe for CppDocCodeBlock
impl !Send for CppDocCodeBlock
impl !Sync for CppDocCodeBlock
impl !UnwindSafe for CppDocCodeBlock
impl Freeze for CppDocCodeBlock
impl Unpin for CppDocCodeBlock
impl UnsafeUnpin for CppDocCodeBlock
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> 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