From e38b29b409bcb34bed6f2d71cc0c243cf5299da1 Mon Sep 17 00:00:00 2001 From: Jutta Schnabel <jutta.schnabel@fau.de> Date: Tue, 20 Aug 2024 10:26:11 +0200 Subject: [PATCH] setting up sphinx building --- .gitlab-ci.yml | 41 ++++++++++++--- docs/GitRev.tex | 1 - docs/Makefile | 20 +++++++ docs/index.json | 5 -- docs/km3net-dataformat-specifications.tex | 18 ------- docs/make.bat | 35 +++++++++++++ docs/source/conf.py | 57 ++++++++++++++++++++ docs/source/index.rst | 20 +++++++ docs/specs/glossary.json | 0 docs/specs/template_index.json | 11 ---- docs/specs/template_specs.json | 32 ------------ requirements.txt | 2 + specs/README.md | 3 ++ specs/templates/dataformat_standard.js | 64 +++++++++++++++++++++++ 14 files changed, 234 insertions(+), 75 deletions(-) delete mode 100644 docs/GitRev.tex create mode 100644 docs/Makefile delete mode 100644 docs/index.json delete mode 100644 docs/km3net-dataformat-specifications.tex create mode 100644 docs/make.bat create mode 100644 docs/source/conf.py create mode 100644 docs/source/index.rst delete mode 100644 docs/specs/glossary.json delete mode 100644 docs/specs/template_index.json delete mode 100644 docs/specs/template_specs.json create mode 100644 requirements.txt create mode 100644 specs/README.md create mode 100644 specs/templates/dataformat_standard.js diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 98684de..c116500 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,9 +1,34 @@ +image: python:3.11 + +stages: + - build + - deploy + +variables: + DOCS_DIR: docs + BUILD_DIR: public + PAGES_BRANCH: "basic_setup" + +before_script: + - python -m pip install --upgrade pip + - pip install -r requirements.txt + +build_docs: + stage: build + script: + - sphinx-build -b html $DOCS_DIR/source $BUILD_DIR + artifacts: + paths: + - $BUILD_DIR + only: + - $PAGES_BRANCH + pages: - image: docker.km3net.de/base/texlive:2023 - script: - - make - - mkdir public - - cp km3net-dataformat-specifications.pdf public/ - artifacts: - paths: - - public + stage: deploy + script: + - mv $BUILD_DIR public + artifacts: + paths: + - public + only: + - $PAGES_BRANCH diff --git a/docs/GitRev.tex b/docs/GitRev.tex deleted file mode 100644 index bacbcb3..0000000 --- a/docs/GitRev.tex +++ /dev/null @@ -1 +0,0 @@ -\begin{center} Git release: , date . \end{center} diff --git a/docs/Makefile b/docs/Makefile new file mode 100644 index 0000000..d0c3cbf --- /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 = source +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/index.json b/docs/index.json deleted file mode 100644 index 15c3e0e..0000000 --- a/docs/index.json +++ /dev/null @@ -1,5 +0,0 @@ -- glossary -- build from folders - - intro.json - - specs document - \ No newline at end of file diff --git a/docs/km3net-dataformat-specifications.tex b/docs/km3net-dataformat-specifications.tex deleted file mode 100644 index e2e90ee..0000000 --- a/docs/km3net-dataformat-specifications.tex +++ /dev/null @@ -1,18 +0,0 @@ -\documentclass[a4paper, 11pt]{article} -\usepackage{graphicx} -\usepackage{color} -\usepackage{hyperref} - -\begin{document} -\title{KM3NeT Dataformat Specifications} -\author{Tamas Gal and Mieke Bouwhuis} -\date{\today} -\maketitle - -\tableofcontents - -\section{Detector Description (DETX, DATX)...} - -The corresponding Google drive document: https://drive.google.com/open?id=0B6l8SNtndcwaUTZPOWZOXzd6R3M - -\end{document} diff --git a/docs/make.bat b/docs/make.bat new file mode 100644 index 0000000..747ffb7 --- /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=source +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/docs/source/conf.py b/docs/source/conf.py new file mode 100644 index 0000000..a1d7e8c --- /dev/null +++ b/docs/source/conf.py @@ -0,0 +1,57 @@ +# Configuration file for the Sphinx documentation builder. +# +# This file only contains a selection of the most common options. For a full +# list see the documentation: +# https://www.sphinx-doc.org/en/master/usage/configuration.html + +# -- Path setup -------------------------------------------------------------- + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +# +# import os +# import sys +# sys.path.insert(0, os.path.abspath('.')) + + +# -- Project information ----------------------------------------------------- + +project = 'KM3NeT Dataformat Specifications' +copyright = '2024, The KM3NeT Collaboration' +author = 'The KM3NeT Collaboration' + +# The full version, including alpha/beta/rc tags +release = '0.1' + + +# -- General configuration --------------------------------------------------- + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. +extensions = [ + 'sphinx.ext.autodoc', + 'sphinx-jsonschema' +] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +# This pattern also affects html_static_path and html_extra_path. +exclude_patterns = [] + + +# -- Options for HTML output ------------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +# +html_theme = 'alabaster' + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ['_static'] diff --git a/docs/source/index.rst b/docs/source/index.rst new file mode 100644 index 0000000..c81337d --- /dev/null +++ b/docs/source/index.rst @@ -0,0 +1,20 @@ +.. KM3NeT Dataformat Specifications documentation master file, created by + sphinx-quickstart on Tue Aug 20 09:58:21 2024. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +Welcome to KM3NeT Dataformat Specifications's documentation! +============================================================ + +.. toctree:: + :maxdepth: 2 + :caption: Contents: + + + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` diff --git a/docs/specs/glossary.json b/docs/specs/glossary.json deleted file mode 100644 index e69de29..0000000 diff --git a/docs/specs/template_index.json b/docs/specs/template_index.json deleted file mode 100644 index 83b66fa..0000000 --- a/docs/specs/template_index.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "description": "An introduction to the format", - "references": - { - "key": - { - "title": "x", - "reference": "URL" - } - } -} \ No newline at end of file diff --git a/docs/specs/template_specs.json b/docs/specs/template_specs.json deleted file mode 100644 index 0d30250..0000000 --- a/docs/specs/template_specs.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "title": "Extended name", - "description": "An introduction to the format", - "version": "", - "filename_convention": - { - "namestring": "", - "placeholder": {"abbrev": "description"} - }, - "related_software": "", - "filetype": "", - "fields": - { - "name": "", - "description": "", - "ismandatory": "", - "datatype": "", - "contraints": "" - }, - "headers": {}, - "metadata": {}, - "example": {}, - "validator": {}, - "references": - { - "key": - { - "title": "x", - "reference": "URL" - } - } -} \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..c6b464c --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +sphinx +sphinx-jsonschema diff --git a/specs/README.md b/specs/README.md new file mode 100644 index 0000000..37bcda8 --- /dev/null +++ b/specs/README.md @@ -0,0 +1,3 @@ +# Data format specifications + +How to add ... diff --git a/specs/templates/dataformat_standard.js b/specs/templates/dataformat_standard.js new file mode 100644 index 0000000..0950d9d --- /dev/null +++ b/specs/templates/dataformat_standard.js @@ -0,0 +1,64 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "Example Data Format", + "description": "This schema defines the format for the example data used in our physics experiment.", + "type": "object", + "properties": { + "experiment_id": { + "type": "string", + "description": "Unique identifier for the experiment.", + "examples": ["EXP12345"] + }, + "timestamp": { + "type": "string", + "format": "date-time", + "description": "Timestamp when the data was collected.", + "examples": ["2024-08-19T14:31:00Z"] + }, + "sensor_data": { + "type": "array", + "description": "Array of sensor readings collected during the experiment.", + "items": { + "type": "object", + "properties": { + "sensor_id": { + "type": "string", + "description": "Unique identifier for the sensor.", + "examples": ["SENSOR001"] + }, + "value": { + "type": "number", + "description": "The reading value from the sensor.", + "examples": [23.5] + }, + "unit": { + "type": "string", + "description": "The unit of the sensor reading.", + "enum": ["Celsius", "Kelvin", "Fahrenheit"], + "examples": ["Celsius"] + } + }, + "required": ["sensor_id", "value", "unit"] + } + }, + "metadata": { + "type": "object", + "description": "Additional metadata about the experiment.", + "properties": { + "location": { + "type": "string", + "description": "Location where the experiment was conducted.", + "examples": ["Lab A"] + }, + "operator": { + "type": "string", + "description": "Name or ID of the person who conducted the experiment.", + "examples": ["John Doe"] + } + }, + "required": ["location"] + } + }, + "required": ["experiment_id", "timestamp", "sensor_data"], + "additionalProperties": false +} -- GitLab