MyST sphinx 扩展无法识别 `{code-cell}` 指令

问题描述 投票:0回答:1

我正在努力让 myst_parser sphinx 扩展识别

{code-cell}
指令。 Sphinx 发出此警告:

/home/dallan/Repos/bnl/myst_test/docs/index.md.rst:3: WARNING: Unknown directive type: 'code-cell' [myst.directive_unknown]

我想我一定错过了一些明显的东西。这是一个最小的例子。

tree docs
docs
├── conf.py
└── index.md

0 directories, 2 files
$ cat docs/conf.py 
extensions=["myst_parser"]
$ cat docs/index.md 
# Test

```{admonition} Here's my title
:class: warning

Here's my admonition content
```

```{code-cell} ipython3
1 + 1
```
$ sphinx-build docs docs/html
Running Sphinx v8.0.2
loading translations [en]... done
making output directory... done
myst v4.0.0: MdParserConfig(commonmark_only=False, gfm_only=False, enable_extensions=set(), disable_syntax=[], all_links_external=False, links_external_new_tab=False, url_schemes=('http', 'https', 'mailto', 'ftp'), ref_domains=None, fence_as_directive=set(), number_code_blocks=[], title_to_header=False, heading_anchors=0, heading_slug_func=None, html_meta={}, footnote_sort=True, footnote_transition=True, words_per_minute=200, substitutions={}, linkify_fuzzy_links=True, dmath_allow_labels=True, dmath_allow_space=True, dmath_allow_digits=True, dmath_double_inline=False, update_mathjax=True, mathjax_classes='tex2jax_process|mathjax_process|math|output_area', enable_checkboxes=False, suppress_warnings=[], highlight_code_blocks=True)
building [mo]: targets for 0 po files that are out of date
writing output... 
building [html]: targets for 1 source files that are out of date
updating environment: [new config] 1 added, 0 changed, 0 removed
reading sources... [100%] index
/home/dallan/Repos/bnl/myst_test/docs/index.md.rst:3: WARNING: Unknown directive type: 'code-cell' [myst.directive_unknown]
looking for now-outdated files... none found
pickling environment... done
checking consistency... done
preparing documents... done
copying assets... 
copying static files... done
copying extra files... done
copying assets: done
writing output... [100%] index
generating indices... genindex done
writing additional pages... search done
dumping search index in English (code: en)... done
dumping object inventory... done
build succeeded, 1 warning.

The HTML pages are in docs/html.

注意警告:

Unknown directive type: 'code-cell' [myst.directive_unknown]
。值得注意的是,
{admonition}
指令在 HTML 中按预期工作和渲染;只有
{code-cell}
指令失败。

以上是在干净的环境中运行的,并从 PyPI 安装了

sphinx
myst_parser

$ pip list
Package                       Version
----------------------------- --------
alabaster                     1.0.0
babel                         2.16.0
certifi                       2024.7.4
charset-normalizer            3.3.2
docutils                      0.21.2
idna                          3.8
imagesize                     1.4.1
Jinja2                        3.1.4
markdown-it-py                3.0.0
MarkupSafe                    2.1.5
mdit-py-plugins               0.4.1
mdurl                         0.1.2
myst-parser                   4.0.0
packaging                     24.1
pip                           24.2
Pygments                      2.18.0
PyYAML                        6.0.2
requests                      2.32.3
setuptools                    72.2.0
snowballstemmer               2.2.0
Sphinx                        8.0.2
sphinxcontrib-applehelp       2.0.0
sphinxcontrib-devhelp         2.0.0
sphinxcontrib-htmlhelp        2.1.0
sphinxcontrib-jsmath          1.0.1
sphinxcontrib-qthelp          2.0.0
sphinxcontrib-serializinghtml 2.0.0
urllib3                       2.2.2
wheel                         0.44.0

我怀疑这是“椅子和键盘之间存在问题”的情况——感谢任何帮助!

参考资料:


更新:阅读在构建期间执行笔记本我看到了

为了执行 MyST 内容,您必须安装 Jupyter 服务器和执行代码所需的内核(例如,IPython 内核、Xeus Python 内核或 IRKernel)。

我将

ipykernel
jupyter-server
添加到我的环境中,但这并没有改变结果。我还缺少一些东西。

python-sphinx myst
1个回答
0
投票

code-cell
指令由兄弟扩展
mystnb
添加。如果您在 Sphinx 应用程序中启用了
mystnb
,则无需手动配置(也不应该!)
myst-parser
。 :)

© www.soinside.com 2019 - 2024. All rights reserved.