MkDocs插件,用于执行notebooks并将结果嵌入文档中。
项目描述
MkDocs Execute Plugin
用于使用jupytext执行文档文件并将其输出嵌入到文档中的MkDocs插件。
安装
首先使用pip安装插件
pip install mkdocs-execute-plugin
基本用法
配置mkdocs
安装后,您可以通过将其添加到mkdocs.yml
中的plugin
部分来启用插件
plugins:
- execute
添加可执行文件
默认情况下,如果文件具有execute
标签,此插件将执行Markdown文件中的所有代码块。下面是一个示例Markdown文件。
---
execute: true
---
```python
print('Hello world!')
```
除此之外,该插件还将默认执行所有Python(.py
)文件。
print('Hello world!')
隐藏单元格输入或输出
可以通过分别应用hide-input
和hide-output
标签来隐藏单元格的输入或输出。还可以使用hide-cell
标签完全隐藏单元格。
```python tags=["hide-input"]
print('Hidden input')
```
```python tags=["hide-output"]
print('Hidden output')
```
```python tags=["hide-cell"]
print('Completely hidden')
```
配置
所有配置选项如下。给出的值是默认值。
# Default configuration
plugins:
- execute:
# Specify which files to include for execution. Should be a list of .gitignore style glob patterns.
# Note that only files with the execute tag set to true will be executed. To override, see `execute_without_tag`.
include:
- '*.py'
- '*.md'
# Specify which glob patterns to exclude for execution. Same format as `include`.
exclude: []
# Specify which files should still be executed if the execute tag is missing. Same format as `include`.
# If the execute is set to false for a file matching this pattern, it will NOT be executed.
execute_without_tag:
- '*.py'
# Markdown template used to render the executed files.
markdown_template: 'markdown/index.md.j2'
# You can modify the names of all tags.
tags:
# Tag that marks the file as executable.
execute: 'execute'
# Tag that hides a cell completely, both the input and output.
# Note that the cell will still be executed.
hide_cell: 'hide-cell'
# Tag that hides the cell input (code).
hide_input: 'hide-input'
# Tag that hides the cell output.
hide_output: 'hide-output'
支持的格式和语言
此插件使用 jupytext 来执行并将文件转换为 Markdown 格式。这意味着所有由 jupytext 支持的语言和格式都应该可以正常工作。
项目详情
下载文件
下载适用于您的平台的文件。如果您不确定选择哪个,请了解有关 安装包 的更多信息。
源代码分发
mkdocs_execute_plugin-0.0.8.tar.gz (6.6 kB 查看哈希值)