From: Daniele Varrazzo Date: Sun, 22 Nov 2020 16:13:31 +0000 (+0000) Subject: Dropped "-> None" from function returning no result in docs X-Git-Tag: 3.0.dev0~336 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5c994d9cd11dbc8a3313f81db187323d8ee8b481;p=thirdparty%2Fpsycopg.git Dropped "-> None" from function returning no result in docs --- diff --git a/docs/conf.py b/docs/conf.py index 772e2efeb..8228bc3b1 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -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 index 000000000..cfb6d4f8e --- /dev/null +++ b/docs/lib/pg3_docs.py @@ -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)