From 6f8e2feacbce7d57667906a3e26ace15f7b1fce0 Mon Sep 17 00:00:00 2001 From: aleksslitvinovs-axonius Date: Thu, 16 Oct 2025 15:26:54 +0300 Subject: [PATCH 1/3] Add support for keyword args for Google flavor docs --- pdoc/docstrings.py | 4 ++- test/testdata/flavors_google.html | 58 +++++++++++++++++++++++++++++++ test/testdata/flavors_google.py | 12 +++++++ test/testdata/flavors_google.txt | 1 + 4 files changed, 74 insertions(+), 1 deletion(-) diff --git a/pdoc/docstrings.py b/pdoc/docstrings.py index 9cc062ce..9d45e209 100644 --- a/pdoc/docstrings.py +++ b/pdoc/docstrings.py @@ -104,13 +104,15 @@ def google(docstring: str) -> str: ) -GOOGLE_LIST_SECTIONS = ["Args", "Raises", "Attributes"] +GOOGLE_LIST_SECTIONS = ["Args", "Raises", "Attributes", "Keyword Args"] """Section headers listed in the official Google docstring style guide.""" GOOGLE_LIST_SECTION_ALIASES = { "Parameters": "Args", "Params": "Args", "Arguments": "Args", + "Raise": "Raises", + "Keyword Arguments": "Keyword Args", } """ Alternative section headers that are not listed in the official Google diff --git a/test/testdata/flavors_google.html b/test/testdata/flavors_google.html index c25b40de..105b808a 100644 --- a/test/testdata/flavors_google.html +++ b/test/testdata/flavors_google.html @@ -131,6 +131,9 @@

API Documentation

  • alternative_section_names
  • +
  • + keyword_arguments +
  • @@ -648,6 +651,18 @@
    Todo:
    453 Parameters: 454 test: the test string 455 """ +456 +457def keyword_arguments(**kwargs): +458 """ +459 This an example for a function with keyword arguments documented in the docstring. +460 +461 Args: +462 **kwargs: A dictionary containing user info. +463 +464 Keyword Arguments: +465 str_arg (str): First string argument. +466 int_arg (int): Second integer argument. +467 """ @@ -1944,6 +1959,49 @@
    Arguments:
    + +
    + +
    + + def + keyword_arguments(**kwargs): + + + +
    + +
    458def keyword_arguments(**kwargs):
    +459    """
    +460    This an example for a function with keyword arguments documented in the docstring.
    +461
    +462    Args:
    +463        **kwargs: A dictionary containing user info.
    +464
    +465    Keyword Arguments:
    +466        str_arg (str): First string argument.
    +467        int_arg (int): Second integer argument.
    +468    """
    +
    + + +

    This an example for a function with keyword arguments documented in the docstring.

    + +
    Arguments:
    + +
      +
    • **kwargs: A dictionary containing user info.
    • +
    + +
    Keyword Args:
    + +
      +
    • str_arg (str): First string argument.
    • +
    • int_arg (int): Second integer argument.
    • +
    +
    + +
    diff --git a/test/testdata/flavors_google.py b/test/testdata/flavors_google.py index f18e7bfb..122e634f 100644 --- a/test/testdata/flavors_google.py +++ b/test/testdata/flavors_google.py @@ -453,3 +453,15 @@ def alternative_section_names(test: str): Parameters: test: the test string """ + +def keyword_arguments(**kwargs): + """ + This an example for a function with keyword arguments documented in the docstring. + + Args: + **kwargs: A dictionary containing user info. + + Keyword Arguments: + str_arg (str): First string argument. + int_arg (int): Second integer argument. + """ diff --git a/test/testdata/flavors_google.txt b/test/testdata/flavors_google.txt index e801eb69..3a571907 100644 --- a/test/testdata/flavors_google.txt +++ b/test/testdata/flavors_google.txt @@ -44,4 +44,5 @@ + > \ No newline at end of file From fbc8fd5a86a9ef2631c9d7e6b1250d34c27ea599 Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Mon, 20 Oct 2025 13:38:10 +0200 Subject: [PATCH 2/3] add changelog entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8901f53f..7de0bde3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ ([#831](https://github.com/mitmproxy/pdoc/issues/831), @iFreilicht) - Replace vendored version of `markdown2` with the [official upstream](https://github.com/trentm/python-markdown2) +- Add support for keyword args for Google flavor docs. ## 2025-06-04: pdoc 15.0.4 From 259ee28b2819c0352e36edec4af058fb4cf851d9 Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Mon, 20 Oct 2025 11:38:49 +0000 Subject: [PATCH 3/3] [autofix.ci] apply automated fixes --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7de0bde3..eb8f7a3e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ - Replace vendored version of `markdown2` with the [official upstream](https://github.com/trentm/python-markdown2) - Add support for keyword args for Google flavor docs. + ([#840](https://github.com/mitmproxy/pdoc/pull/840), @aleksslitvinovs) ## 2025-06-04: pdoc 15.0.4