From 0ac884642d3ae4c2f5e40f9d07ccbddc5a1a1638 Mon Sep 17 00:00:00 2001 From: Andreas Motl Date: Mon, 5 Feb 2024 00:48:23 +0100 Subject: [PATCH] Documentation: Add Sphinx and Read the Docs project configuration --- .gitignore | 1 + .readthedocs.yml | 21 +++++++++++++++++++++ Makefile | 10 +++++++--- docs/Makefile | 20 ++++++++++++++++++++ docs/_static/.gitkeep | 0 docs/_templates/.gitkeep | 0 docs/conf.py | 27 +++++++++++++++++++++++++++ docs/index.md | 8 ++++++++ docs/make.bat | 35 +++++++++++++++++++++++++++++++++++ docs/requirements-dev.txt | 1 + docs/requirements.txt | 3 +++ 11 files changed, 123 insertions(+), 3 deletions(-) create mode 100644 .readthedocs.yml create mode 100644 docs/Makefile create mode 100644 docs/_static/.gitkeep create mode 100644 docs/_templates/.gitkeep create mode 100644 docs/conf.py create mode 100644 docs/index.md create mode 100644 docs/make.bat create mode 100644 docs/requirements-dev.txt create mode 100644 docs/requirements.txt diff --git a/.gitignore b/.gitignore index 71f9712..6d079c2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .idea .pio .venv* +docs/_build diff --git a/.readthedocs.yml b/.readthedocs.yml new file mode 100644 index 0000000..5680b20 --- /dev/null +++ b/.readthedocs.yml @@ -0,0 +1,21 @@ +# .readthedocs.yml +# Read the Docs configuration file + +# Details +# - https://docs.readthedocs.io/en/stable/config-file/v2.html + +version: 2 + +build: + os: "ubuntu-22.04" + tools: + python: "3.11" + +sphinx: + builder: html + configuration: docs/conf.py + fail_on_warning: true + +python: + install: + - requirements: docs/requirements.txt diff --git a/Makefile b/Makefile index db6c16d..1f477f6 100644 --- a/Makefile +++ b/Makefile @@ -3,10 +3,14 @@ $(eval python := $(venvpath)/bin/python) $(eval pip := $(venvpath)/bin/pip) $(eval platformio := $(venvpath)/bin/platformio) +setup-virtualenv: + @test -e $(python) || python3 -m venv $(venvpath) + $(pip) install platformio +.PHONY: build build: setup-virtualenv $(platformio) run -setup-virtualenv: - @test -e $(python) || `command -v virtualenv` --python=python3 $(venvpath) - $(pip) install platformio +.PHONY: docs +docs: setup-virtualenv + $(pip) install -r docs/requirements.txt -r docs/requirements-dev.txt 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/_static/.gitkeep b/docs/_static/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/docs/_templates/.gitkeep b/docs/_templates/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/docs/conf.py b/docs/conf.py new file mode 100644 index 0000000..005fd21 --- /dev/null +++ b/docs/conf.py @@ -0,0 +1,27 @@ +# 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 = 'HaniMandl' +copyright = '2024, The HaniMandl Developers' +author = 'The HaniMandl Developers' + +# -- General configuration --------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration + +extensions = ["myst_parser"] + +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 = 'furo' +html_static_path = ['_static'] diff --git a/docs/index.md b/docs/index.md new file mode 100644 index 0000000..08d6586 --- /dev/null +++ b/docs/index.md @@ -0,0 +1,8 @@ +# Welcome to HaniMandl + +```{toctree} +:maxdepth: 1 + +handbook-de +handbook-en +``` 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/docs/requirements-dev.txt b/docs/requirements-dev.txt new file mode 100644 index 0000000..18deadb --- /dev/null +++ b/docs/requirements-dev.txt @@ -0,0 +1 @@ +sphinx-autobuild==2024.2.4 diff --git a/docs/requirements.txt b/docs/requirements.txt new file mode 100644 index 0000000..357e9fd --- /dev/null +++ b/docs/requirements.txt @@ -0,0 +1,3 @@ +furo==2024.1.29 +myst-parser>=2,<3 +sphinx>=7,<7.3