From 2364f41f3ba4c4ba4e3360e48577151ac52bddef Mon Sep 17 00:00:00 2001 From: Robin Krahl Date: Thu, 25 Jul 2024 13:05:01 +0200 Subject: [PATCH] Add Nitrokey Python SDK documentation Fixes: https://github.com/Nitrokey/nitrokey-documentation/issues/329 --- .gitignore | 1 + Makefile | 23 ++++++++++++++++++++--- source/components/software/index.rst | 1 + source/conf.py | 9 ++++++++- 4 files changed, 30 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index eff47bedfe..1b4a8f6bee 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ build dist venv +nitrokey-sdk-py* diff --git a/Makefile b/Makefile index 2d144c4e82..8f745894b2 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,29 @@ +NITROKEY_SDK_PY_VERSION ?= v0.2.3 +NITROKEY_SDK_PY_URL := https://github.com/Nitrokey/nitrokey-sdk-py/archive/refs/tags/$(NITROKEY_SDK_PY_VERSION).tar.gz +NITROKEY_SDK_PY := nitrokey-sdk-py-$(NITROKEY_SDK_PY_VERSION) +NITROKEY_SDK_PY_ARCHIVE := $(NITROKEY_SDK_PY).tar.gz +NITROKEY_SDK_PY_LINK := source/components/software/nitrokey-sdk-py - +.PHONY: all all: venv venv/bin/sphinx-build -j auto -b html -D language=en -d build/en/doctrees source dist/en -venv: +.PHONY: venv +venv: $(NITROKEY_SDK_PY) python -m venv venv venv/bin/pip3 install -r requirements.txt + venv/bin/pip3 install ./$(NITROKEY_SDK_PY) + +$(NITROKEY_SDK_PY): $(NITROKEY_SDK_PY_ARCHIVE) + mkdir "$@" + tar --directory "$@" --extract --strip-components 1 --file "$<" + rm -f $(NITROKEY_SDK_PY_LINK) + ln -s ../../../$(NITROKEY_SDK_PY)/docs $(NITROKEY_SDK_PY_LINK) + +$(NITROKEY_SDK_PY_ARCHIVE): + curl "$(NITROKEY_SDK_PY_URL)" --location --output "$@" +.PHONY: clean clean: - rm -rf dist build venv + rm -rf dist build venv nitrokey-sdk-py* $(NITROKEY_SDK_PY_LINK) diff --git a/source/components/software/index.rst b/source/components/software/index.rst index 2fc32150d5..86736050ca 100644 --- a/source/components/software/index.rst +++ b/source/components/software/index.rst @@ -7,3 +7,4 @@ Software nk-app2/index nitropy/index + nitrokey-sdk-py/index diff --git a/source/conf.py b/source/conf.py index 3165f8f854..bd97dd48c8 100644 --- a/source/conf.py +++ b/source/conf.py @@ -39,6 +39,7 @@ # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = [ + 'sphinx.ext.autodoc', 'sphinx.ext.todo', 'sphinx.ext.coverage', #'sphinx_copybutton', @@ -71,7 +72,7 @@ # 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 = ['venv/*', 'components/nethsm/_*.rst', 'components/to-be-integrated.rst'] +exclude_patterns = ['venv/*', 'components/nethsm/_*.rst', 'components/to-be-integrated.rst', 'nitrokey-sdk-py/*'] # The name of the Pygments (syntax highlighting) style to use. #pygments_style = "solarizeddark" @@ -434,3 +435,9 @@ # Disables the closing of tabs if clicked on the currently active tab sphinx_tabs_disable_tab_closing = True + +# -- Options for autodoc extension ------------------------------------------- + +autodoc_class_signature = 'separated' +autodoc_member_order = 'groupwise' +autodoc_typehints = 'description'