-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Automate Signer API docs for RTD #622
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,3 +15,6 @@ env/* | |
tests/htmlcov/* | ||
.DS_Store | ||
.python-version | ||
|
||
# Sphinx documentation | ||
docs/_build/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# .readthedocs.yaml | ||
# Read the Docs configuration file | ||
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details | ||
|
||
version: 2 | ||
build: | ||
os: ubuntu-22.04 | ||
apt_packages: | ||
- swig | ||
- softhsm2 | ||
tools: | ||
python: "3.11" | ||
|
||
sphinx: | ||
builder: html | ||
configuration: docs/conf.py | ||
fail_on_warning: true | ||
|
||
python: | ||
install: | ||
- requirements: requirements-docs.txt |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# 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(os.path.join(".."))) | ||
|
||
import securesystemslib | ||
|
||
# -- Project information ----------------------------------------------------- | ||
|
||
project = "securesystemslib" | ||
copyright = "2023, New York University and the securesystemslib contributors" | ||
author = "New York University and the securesystemslib contributors" | ||
|
||
|
||
# -- General configuration --------------------------------------------------- | ||
|
||
master_doc = "index" | ||
|
||
# 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.napoleon", | ||
"sphinx.ext.autosummary", | ||
"sphinx.ext.autosectionlabel", | ||
] | ||
|
||
autosectionlabel_prefix_document = True | ||
|
||
|
||
# -- 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 = "sphinx_rtd_theme" | ||
|
||
# -- Autodoc configuration --------------------------------------------------- | ||
# https://www.sphinx-doc.org/en/master/usage/extensions/autodoc.html | ||
|
||
# Shorten paths | ||
add_module_names = False | ||
python_use_unqualified_type_names = True | ||
|
||
# Show typehints in argument doc lines, but not in signatures | ||
autodoc_typehints = "description" | ||
|
||
autodoc_default_options = { | ||
"members": True, | ||
"inherited-members": "Exception", # excl. members inherited from 'Exception' | ||
} | ||
|
||
# Version | ||
version = securesystemslib.__version__ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
Welcome to ``securesystemslib`` | ||
=============================== | ||
|
||
A cryptography interface to sign and verify `TUF | ||
<https://theupdateframework.io>`_ and `in-toto <https://in-toto.io>`_ metadata. | ||
|
||
.. note:: | ||
This documentation is built for | ||
`securesystemslib (Python) <https://github.com/secure-systems-lab/securesystemslib>`_, used by | ||
`python-tuf <https://github.com/theupdateframework/python-tuf/>`_ and | ||
`in-toto (Python) <https://github.com/in-toto/in-toto>`_ reference implementations. | ||
|
||
.. toctree:: | ||
:maxdepth: 2 | ||
:caption: Contents | ||
|
||
signer |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
Signer API | ||
========== | ||
|
||
.. currentmodule:: securesystemslib.signer | ||
|
||
.. warning:: | ||
The API is experimental and may change without warning in versions ``<1.0.0``. | ||
|
||
See `'New Signer API' <https://theupdateframework.github.io/python-tuf/2023/01/24/securesystemslib-signer-api.html>`_ blog post | ||
for background infos. | ||
|
||
|
||
.. Autodoc cannot resolve docs for imported globals (sphinx-doc/sphinx#6495) | ||
.. As workaround we reference their original internal definition. | ||
.. autodata:: securesystemslib.signer._signer.SIGNER_FOR_URI_SCHEME | ||
:no-value: | ||
.. autodata:: securesystemslib.signer._key.KEY_FOR_TYPE_AND_SCHEME | ||
:no-value: | ||
.. autoclass:: securesystemslib.signer.Signer | ||
.. autoclass:: securesystemslib.signer.Key | ||
.. autoclass:: securesystemslib.signer.Signature |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,5 @@ tox | |
-r requirements.txt | ||
-r requirements-test.txt | ||
-r requirements-lint.txt | ||
-r requirements-docs.txt | ||
-e . |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
-r requirements-pinned.txt | ||
|
||
# install sphinx and its extensions | ||
sphinx | ||
sphinx-rtd-theme |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,12 @@ class Signature: | |
Provides utility methods to easily create an object from a dictionary | ||
and return the dictionary representation of the object. | ||
|
||
Args: | ||
keyid: HEX string used as a unique identifier of the key. | ||
sig: HEX string representing the signature. | ||
unrecognized_fields: Dictionary of all attributes that are not managed | ||
by securesystemslib. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Repeating Args and Attributes seems silly. I'd prefer to only use "Args" here and say "All parameters named below are not just constructor arguments but also instance attributes." as we do in the The problem is we use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah, consolidate now sounds good: No-one outside of securesystemslib should should be calling Signature() so the fallout should be minimal. This doesn't have to be in this PR though |
||
|
||
Attributes: | ||
keyid: HEX string used as a unique identifier of the key. | ||
signature: HEX string representing the signature. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
swig
andsofthsm2
are needed forpykcs11
, which we install in requirements-docs.txt viarequirements-pinned.txt
.We can probably shuffle requirements* files so that we don't need to install any optional requirements.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion makes sense but if rtd is fine with us installing random software... I suppose this is ok