在Windows上的Sphinx中使用Merro.cli时出现问题



我有一个简单的狮身人面像项目,我希望能够将我的美人鱼图渲染为png。为了做到这一点,我已经通过yarn安装了美人鱼.cli,但我还没能让它正常工作。

我的尝试

我尝试过各种组合:

  • 我尝试过通过npm和yarn在全球范围内安装,但没有成功
  • 我曾尝试在Sphinx项目的根文件夹中进行本地安装,并将.bin文件夹作为conf.py中的绝对路径,但没有成功
  • 我可以像往常一样从命令提示符使用mmdc

我的conf.py

我的conf.py位于C:UsersmartiDocumentssphinx-testdocs,包含以下内容(以及其他内容(:

extensions = [
"sphinxcontrib.mermaid",
]
mermaid_cmd = "C:\Users\marti\Documents\sphinx-test\node_modules\.bin\mmdc"
mermaid_output_format = "png"

回溯

当我使用上面的conf.py时,我会得到下面的回溯。如果从路径中删除\mmdc,则会出现Permission Denied错误。

# Sphinx version: 3.0.0
# Python version: 3.7.3 (CPython)
# Docutils version: 0.14 
# Jinja2 version: 2.11.1
# Last messages:
#   none found
#   pickling environment...
#   done
#   checking consistency...
#   done
#   preparing documents...
#   done
#   writing output... [ 33%] configure/configure
#   writing output... [ 66%] index
#   writing output... [100%] introduction/introduction
# Loaded extensions:
#   sphinx.ext.mathjax (3.0.0) from c:usersmartiappdatalocalprogramspythonpython37libsite-packagessphinxextmathjax.py
#   sphinxcontrib.applehelp (1.0.2) from c:usersmartiappdatalocalprogramspythonpython37libsite-packagessphinxcontribapplehelp__init__.py
#   sphinxcontrib.devhelp (1.0.2) from c:usersmartiappdatalocalprogramspythonpython37libsite-packagessphinxcontribdevhelp__init__.py
#   sphinxcontrib.htmlhelp (1.0.3) from c:usersmartiappdatalocalprogramspythonpython37libsite-packagessphinxcontribhtmlhelp__init__.py
#   sphinxcontrib.serializinghtml (1.1.4) from c:usersmartiappdatalocalprogramspythonpython37libsite-packagessphinxcontribserializinghtml__init__.py
#   sphinxcontrib.qthelp (1.0.3) from c:usersmartiappdatalocalprogramspythonpython37libsite-packagessphinxcontribqthelp__init__.py
#   alabaster (0.7.12) from c:usersmartiappdatalocalprogramspythonpython37libsite-packagesalabaster__init__.py
#   recommonmark (0.6.0) from c:usersmartiappdatalocalprogramspythonpython37libsite-packagesrecommonmark__init__.py
#   sphinx.ext.todo (3.0.0) from c:usersmartiappdatalocalprogramspythonpython37libsite-packagessphinxexttodo.py
#   sphinx.ext.githubpages (3.0.0) from c:usersmartiappdatalocalprogramspythonpython37libsite-packagessphinxextgithubpages.py
#   sphinxcontrib.mermaid (3.0.0) from c:usersmartiappdatalocalprogramspythonpython37libsite-packagessphinxcontribmermaid.py
#   romnnn_sphinx_press_theme (unknown version) from c:usersmartiappdatalocalprogramspythonpython37libsite-packagesromnnn_sphinx_press_theme__init__.py
Traceback (most recent call last):
File "c:usersmartiappdatalocalprogramspythonpython37libsite-packagessphinxcmdbuild.py", line 280, in build_main
app.build(args.force_all, filenames)
File "c:usersmartiappdatalocalprogramspythonpython37libsite-packagessphinxapplication.py", line 348, in build
self.builder.build_update()
File "c:usersmartiappdatalocalprogramspythonpython37libsite-packagessphinxbuilders__init__.py", line 299, in build_update
len(to_build))
File "c:usersmartiappdatalocalprogramspythonpython37libsite-packagessphinxbuilders__init__.py", line 361, in build
self.write(docnames, list(updated_docnames), method)
File "c:usersmartiappdatalocalprogramspythonpython37libsite-packagessphinxbuilders__init__.py", line 535, in write
self._write_serial(sorted(docnames))
File "c:usersmartiappdatalocalprogramspythonpython37libsite-packagessphinxbuilders__init__.py", line 545, in _write_serial
self.write_doc(docname, doctree)
File "c:usersmartiappdatalocalprogramspythonpython37libsite-packagessphinxbuildershtml__init__.py", line 597, in write_doc
self.docwriter.write(doctree, destination)
File "c:usersmartiappdatalocalprogramspythonpython37libsite-packagesdocutilswriters__init__.py", line 80, in write
self.translate()
File "c:usersmartiappdatalocalprogramspythonpython37libsite-packagessphinxwritershtml.py", line 71, in translate
self.document.walkabout(visitor)
File "c:usersmartiappdatalocalprogramspythonpython37libsite-packagesdocutilsnodes.py", line 174, in walkabout
if child.walkabout(visitor):
File "c:usersmartiappdatalocalprogramspythonpython37libsite-packagesdocutilsnodes.py", line 174, in walkabout
if child.walkabout(visitor):
File "c:usersmartiappdatalocalprogramspythonpython37libsite-packagesdocutilsnodes.py", line 166, in walkabout
visitor.dispatch_visit(self)
File "c:usersmartiappdatalocalprogramspythonpython37libsite-packagessphinxutildocutils.py", line 468, in dispatch_visit
method(node)
File "c:usersmartiappdatalocalprogramspythonpython37libsite-packagessphinxcontribmermaid.py", line 280, in html_visit_mermaid
render_mm_html(self, node, node['code'], node['options'])
File "c:usersmartiappdatalocalprogramspythonpython37libsite-packagessphinxcontribmermaid.py", line 251, in render_mm_html
fname, outfn = render_mm(self, code, options, format, prefix)
File "c:usersmartiappdatalocalprogramspythonpython37libsite-packagessphinxcontribmermaid.py", line 182, in render_mm
p = Popen(mm_args, stdout=PIPE, stdin=PIPE, stderr=PIPE)
File "c:usersmartiappdatalocalprogramspythonpython37libsubprocess.py", line 775, in __init__
restore_signals, start_new_session)
File "c:usersmartiappdatalocalprogramspythonpython37libsubprocess.py", line 1178, in _execute_child
startupinfo)
OSError: [WinError 193] %1 is not a valid Win32 application

通过添加shell=True修改以下行解决了这个问题,归功于Martín Gaitán:

https://github.com/mgaitan/sphinxcontrib-mermaid/blob/master/sphinxcontrib/mermaid.py#L172-L174

使用0.5.0版(2020年9月24日(及更高版本,您可以添加使用mermaid_cmd_shell而不是修改源代码:

mermaid_cmd_shell = True

相关内容

  • 没有找到相关文章

最新更新