Skip to content

Commit

Permalink
update doc requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
mathiasertl committed Dec 28, 2023
1 parent a909be7 commit 82eab18
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 15 deletions.
30 changes: 21 additions & 9 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,23 +460,31 @@
}

qualname_overrides = {
"KeyUsages": "django_ca.typehints.KeyUsages",
"OtherNames": "django_ca.typehints.OtherNames",
"mappingproxy": "python:types.MappingProxyType",
"MappingProxyType": "python:types.MappingProxyType",
"cryptography.hazmat.bindings._rust.ObjectIdentifier": "cg:cryptography.x509.ObjectIdentifier",
"cryptography.x509.extensions.ExtendedKeyUsage": "cg:cryptography.x509.ExtendedKeyUsage",
"x509.GeneralName": "cg:cryptography.x509.GeneralName",
# x509.GeneralName fixes a build error with the typehints in constants.GENERAL_NAME_TYPES. The error seems
# to disappear once the typehint is unquoted, which is possible with Python 3.9. It's likely that this
# override can be removed once support for Python 3.8 is dropped.
"x509.GeneralName": "cg:cryptography.x509.GeneralName", # pragma: only py<3.9
# Django documents HttpRequest and HttpResponse under re-exported path names:
"django.http.request.HttpRequest": "django:django.http.HttpRequest",
"django.http.response.HttpResponse": "django:django.http.HttpResponse",
}

# Ignore (not so important) classes where the documented name does not match the documented name.
nitpick_ignore = [
# Django documents these under non-canonical path names
("py:class", "django.http.request.HttpRequest"),
("py:class", "django.http.response.HttpResponse"),
("py:class", "django_ca.typehints.OtherNames"),
("py:class", "django_ca.typehints.ExtensionTypeTypeVar"),
("py:class", "django_ca.typehints.KeyUsages"),
# When literals are used in typehints, Sphinx does not find the reference to the literal and errors with:
#
# docstring of django_ca.constants....:1:py:class reference target not found: <name-of-literal>
#
# Note that the above message does *not* contain the full class path, just the variable name and also
# claims a type of "class", when "attr" would be correct. The full path can be "fixed" with
# `qualname_overrides` above, but that does not fix the error. Setting "reftype" to "attr" in
# `resolve_canonical_names()` below also works, but you still get the same error.
("py:class", "OtherNames"),
("py:class", "KeyUsages"),
# asn1crypto is really used only for OtherNames, so we do not link it
("py:class", "asn1crypto.core.Primitive"),
# Pydantic root model signature does not currently work
Expand Down Expand Up @@ -512,6 +520,10 @@ def resolve_canonical_names(app: Sphinx, doctree: document) -> None:
alias = node.get("reftarget", None)

if alias is not None and alias in qualname_overrides:
# This does set the type to attr in the error message, but does not fix the build error with
# typehints described in nitpick_ignore either:
# if alias == "KeyUsages":
# node["reftype"] = "attr"
node["reftarget"] = qualname_overrides[alias]


Expand Down
2 changes: 1 addition & 1 deletion requirements/requirements-dev-common.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ GitPython==3.1.40
Jinja2==3.1.2
PyYAML==6.0.1
# Sphinx 7 requires Python>3.8, but we still support Python 3.8.
Sphinx<7
Sphinx==7.2.6
coverage[toml]==7.3.4
selenium==4.16.0
semantic-version==2.10.0
Expand Down
7 changes: 2 additions & 5 deletions requirements/requirements-docs.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
-r requirements-dev-common.txt
# doc8==1.0.0 and later requires docutils>19, but sphinx-rtd-theme==1.3.0
# requires docutils<19, changes in doc8 are minimal:
# https://github.com/readthedocs/sphinx_rtd_theme/issues/1323
doc8==0.11.2
doc8==1.1.1
numpydoc==1.6.0
# django-ninja==0.22.2 requires pydantic<2, but rstcheck requires pydantic>=2
# Enable once django-ninja~=1.0 is out
#rstcheck==6.2.0
sphinx-inline-tabs==2023.4.21
sphinx-jinja==2.0.2
sphinx_rtd_theme==1.3.0
sphinx-rtd-theme==2.0.0
sphinxcontrib-openapi==0.8.3
sphinxcontrib-spelling==8.0.0

0 comments on commit 82eab18

Please sign in to comment.