json - 由于 json 指针,Sphinx 无法包含我的 JSON 定义文件
问题描述
我正在使用 Sphinx 记录我的 JSON Schema 以将其托管在 ReadTheDocs 上。
当我在我的主模式文件中有我的定义时,一切都很好。但我想将我的定义移动到外部 json 文件中。
我的代码从
"$ref": "#/definitions/positiveNumber"
至
"$ref": "./general.definitions.json#/definitions/positiveNumber"
我的general.definitions.json
文件如下所示:
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://raw.githubusercontent.com/andrejellema/GlobalCoffeeDataStandard/master/schema/general.definitions.json",
"title": "General definitions",
"definitions": {
"percentage": {
"title": "The percentage, 0-100",
"description": "The percentage, from 0 to 100 with decimals allowed",
"$comment": "Duplicate in /productionCosts.json",
"type": "number",
"minimum": 0,
"maximum": 100
},
"positiveNumber": {
"title": "A positive number > 0",
"description": "A positive number starting at 0 with decimals allowed",
"type": "number",
"minimum": 0
},
"greaterThanZero": {
"title": "The positive number, greater than 0",
"description": "A positive number starting at greater than 0 with decimals allowed",
"type": "number",
"exclusiveMinimum": 0
},
"yesNo": {
"title": "Yes-No enumeration",
"type": "string",
"enum": [
"Yes",
"No"
]
}
}
}
我失败的第一个内容:
.. literalinclude:: ../../schema/general.definitions.json#/definitions/positiveNumber
:language: json
:linenos:
:caption: Object description
我的第一个有效内容:
.. literalinclude:: ../../schema/global-unique-id.json
:language: json
:linenos:
:caption: Object description
当我打电话时,make html
我收到此错误:
[...]\docs\source\explanation.rst:1360: WARNING: Include file '[...]\\schema\\general.definitions.json#\\definitions\\positiveNumber' not found or reading it failed
该文件存在于该位置。似乎 Sphinx 没有正确处理 JSON 指针。
我能做些什么来解决这个问题?
解决方案
Sphinx 不理解 JSON 指针语法。
为了突出显示包含的 JSON 文件中的某一行,您可以使用该:emphasize-lines:
选项。例子:
.. literalinclude:: ./general.definitions.json
:language: json
:linenos:
:emphasize-lines: 14
:caption: Object description
推荐阅读
- python - 如何在 RMarkdown 中渲染 Python 绘图?
- swift - 从符合协议的通用交互器传递已发布的 var
- c - 用gdb调试的时候,有时候gdb显示的运行位置很奇怪?
- python - 如何使用此代码在 Python 中重复一个程序?
- android - 我的应用程序关闭后如何让警报管理器执行?
- python - 我有错误,TypeError: unsupported operand type(s) for /: 'function' and 'int' 我不知道如何解决
- kotlin - 子类的 kotlin 工厂
- c++ - 在 C++-17 中,此构造函数是否有模板推导指南?
- azure-service-fabric - Service Fabric 状态配置
- reactjs - REACT - 独立地显示一个元素到一个相似的元素