pub struct Notebook { /* private fields */ }Implementations§
Source§impl Notebook
impl Notebook
Sourcepub fn from_path(path: &Path) -> Result<Self, NotebookError>
pub fn from_path(path: &Path) -> Result<Self, NotebookError>
Read the Jupyter Notebook from the given Path.
Sourcepub fn from_source_code(source_code: &str) -> Result<Self, NotebookError>
pub fn from_source_code(source_code: &str) -> Result<Self, NotebookError>
Read the Jupyter Notebook from its JSON string.
pub fn from_raw_notebook( raw_notebook: RawNotebook, trailing_newline: bool, ) -> Result<Self, NotebookError>
Sourcepub fn source_code(&self) -> &str
pub fn source_code(&self) -> &str
Return the notebook content.
This is the concatenation of all Python code cells.
Sourcepub fn index(&self) -> &NotebookIndex
pub fn index(&self) -> &NotebookIndex
Return the Jupyter notebook index.
The index is built only once when required. This is only used to
report diagnostics, so by that time all of the fixes must have
been applied if --fix was passed.
Sourcepub fn into_index(self) -> NotebookIndex
pub fn into_index(self) -> NotebookIndex
Return the Jupyter notebook index, consuming the notebook.
The index is built only once when required. This is only used to
report diagnostics, so by that time all of the fixes must have
been applied if --fix was passed.
Sourcepub fn cell_offsets(&self) -> &CellOffsets
pub fn cell_offsets(&self) -> &CellOffsets
Return the CellOffsets for the concatenated source code corresponding
the Jupyter notebook.
Sourcepub fn cell_offset(&self, cell: OneIndexed) -> Option<TextSize>
pub fn cell_offset(&self, cell: OneIndexed) -> Option<TextSize>
Returns the start offset of the cell at index cell in the concatenated
text document.
Sourcepub fn cell_range(&self, cell: OneIndexed) -> Option<TextRange>
pub fn cell_range(&self, cell: OneIndexed) -> Option<TextRange>
Returns the text range in the concatenated document of the cell
with index cell.
Sourcepub fn trailing_newline(&self) -> bool
pub fn trailing_newline(&self) -> bool
Return true if the notebook has a trailing newline, false otherwise.
Sourcepub fn update(&mut self, source_map: &SourceMap, transformed: String)
pub fn update(&mut self, source_map: &SourceMap, transformed: String)
Update the notebook with the given sourcemap and transformed content.
Sourcepub fn is_python_notebook(&self) -> bool
pub fn is_python_notebook(&self) -> bool
Check if it’s a Python notebook.
This is determined by checking the language_info or kernelspec in the notebook
metadata. If neither is present, it’s assumed to be a Python notebook.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Notebook
impl RefUnwindSafe for Notebook
impl Send for Notebook
impl Sync for Notebook
impl Unpin for Notebook
impl UnsafeUnpin for Notebook
impl UnwindSafe for Notebook
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.