Skip to content

DOC: GL01 numpydoc validation #44567

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Nov 25, 2021
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ci/code_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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, SS03, SS04, SS05, PR03, PR04, PR05, PRO9, 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,SS03,SS04,SS05,PR03,PR04,PR05,PR09,PR10,EX04,RT01,RT04,RT05,SA02,SA03
MSG='Validate docstrings (GL01, GL02, GL03, GL04, GL05, GL06, GL07, GL09, GL10, SS01, SS02, SS03, SS04, SS05, PR03, PR04, PR05, PRO9, 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,SS03,SS04,SS05,PR03,PR04,PR05,PR09,PR10,EX04,RT01,RT04,RT05,SA02,SA03
RET=$(($RET + $?)) ; echo $MSG "DONE"

fi
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/window/doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
"""
Expand Down
18 changes: 12 additions & 6 deletions pandas/io/formats/style_render.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,23 @@ class CSSDict(TypedDict):
Subset = Union[slice, Sequence, Index]


def _gl01_adjust(obj: Any) -> Any:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

umm this seems kind of a hack, can we just adjust the templates?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are the docstrings of jinja2.PackageLoader and jinja2.Environment I believe, and their docstrings don't conform with GL01 cc @attack68

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thats right these are inherited docstring objects.

is there a way we can prevent the doc string validation is such cases? might be better than overwriting it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Looks like the validation script doesn't have any capabilities to ignore certain objects or methods; it looks to check everything in the public API.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok merging

but maybe would be good to enable some ignoring to prevent having to do this

"""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,
Expand Down