From c35eb9631347be2246023c72cc6cf11666e0ef54 Mon Sep 17 00:00:00 2001 From: Gabriel Erzse Date: Wed, 15 May 2024 16:50:11 +0300 Subject: [PATCH] Streamline documentation style (#3232) Adopt the Google docstrings style as the preferred way to document code. Update one of the existing docstrings to the new format, to showcase how it would look like. Enable the `napoleon` preprocessor in Sphinx, to be able to process Google style docstrings. Take the opportunity to make the copyright year dynamic, so we don't have to manually keep it up to date. --------- Co-authored-by: Gabriel Erzse --- .github/wordlist.txt | 2 + docs/conf.py | 12 +++-- redis/commands/core.py | 109 ++++++++++++++++++----------------------- 3 files changed, 60 insertions(+), 63 deletions(-) diff --git a/.github/wordlist.txt b/.github/wordlist.txt index 22ae767e46..540e915277 100644 --- a/.github/wordlist.txt +++ b/.github/wordlist.txt @@ -74,6 +74,8 @@ bysource charset del dev +docstring +docstrings eg exc firsttimersonly diff --git a/docs/conf.py b/docs/conf.py index a201da2fc0..33a8589654 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -10,6 +10,7 @@ # All configuration values have a default; values that are commented out # serve to show the default. +import datetime import os import sys @@ -30,12 +31,15 @@ "nbsphinx", "sphinx_gallery.load_style", "sphinx.ext.autodoc", - "sphinx_autodoc_typehints", - "sphinx.ext.doctest", "sphinx.ext.viewcode", "sphinx.ext.autosectionlabel", + "sphinx.ext.napoleon", ] +# Napoleon settings. We only accept Google-style docstrings. +napoleon_google_docstring = True +napoleon_numpy_docstring = False + # AutosectionLabel settings. # Uses a :