From 36d3a197f753d149883b7c11758896bbe074c361 Mon Sep 17 00:00:00 2001 From: Matthew Roeschke Date: Fri, 19 Nov 2021 23:19:54 -0800 Subject: [PATCH] DOC: GL01 Numpydoc validation --- ci/code_checks.sh | 4 ++-- pandas/core/window/doc.py | 2 +- pandas/io/formats/style_render.py | 18 ++++++++++++------ 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/ci/code_checks.sh b/ci/code_checks.sh index ea9595fd88630..d89d308836eb3 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -93,8 +93,8 @@ fi ### DOCSTRINGS ### if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then - MSG='Validate docstrings (GL02, GL03, GL04, GL05, GL06, GL07, GL09, GL10, SS01, SS02, SS04, SS05, PR03, PR04, PR05, PR10, EX04, RT01, RT04, RT05, SA02, SA03)' ; echo $MSG - $BASE_DIR/scripts/validate_docstrings.py --format=actions --errors=GL02,GL03,GL04,GL05,GL06,GL07,GL09,GL10,SS02,SS04,SS05,PR03,PR04,PR05,PR10,EX04,RT01,RT04,RT05,SA02,SA03 + MSG='Validate docstrings (GL01, GL02, GL03, GL04, GL05, GL06, GL07, GL09, GL10, SS01, SS02, SS04, SS05, PR03, PR04, PR05, PR10, EX04, RT01, RT04, RT05, SA02, SA03)' ; echo $MSG + $BASE_DIR/scripts/validate_docstrings.py --format=actions --errors=GL01,GL02,GL03,GL04,GL05,GL06,GL07,GL09,GL10,SS02,SS04,SS05,PR03,PR04,PR05,PR10,EX04,RT01,RT04,RT05,SA02,SA03 RET=$(($RET + $?)) ; echo $MSG "DONE" fi diff --git a/pandas/core/window/doc.py b/pandas/core/window/doc.py index 2cc7962c6bd7b..61f388c35df0f 100644 --- a/pandas/core/window/doc.py +++ b/pandas/core/window/doc.py @@ -11,7 +11,7 @@ def create_section_header(header: str) -> str: return "\n".join((header, "-" * len(header))) + "\n" -template_header = "Calculate the {window_method} {aggregation_description}.\n\n" +template_header = "\nCalculate the {window_method} {aggregation_description}.\n\n" template_returns = dedent( """ diff --git a/pandas/io/formats/style_render.py b/pandas/io/formats/style_render.py index ae4e05160e70a..30b4ef82f23d2 100644 --- a/pandas/io/formats/style_render.py +++ b/pandas/io/formats/style_render.py @@ -57,17 +57,23 @@ class CSSDict(TypedDict): Subset = Union[slice, Sequence, Index] +def _gl01_adjust(obj: Any) -> Any: + """Adjust docstrings for Numpydoc GLO1.""" + obj.__doc__ = "\n" + obj.__doc__ + return obj + + class StylerRenderer: """ Base class to process rendering a Styler with a specified jinja2 template. """ - loader = jinja2.PackageLoader("pandas", "io/formats/templates") - env = jinja2.Environment(loader=loader, trim_blocks=True) - template_html = env.get_template("html.tpl") - template_html_table = env.get_template("html_table.tpl") - template_html_style = env.get_template("html_style.tpl") - template_latex = env.get_template("latex.tpl") + loader = _gl01_adjust(jinja2.PackageLoader("pandas", "io/formats/templates")) + env = _gl01_adjust(jinja2.Environment(loader=loader, trim_blocks=True)) + template_html = _gl01_adjust(env.get_template("html.tpl")) + template_html_table = _gl01_adjust(env.get_template("html_table.tpl")) + template_html_style = _gl01_adjust(env.get_template("html_style.tpl")) + template_latex = _gl01_adjust(env.get_template("latex.tpl")) def __init__( self,