]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
Dropped "-> None" from function returning no result in docs
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Sun, 22 Nov 2020 16:13:31 +0000 (16:13 +0000)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Sun, 22 Nov 2020 16:13:31 +0000 (16:13 +0000)
docs/conf.py
docs/lib/pg3_docs.py [new file with mode: 0644]

index 772e2efeb337a38f57dd36207b545fe0511900ca..8228bc3b1d6f01eb1a193901fdf04e2680ba3367 100644 (file)
@@ -39,6 +39,7 @@ extensions = [
     "sphinx.ext.autodoc",
     "sphinx.ext.intersphinx",
     "sql_role",
+    "pg3_docs",
 ]
 
 # Add any paths that contain templates here, relative to this directory.
diff --git a/docs/lib/pg3_docs.py b/docs/lib/pg3_docs.py
new file mode 100644 (file)
index 0000000..cfb6d4f
--- /dev/null
@@ -0,0 +1,28 @@
+"""
+Customisation for docs generation.
+"""
+
+# Copyright (C) 2020 The Psycopg Team
+
+
+def process_docstring(app, what, name, obj, options, lines):
+    pass
+
+
+def before_process_signature(app, obj, bound_method):
+    # Drop "return: None" from the function signatures
+    ann = getattr(obj, "__annotations__", {})
+    if "return" in ann and ann["return"] is None:
+        del ann["return"]
+
+
+def process_signature(
+    app, what, name, obj, options, signature, return_annotation
+):
+    pass
+
+
+def setup(app):
+    app.connect("autodoc-process-docstring", process_docstring)
+    app.connect("autodoc-process-signature", process_signature)
+    app.connect("autodoc-before-process-signature", before_process_signature)