Skip to content

Commit

Permalink
Update documentation => readthedocs v2
Browse files Browse the repository at this point in the history
  • Loading branch information
rkoopmans committed Oct 21, 2023
1 parent 0213bb7 commit ca1a6c4
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -6,3 +6,4 @@
.coverage
htmlcov
docs/_build
.reqs_docs
23 changes: 23 additions & 0 deletions .readthedocs.yaml
@@ -0,0 +1,23 @@
# .readthedocs.yaml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Set the version of Python and other tools you might need
build:
os: ubuntu-22.04
tools:
python: "3.11"

# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: docs/conf.py

# We recommend specifying your dependencies to enable reproducible builds:
# https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
python:
install:
- requirements: requirements_docs.txt
- requirements: requirements.txt
10 changes: 9 additions & 1 deletion Makefile
@@ -1,7 +1,7 @@
ENV_DIR = ./env
PIP := $(ENV_DIR)/bin/pip

.PHONY: all tests coverage clean pyclean
.PHONY: all tests coverage clean pyclean docs

all: tests

Expand All @@ -16,9 +16,17 @@ $(PIP):
$(PIP) install -r requirements_dev.txt
@touch $@

.reqs_docs: .reqs requirements_docs.txt
$(PIP) install -r requirements_docs.txt
touch $@

tests: .reqs .reqs_dev
./env/bin/tox $(TEST_ARGS)

docs: .reqs .reqs_docs
./env/bin/sphinx-build docs docs/_build


coverage:
./env/bin/py.test --cov-report html --cov=cert_chain_resolver --cov-fail-under=90

Expand Down
3 changes: 2 additions & 1 deletion cert_chain_resolver/cli.py
Expand Up @@ -29,7 +29,8 @@ def _print_chain_details(chain):
print("")


def cli(file_bytes=None, show_details=None):
def cli(file_bytes, show_details=False):
# type: (bytes, bool) -> None
chain = resolve(file_bytes)
if show_details:
_print_chain_details(chain)
Expand Down
2 changes: 1 addition & 1 deletion cert_chain_resolver/models.py
Expand Up @@ -25,7 +25,7 @@ class Cert:
wrapper for interacting with the underlying :py:class:`cryptography.x509.Certificate` object
Args:
x509_obj (:py:class:`cryptography.x509.Certificate`): An instance of :py:class:`cryptography.x509.Certificate`
x509_obj: An instance of :py:class:`cryptography.x509.Certificate`
Raises:
TypeError: given type is not an instance of :py:class:`cryptography.x509.Certificate`
"""
Expand Down
6 changes: 6 additions & 0 deletions cert_chain_resolver/utils.py
Expand Up @@ -14,6 +14,8 @@

def load_ascii_to_x509(bytes_input):
# type: (bytes) -> x509.Certificate
""" Converts ASCII PKCS7 or Certificate to a :py:class:`cryptography.x509.Certificate` object
"""
first_line = bytes_input.decode("ascii").splitlines()[0]
if first_line == "-----BEGIN PKCS7-----":
return pkcs7.load_pem_pkcs7_certificates(bytes_input)[0]
Expand All @@ -24,6 +26,8 @@ def load_ascii_to_x509(bytes_input):

def load_der_to_x509(bytes_input):
# type: (bytes) -> x509.Certificate
""" Converts bytes formatted DER (PKCS7 or Cert) to :py:class:`cryptography.x509.Certificate` object
"""
try:
return x509.load_der_x509_certificate(bytes_input)
except ValueError:
Expand All @@ -32,6 +36,8 @@ def load_der_to_x509(bytes_input):

def load_bytes_to_x509(bytes_input):
# type: (bytes) -> x509.Certificate
""" Converts Certificate / PKCS7 in ASCII or DER to :py:class:`cryptography.x509.Certificate` object
"""
try:
return load_ascii_to_x509(bytes_input)
except UnicodeDecodeError:
Expand Down
9 changes: 5 additions & 4 deletions docs/conf.py
Expand Up @@ -16,8 +16,8 @@
sys.path.insert(0, os.path.abspath(".."))


import cert_chain_resolver
import sphinx_rtd_theme
import cert_chain_resolver # noqa: E402
import sphinx_rtd_theme # noqa: E402, F401


# -- Project information -----------------------------------------------------
Expand All @@ -42,7 +42,6 @@
"sphinx.ext.autodoc",
"sphinx.ext.viewcode",
"sphinx.ext.intersphinx",
"sphinx-autodoc-typehints",
]

# Add any paths that contain templates here, relative to this directory.
Expand Down Expand Up @@ -71,4 +70,6 @@
"cryptography": ("https://cryptography.io/en/latest", None),
}

always_document_param_types = True

# autodoc_typehints =
autodoc_typehints_format = 'short'
2 changes: 2 additions & 0 deletions requirements_docs.txt
@@ -0,0 +1,2 @@
sphinx
sphinx-rtd-theme

0 comments on commit ca1a6c4

Please sign in to comment.