diff --git a/docs/Makefile b/docs/Makefile new file mode 100644 index 0000000..d4bb2cb --- /dev/null +++ b/docs/Makefile @@ -0,0 +1,20 @@ +# Minimal makefile for Sphinx documentation +# + +# You can set these variables from the command line, and also +# from the environment for the first two. +SPHINXOPTS ?= +SPHINXBUILD ?= sphinx-build +SOURCEDIR = . +BUILDDIR = _build + +# Put it first so that "make" without argument is like "make help". +help: + @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + +.PHONY: help Makefile + +# Catch-all target: route all unknown targets to Sphinx using the new +# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). +%: Makefile + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) diff --git a/docs/conf.py b/docs/conf.py new file mode 100644 index 0000000..6a5b498 --- /dev/null +++ b/docs/conf.py @@ -0,0 +1,31 @@ +# Configuration file for the Sphinx documentation builder. +# +# For the full list of built-in configuration values, see the documentation: +# https://www.sphinx-doc.org/en/master/usage/configuration.html + +# -- Project information ----------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information + +project = 'jupyter-schemas' +copyright = '2024, .' +author = 'Jupyter Development Team' + +# -- General configuration --------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration + +extensions = [ + 'sphinx.ext.autodoc', + 'sphinx_design', + 'sphinx-jsonschema' +] + +templates_path = ['_templates'] +exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] + + + +# -- Options for HTML output ------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output + +html_theme = 'pydata_sphinx_theme' +html_static_path = ['_static'] diff --git a/docs/example.rst b/docs/example.rst new file mode 100644 index 0000000..01400e4 --- /dev/null +++ b/docs/example.rst @@ -0,0 +1,129 @@ +Example schema +============== + +.. tab-set:: + + .. tab-item:: Rendered using sphinx-jsonschema + + .. jsonschema:: ../schema/server/events/kernel-actions/v1/kernel-actions.schema.json + + .. tab-item:: JSON + + .. literalinclude:: ../schema/server/events/kernel-actions/v1/kernel-actions.schema.json + :language: JSON + + .. tab-item:: TOML + + .. code-block:: toml + + "$schema" = "https://json-schema.org/draft/2020-12/schema" + "$id" = "https://schema.jupyter.org/server/events/kernel-actions/v1/kernel-actions.schema.json" + version = 1 + title = "Kernel Manager activities" + personal-data = true + description = "Record events of a kernel manager.\n" + type = "object" + required = [ "action", "msg",] + + [properties.action] + enum = [ "start", "interrupt", "shutdown", "restart",] + description = "Action performed by the Kernel Manager.\n\nThis is a required field.\n\nPossible values:\n\n1. start\n A kernel has been started with the given kernel id.\n\n2. interrupt\n A kernel has been interrupted for the given kernel id.\n\n3. shutdown\n A kernel has been shut down for the given kernel id.\n\n4. restart\n A kernel has been restarted for the given kernel id.\n" + + [properties.kernel_id] + type = "string" + description = "Kernel id.\n\nThis is a required field for all actions and statuses except action start with status error.\n" + + [properties.kernel_name] + type = "string" + description = "Name of the kernel.\n" + + [properties.status] + enum = [ "error", "success",] + description = "Status received from a rest api operation to kernel server.\n\nThis is a required field.\n\nPossible values:\n\n1. error\n Error response from a rest api operation to kernel server.\n\n2. success\n Success response from a rest api operation to kernel server.\n" + + [properties.status_code] + type = "number" + description = "Http response codes from a rest api operation to kernel server.\nExamples: 200, 400, 502, 503, 599 etc\n" + + [properties.msg] + type = "string" + description = "Description of the event specified in action.\n" + + [if.not.properties.status] + const = "error" + + [if.not.properties.action] + const = "start" + + [then] + required = [ "kernel_id",] + + .. tab-item:: YAML + + .. code-block:: yaml + + $schema: https://json-schema.org/draft/2020-12/schema + $id: https://schema.jupyter.org/server/events/kernel-actions/v1/kernel-actions.schema.json + version: 1 + title: Kernel Manager activities + personal-data: true + description: 'Record events of a kernel manager. + + ' + type: object + required: + - action + - msg + properties: + action: + enum: + - start + - interrupt + - shutdown + - restart + description: "Action performed by the Kernel Manager.\n\nThis is a required field.\n\nPossible values:\n\ + \n1. start\n A kernel has been started with the given kernel id.\n\n2. interrupt\n A kernel\ + \ has been interrupted for the given kernel id.\n\n3. shutdown\n A kernel has been shut down for\ + \ the given kernel id.\n\n4. restart\n A kernel has been restarted for the given kernel id.\n" + kernel_id: + type: string + description: 'Kernel id. + + + This is a required field for all actions and statuses except action start with status error. + + ' + kernel_name: + type: string + description: 'Name of the kernel. + + ' + status: + enum: + - error + - success + description: "Status received from a rest api operation to kernel server.\n\nThis is a required field.\n\ + \nPossible values:\n\n1. error\n Error response from a rest api operation to kernel server.\n\n\ + 2. success\n Success response from a rest api operation to kernel server.\n" + status_code: + type: number + description: 'Http response codes from a rest api operation to kernel server. + + Examples: 200, 400, 502, 503, 599 etc + + ' + msg: + type: string + description: 'Description of the event specified in action. + + ' + if: + not: + properties: + status: + const: error + action: + const: start + then: + required: + - kernel_id diff --git a/docs/index.rst b/docs/index.rst new file mode 100644 index 0000000..b90026c --- /dev/null +++ b/docs/index.rst @@ -0,0 +1,21 @@ +.. jupyter-schemas documentation master file, created by + sphinx-quickstart on Fri Feb 23 14:44:15 2024. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +Welcome to jupyter-schemas's documentation! +=========================================== + +.. toctree:: + :maxdepth: 2 + :caption: Contents: + + example + + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` diff --git a/docs/make.bat b/docs/make.bat new file mode 100644 index 0000000..32bb245 --- /dev/null +++ b/docs/make.bat @@ -0,0 +1,35 @@ +@ECHO OFF + +pushd %~dp0 + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) +set SOURCEDIR=. +set BUILDDIR=_build + +%SPHINXBUILD% >NUL 2>NUL +if errorlevel 9009 ( + echo. + echo.The 'sphinx-build' command was not found. Make sure you have Sphinx + echo.installed, then set the SPHINXBUILD environment variable to point + echo.to the full path of the 'sphinx-build' executable. Alternatively you + echo.may add the Sphinx directory to PATH. + echo. + echo.If you don't have Sphinx installed, grab it from + echo.https://www.sphinx-doc.org/ + exit /b 1 +) + +if "%1" == "" goto help + +%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% +goto end + +:help +%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% + +:end +popd diff --git a/pyproject.toml b/pyproject.toml index 7ec7d63..b3df010 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -36,6 +36,12 @@ Source = "https://github.com/unknown/jupyter-schemas" test = [ "pytest", ] +docs = [ + "pydata_sphinx_theme", + "sphinx", + "sphinx_design", + "sphinx-jsonschema", +] [tool.hatch.version] path = "jupyter_schemas.py"