This release is a pre-release and may not be stable for production use.
mknotebooks
mknotebooks is a plugin for MkDocs enabling you to include Jupyter notebooks directly in your project documentation.
Install
pip3 install mknotebooks
Usage
- Add
mknotebooksto the plugin section of yourmkdocs.yml - Include any notebooks (
.ipynbfiles) you want to use in thedocs/directory just as you would.mdfiles.
Example:
# mkdocs.yml
nav:
- your_notebook.ipynb
plugins:
- mknotebooks
Any static images, plots, etc. will be extracted from the notebook and placed alongside the output HTML.
Options
You can optionally execute the notebooks, by setting execute: true in the config. You can include a hidden preamble script, to be run before executing any cells using preamble: "<path/to/your/script>". The default cell execution timeout can be overridden by setting timeout: <timeout>, where <timeout> is an integer number of seconds.
By default, execution will be aborted if any of the cells throws an error, but you can set allow_errors: true to continue execution and include the error message in the cell output.
Example:
# mkdocs.yml
plugins:
- mknotebooks
execute: false
timeout: 100
preamble: "<path/to/your/script>"
allow_errors: false
Styling
Mknotebooks applies default styling to improve the appearance of notebook input/output cells and pandas dataframes. If these interfere with any other CSS stylesheets that you're using, you can disable these via the following options.
# mkdocs.yml
- mknotebooks:
enable_default_jupyter_cell_styling: false
enable_default_pandas_dataframe_styling: false
Syntax highlighting
In order to enable syntax highlighting for code blocks, pygments has to be installed and codehilite extension has to be enabled in mkdocs.yml.
- Install pygments:
pip install Pygments
- Enable
codehiliteextension inmkdocs.yml:
# mkdocs.yml
markdown_extensions:
- codehilite
Binder
You can also choose to have mknotebooks insert a Binder link into each notebook.
- mknotebooks:
binder: true
binder_service_name: "gh"
binder_branch: "master"
binder_ui: "lab"
If you are using GitLab, you will need to set binder_service_name to "gl".
Examples
See the examples folder for examples on the use of a preamble and using Binder. Try them out by running pipenv install && pipenv run mkdocs serve.
Inspecting generated markdown
You can also export the generated markdown by setting write_markdown: true in your mkdocs.yml. This will write the generated markdown to a .md.tmp file alongside the original notebook.
Metadata
Release files for mknotebooks-with-links 0.7.1.post0.dev808
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mknotebooks_with_links-0.7.1.post0.dev808-py3-none-any.whl | Python 3 | none | any | Details for mknotebooks_with_links-0.7.1.post0.dev808-py3-none-any.whl |
Release files / mknotebooks_with_links-0.7.1.post0.dev808-py3-none-any.whl
| Download URL | mknotebooks_with_links-0.7.1.post0.dev808-py3-none-any.whl |
|---|---|
| Size | 13.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f9ad0949f55ee52dd5a9ec69b0bb6977859ca2fd09f9a7a6e453b64f086df983
|
|
BLAKE2b-256 checksum How to use checksums |
df3b3e0a16b565285bb092f802042890e872b256b12673a0d0c523509baacfad
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.8.19
|
Security for mknotebooks-with-links 0.7.1.post0.dev808
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.