pub struct StmtIpyEscapeCommand {
pub node_index: AtomicNodeIndex,
pub range: TextRange,
pub kind: IpyEscapeKind,
pub value: Box<str>,
}Expand description
An AST node used to represent a IPython escape command at the statement level.
For example,
%matplotlib inline§Terminology
Escape commands are special IPython syntax which starts with a token to identify
the escape kind followed by the command value itself. Escape kind are the kind
of escape commands that are recognized by the token: %, %%, !, !!,
?, ??, /, ;, and ,.
Help command (or Dynamic Object Introspection as it’s called) are the escape commands
of the kind ? and ??. For example, ?str.replace. Help end command are a subset
of Help command where the token can be at the end of the line i.e., after the value.
For example, str.replace?.
Here’s where things get tricky. I’ll divide the help end command into two types for better understanding:
- Strict version: The token is only at the end of the line. For example,
str.replace?orstr.replace??. - Combined version: Along with the
?or??token, which are at the end of the line, there are other escape kind tokens that are present at the start as well. For example,%matplotlib?or%%timeit?.
Priority comes into picture for the “Combined version” mentioned above. How do
we determine the escape kind if there are tokens on both side of the value, i.e., which
token to choose? The Help end command always takes priority over any other token which
means that if there is ?/?? at the end then that is used to determine the kind.
For example, in %matplotlib? the escape kind is determined using the ? token
instead of % token.
§Syntax
<IpyEscapeKind><Command value>
The simplest form is an escape kind token followed by the command value. For example,
%matplotlib inline, /foo, !pwd, etc.
<Command value><IpyEscapeKind ("?" or "??")>
The help end escape command would be the reverse of the above syntax. Here, the
escape kind token can only be either ? or ?? and it is at the end of the line.
For example, str.replace?, math.pi??, etc.
<IpyEscapeKind><Command value><EscapeKind ("?" or "??")>
The final syntax is the combined version of the above two. For example, %matplotlib?,
%%timeit??, etc.
Fields§
§node_index: AtomicNodeIndex§range: TextRange§kind: IpyEscapeKind§value: Box<str>Trait Implementations§
Source§impl Clone for StmtIpyEscapeCommand
impl Clone for StmtIpyEscapeCommand
Source§fn clone(&self) -> StmtIpyEscapeCommand
fn clone(&self) -> StmtIpyEscapeCommand
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for StmtIpyEscapeCommand
impl Debug for StmtIpyEscapeCommand
Source§impl<'a> From<&'a StmtIpyEscapeCommand> for AnyNodeRef<'a>
impl<'a> From<&'a StmtIpyEscapeCommand> for AnyNodeRef<'a>
Source§fn from(node: &'a StmtIpyEscapeCommand) -> AnyNodeRef<'a>
fn from(node: &'a StmtIpyEscapeCommand) -> AnyNodeRef<'a>
Source§impl<'a> From<&'a StmtIpyEscapeCommand> for StmtRef<'a>
impl<'a> From<&'a StmtIpyEscapeCommand> for StmtRef<'a>
Source§fn from(node: &'a StmtIpyEscapeCommand) -> Self
fn from(node: &'a StmtIpyEscapeCommand) -> Self
Source§impl From<StmtIpyEscapeCommand> for Stmt
impl From<StmtIpyEscapeCommand> for Stmt
Source§fn from(node: StmtIpyEscapeCommand) -> Self
fn from(node: StmtIpyEscapeCommand) -> Self
Source§impl HasNodeIndex for StmtIpyEscapeCommand
impl HasNodeIndex for StmtIpyEscapeCommand
Source§fn node_index(&self) -> &AtomicNodeIndex
fn node_index(&self) -> &AtomicNodeIndex
AtomicNodeIndex for this node.Source§impl PartialEq for StmtIpyEscapeCommand
impl PartialEq for StmtIpyEscapeCommand
Source§impl Ranged for StmtIpyEscapeCommand
impl Ranged for StmtIpyEscapeCommand
Source§impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a StmtIpyEscapeCommand
impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a StmtIpyEscapeCommand
impl StructuralPartialEq for StmtIpyEscapeCommand
Auto Trait Implementations§
impl !Freeze for StmtIpyEscapeCommand
impl RefUnwindSafe for StmtIpyEscapeCommand
impl Send for StmtIpyEscapeCommand
impl Sync for StmtIpyEscapeCommand
impl Unpin for StmtIpyEscapeCommand
impl UnsafeUnpin for StmtIpyEscapeCommand
impl UnwindSafe for StmtIpyEscapeCommand
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<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