Parser for Yaml/JSon schemas to RST
jsonschema2rst的Python项目详细描述
此项目旨在解析json模式或yaml模式,以便创建 重组文本文档。 使用sphinx这样的工具,可以创建高可读性的文档 从生成的文件,这些文件是RST格式的文本。
结果rst可以通过在csv中定义黑名单并使用 自定义css文件。会继承狮身人面像的。对于后者,一个 提供了示例。
用法
要从json架构(或yaml)创建rst文件,请运行命令:
jsonschema2rst input_folder output_folder
此命令将接受此路径、子文件夹中的所有json或yaml文件 包含,并且WLL创建一个新目录——如果已经存在,则删除它。 所有解析的rst文件将被放置在哪里。
示例
假设您运行以下命令:
jsonschema2rst json_folder rst_output_folder
假设文件夹json_folder包含 url.json,其中包含以下架构:
{ "title": "URL of related document", "properties": { "description": { "type": "string" }, "value": { "format": "url", "type": "string" } }, "type": "object" }
因此,jsonschema2rst将创建一个名为url.rstin的文件 rst_output_folder将包含以下RST代码:
.. contents:: Table of Contents .. section-numbering:: .. container:: section-title url.json .. container:: title URL of related document **type** : ``object`` **Properties:** description_, value_ .. description: description +++++++++++ **type** : ``string`` .. value: value +++++ **type** : ``string`` **format** : ``url``
额外
如果您想使用sphinx这样的工具生成html文档,我们
建议您尝试contribution
文件夹中的custom.css
文件
您的模式文档看起来更好。你需要的只是把
sphinx在conf.py文件中使用的默认css,然后
享受吧!