我正在使用Sphinx为我的项目生成文档。
在这个项目中,我在一个yaml文件中描述了一个可用命令列表,一旦加载,就会生成一个字典,{command-name : command-description}
例如:
commands = {"copy" : "Copy the highlighted text in the clipboard",
"paste" : "Paste the clipboard text to cursor location",
...}
我想知道的是,sphinx 中是否有一种方法可以在循环期间加载 yaml 文件,以某种reStructuredText格式(例如定义列表make html
)翻译 python 字典并包含在我的 html 输出中。
我希望我的.rst
文件看起来像:
Available commands
==================
The commands available in bla-bla-bla...
.. magic-directive-that-execute-python-code::
:maybe python code or name of python file here:
并在内部转换为:
Available commands
==================
The commands available in bla-bla-bla...
copy
Copy the highlighted text in the clipboard
paste
Paste the clipboard text to cursor location
在被翻译成 HTML 之前。