nbformat.v3.schema.json 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  1. {
  2. "$schema": "http://json-schema.org/draft-04/schema#",
  3. "description": "IPython Notebook v3.0 JSON schema.",
  4. "type": "object",
  5. "additionalProperties": false,
  6. "required": ["metadata", "nbformat_minor", "nbformat", "worksheets"],
  7. "properties": {
  8. "metadata": {
  9. "description": "Notebook root-level metadata.",
  10. "type": "object",
  11. "additionalProperties": true,
  12. "properties": {
  13. "kernel_info": {
  14. "description": "Kernel information.",
  15. "type": "object",
  16. "required": ["name", "language"],
  17. "properties": {
  18. "name": {
  19. "description": "Name of the kernel specification.",
  20. "type": "string"
  21. },
  22. "language": {
  23. "description": "The programming language which this kernel runs.",
  24. "type": "string"
  25. },
  26. "codemirror_mode": {
  27. "description": "The codemirror mode to use for code in this language.",
  28. "type": "string"
  29. }
  30. }
  31. },
  32. "signature": {
  33. "description": "Hash of the notebook.",
  34. "type": "string"
  35. }
  36. }
  37. },
  38. "nbformat_minor": {
  39. "description": "Notebook format (minor number). Incremented for backward compatible changes to the notebook format.",
  40. "type": "integer",
  41. "minimum": 0
  42. },
  43. "nbformat": {
  44. "description": "Notebook format (major number). Incremented between backwards incompatible changes to the notebook format.",
  45. "type": "integer",
  46. "minimum": 3,
  47. "maximum": 3
  48. },
  49. "orig_nbformat": {
  50. "description": "Original notebook format (major number) before converting the notebook between versions.",
  51. "type": "integer",
  52. "minimum": 1
  53. },
  54. "orig_nbformat_minor": {
  55. "description": "Original notebook format (minor number) before converting the notebook between versions.",
  56. "type": "integer",
  57. "minimum": 0
  58. },
  59. "worksheets" : {
  60. "description": "Array of worksheets",
  61. "type": "array",
  62. "items": {"$ref": "#/definitions/worksheet"}
  63. }
  64. },
  65. "definitions": {
  66. "worksheet": {
  67. "additionalProperties": false,
  68. "required" : ["cells"],
  69. "properties":{
  70. "cells": {
  71. "description": "Array of cells of the current notebook.",
  72. "type": "array",
  73. "items": {
  74. "type": "object",
  75. "oneOf": [
  76. {"$ref": "#/definitions/raw_cell"},
  77. {"$ref": "#/definitions/markdown_cell"},
  78. {"$ref": "#/definitions/heading_cell"},
  79. {"$ref": "#/definitions/code_cell"}
  80. ]
  81. }
  82. },
  83. "metadata": {
  84. "type": "object",
  85. "description": "metadata of the current worksheet"
  86. }
  87. }
  88. },
  89. "raw_cell": {
  90. "description": "Notebook raw nbconvert cell.",
  91. "type": "object",
  92. "additionalProperties": false,
  93. "required": ["cell_type", "source"],
  94. "properties": {
  95. "cell_type": {
  96. "description": "String identifying the type of cell.",
  97. "enum": ["raw"]
  98. },
  99. "metadata": {
  100. "description": "Cell-level metadata.",
  101. "type": "object",
  102. "additionalProperties": true,
  103. "properties": {
  104. "format": {
  105. "description": "Raw cell metadata format for nbconvert.",
  106. "type": "string"
  107. },
  108. "name": {"$ref": "#/definitions/misc/metadata_name"},
  109. "tags": {"$ref": "#/definitions/misc/metadata_tags"}
  110. }
  111. },
  112. "source": {"$ref": "#/definitions/misc/source"}
  113. }
  114. },
  115. "markdown_cell": {
  116. "description": "Notebook markdown cell.",
  117. "type": "object",
  118. "additionalProperties": false,
  119. "required": ["cell_type", "source"],
  120. "properties": {
  121. "cell_type": {
  122. "description": "String identifying the type of cell.",
  123. "enum": ["markdown", "html"]
  124. },
  125. "metadata": {
  126. "description": "Cell-level metadata.",
  127. "type": "object",
  128. "properties": {
  129. "name": {"$ref": "#/definitions/misc/metadata_name"},
  130. "tags": {"$ref": "#/definitions/misc/metadata_tags"}
  131. },
  132. "additionalProperties": true
  133. },
  134. "source": {"$ref": "#/definitions/misc/source"}
  135. }
  136. },
  137. "heading_cell": {
  138. "description": "Notebook heading cell.",
  139. "type": "object",
  140. "additionalProperties": false,
  141. "required": ["cell_type", "source", "level"],
  142. "properties": {
  143. "cell_type": {
  144. "description": "String identifying the type of cell.",
  145. "enum": ["heading"]
  146. },
  147. "metadata": {
  148. "description": "Cell-level metadata.",
  149. "type": "object",
  150. "additionalProperties": true
  151. },
  152. "source": {"$ref": "#/definitions/misc/source"},
  153. "level": {
  154. "description": "Level of heading cells.",
  155. "type": "integer",
  156. "minimum": 1
  157. }
  158. }
  159. },
  160. "code_cell": {
  161. "description": "Notebook code cell.",
  162. "type": "object",
  163. "additionalProperties": false,
  164. "required": ["cell_type", "input", "outputs", "language"],
  165. "properties": {
  166. "cell_type": {
  167. "description": "String identifying the type of cell.",
  168. "enum": ["code"]
  169. },
  170. "language": {
  171. "description": "The cell's language (always Python)",
  172. "type": "string"
  173. },
  174. "collapsed": {
  175. "description": "Whether the cell is collapsed/expanded.",
  176. "type": "boolean"
  177. },
  178. "metadata": {
  179. "description": "Cell-level metadata.",
  180. "type": "object",
  181. "additionalProperties": true
  182. },
  183. "input": {"$ref": "#/definitions/misc/source"},
  184. "outputs": {
  185. "description": "Execution, display, or stream outputs.",
  186. "type": "array",
  187. "items": {"$ref": "#/definitions/output"}
  188. },
  189. "prompt_number": {
  190. "description": "The code cell's prompt number. Will be null if the cell has not been run.",
  191. "type": ["integer", "null"],
  192. "minimum": 0
  193. }
  194. }
  195. },
  196. "output": {
  197. "type": "object",
  198. "oneOf": [
  199. {"$ref": "#/definitions/pyout"},
  200. {"$ref": "#/definitions/display_data"},
  201. {"$ref": "#/definitions/stream"},
  202. {"$ref": "#/definitions/pyerr"}
  203. ]
  204. },
  205. "pyout": {
  206. "description": "Result of executing a code cell.",
  207. "type": "object",
  208. "additionalProperties": false,
  209. "required": ["output_type", "prompt_number"],
  210. "properties": {
  211. "output_type": {
  212. "description": "Type of cell output.",
  213. "enum": ["pyout"]
  214. },
  215. "prompt_number": {
  216. "description": "A result's prompt number.",
  217. "type": ["integer"],
  218. "minimum": 0
  219. },
  220. "text": {"$ref": "#/definitions/misc/multiline_string"},
  221. "latex": {"$ref": "#/definitions/misc/multiline_string"},
  222. "png": {"$ref": "#/definitions/misc/multiline_string"},
  223. "jpeg": {"$ref": "#/definitions/misc/multiline_string"},
  224. "svg": {"$ref": "#/definitions/misc/multiline_string"},
  225. "html": {"$ref": "#/definitions/misc/multiline_string"},
  226. "javascript": {"$ref": "#/definitions/misc/multiline_string"},
  227. "json": {"$ref": "#/definitions/misc/multiline_string"},
  228. "pdf": {"$ref": "#/definitions/misc/multiline_string"},
  229. "metadata": {"$ref": "#/definitions/misc/output_metadata"}
  230. },
  231. "patternProperties": {
  232. "^[a-zA-Z0-9]+/[a-zA-Z0-9\\-\\+\\.]+$": {
  233. "description": "mimetype output (e.g. text/plain), represented as either an array of strings or a string.",
  234. "$ref": "#/definitions/misc/multiline_string"
  235. }
  236. }
  237. },
  238. "display_data": {
  239. "description": "Data displayed as a result of code cell execution.",
  240. "type": "object",
  241. "additionalProperties": false,
  242. "required": ["output_type"],
  243. "properties": {
  244. "output_type": {
  245. "description": "Type of cell output.",
  246. "enum": ["display_data"]
  247. },
  248. "text": {"$ref": "#/definitions/misc/multiline_string"},
  249. "latex": {"$ref": "#/definitions/misc/multiline_string"},
  250. "png": {"$ref": "#/definitions/misc/multiline_string"},
  251. "jpeg": {"$ref": "#/definitions/misc/multiline_string"},
  252. "svg": {"$ref": "#/definitions/misc/multiline_string"},
  253. "html": {"$ref": "#/definitions/misc/multiline_string"},
  254. "javascript": {"$ref": "#/definitions/misc/multiline_string"},
  255. "json": {"$ref": "#/definitions/misc/multiline_string"},
  256. "pdf": {"$ref": "#/definitions/misc/multiline_string"},
  257. "metadata": {"$ref": "#/definitions/misc/output_metadata"}
  258. },
  259. "patternProperties": {
  260. "[a-zA-Z0-9]+/[a-zA-Z0-9\\-\\+\\.]+$": {
  261. "description": "mimetype output (e.g. text/plain), represented as either an array of strings or a string.",
  262. "$ref": "#/definitions/misc/multiline_string"
  263. }
  264. }
  265. },
  266. "stream": {
  267. "description": "Stream output from a code cell.",
  268. "type": "object",
  269. "additionalProperties": false,
  270. "required": ["output_type", "stream", "text"],
  271. "properties": {
  272. "output_type": {
  273. "description": "Type of cell output.",
  274. "enum": ["stream"]
  275. },
  276. "stream": {
  277. "description": "The stream type/destination.",
  278. "type": "string"
  279. },
  280. "text": {
  281. "description": "The stream's text output, represented as an array of strings.",
  282. "$ref": "#/definitions/misc/multiline_string"
  283. }
  284. }
  285. },
  286. "pyerr": {
  287. "description": "Output of an error that occurred during code cell execution.",
  288. "type": "object",
  289. "additionalProperties": false,
  290. "required": ["output_type", "ename", "evalue", "traceback"],
  291. "properties": {
  292. "output_type": {
  293. "description": "Type of cell output.",
  294. "enum": ["pyerr"]
  295. },
  296. "ename": {
  297. "description": "The name of the error.",
  298. "type": "string"
  299. },
  300. "evalue": {
  301. "description": "The value, or message, of the error.",
  302. "type": "string"
  303. },
  304. "traceback": {
  305. "description": "The error's traceback, represented as an array of strings.",
  306. "type": "array",
  307. "items": {"type": "string"}
  308. }
  309. }
  310. },
  311. "misc": {
  312. "metadata_name": {
  313. "description": "The cell's name. If present, must be a non-empty string.",
  314. "type": "string",
  315. "pattern": "^.+$"
  316. },
  317. "metadata_tags": {
  318. "description": "The cell's tags. Tags must be unique, and must not contain commas.",
  319. "type": "array",
  320. "uniqueItems": true,
  321. "items": {
  322. "type": "string",
  323. "pattern": "^[^,]+$"
  324. }
  325. },
  326. "source": {
  327. "description": "Contents of the cell, represented as an array of lines.",
  328. "$ref": "#/definitions/misc/multiline_string"
  329. },
  330. "prompt_number": {
  331. "description": "The code cell's prompt number. Will be null if the cell has not been run.",
  332. "type": ["integer", "null"],
  333. "minimum": 0
  334. },
  335. "mimetype": {
  336. "patternProperties": {
  337. "^[a-zA-Z0-9\\-\\+]+/[a-zA-Z0-9\\-\\+]+": {
  338. "description": "The cell's mimetype output (e.g. text/plain), represented as either an array of strings or a string.",
  339. "$ref": "#/definitions/misc/multiline_string"
  340. }
  341. }
  342. },
  343. "output_metadata": {
  344. "description": "Cell output metadata.",
  345. "type": "object",
  346. "additionalProperties": true
  347. },
  348. "multiline_string": {
  349. "oneOf" : [
  350. {"type": "string"},
  351. {
  352. "type": "array",
  353. "items": {"type": "string"}
  354. }
  355. ]
  356. }
  357. }
  358. }
  359. }