【发布时间】:2021-12-06 20:09:30
【问题描述】:
假设我有一个动物园动物的 JSON/YAML/XML 等,我想为动物园中的所有动物制作一些文档。所以我有一个像这样的 JSON:
{
"zooName": "C town's Zoo",
"animals": [
"tiger": {
"species":"some_species_name_here",
"weight": 120
},
"bear":{
"species":"some_other_species_name",
"weight": 100
}
]
}
在另一个 SSG 中,我可以做类似的事情
> Bring in a JSON file from /data/myfile.json
> Access some index of that file like [animals][tiger], etc...
> Show that data as a part of the HTML template that is made by, say, `tiger.rst`
我将如何在 Sphinx 中实现这一点?假设我有一个animals.rst,其中包含我所有动物的目录树,然后为每个单独的动物创建一个这样的文件。
Tiger
=======================================
Tiger info here.
Species:
[[ Access my json here and show content from jsonfile[animals][tiger][species] ]]
Weight:
[[ Access my json here and show content from jsonfile[animals][tiger][weight] ]]
【问题讨论】:
-
doctest 会做你想做的事吗?
标签: python json python-sphinx restructuredtext