Markdown Commands#

nbrefactor allows the use of Markdown Commands to control the refactoring process. These commands allow you to manipulate the structure of the refactored modules, or to ignore certain parts of the notebook.

Basic Usage#

To use a Markdown command, you may include it in an HTML comment (as to not interfere with your Notebook’s aesthetics 😇) within a Markdown cell.

The format is:

<!-- $command-name=value -->

For example, to rename a package:

<!-- $package=my_custom_package -->

Markdown Command Table#

The following table lists all the possible Markdown commands and their functions.

Command

Description

$ignore-package

Ignores all modules/packages until a header with a depth less than or equal to the current one is reached.

$ignore-module

Ignores a single module (may consist of multiple code cells).

$ignore-cell

Ignores the next code cell regardless of type.

$ignore-markdown

Ignores the current Markdown cell (e.g., when used for instructions only).

$analyze-only

Prevents the current markdown cell from creating a module/package

but still analyzes any following code for dependencies. Useful for global imports.

$package=<name>

Renames the current package and asserts the node type as ‘package’.

$module=<name>

Renames the current module and asserts the node type as ‘module’.

$node=<name>

Renames the current node generically, regardless of type.

$declare-package=<name>

Declares a new node and asserts its type as ‘package’.

$declare-module=<name>

Declares a new node and asserts its type as ‘module’.

$declare-node=<name>

Declares a new node with no type (type will be inferred).