Skip to content
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

docs: add missing methods in api reference #1144

162 changes: 142 additions & 20 deletions utils/check_api_reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,72 @@
print(extra) # noqa: T201
ret = 1

# Series.cat methods
Copy link
Member

@MarcoGorelli MarcoGorelli Oct 6, 2024

Choose a reason for hiding this comment

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

is it possible to loop over ['cat', 'dt', 'str', 'name'] for these? there's a lot of repetition currently

Copy link
Contributor Author

@AlessandroMiola AlessandroMiola Oct 6, 2024

Choose a reason for hiding this comment

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

Sure! If I'm not wrong, "name" isn't a real namespace for Series as it is for Expr, so I excluded it from the loop. lmk if that's ok or if I am missing something.

series_cat_methods = [
i
for i in nw.from_native(pl.Series(), series_only=True).cat.__dir__()
if not i[0].isupper() and i[0] != "_"
]
with open("docs/api-reference/series_cat.md") as fd:
content = fd.read()
documented = [
remove_prefix(i, " - ")
for i in content.splitlines()
if i.startswith(" - ") and not i.startswith(" - _")
]
if missing := set(series_cat_methods).difference(documented):
print("Series.cat: not documented") # noqa: T201
print(missing) # noqa: T201
ret = 1
if extra := set(documented).difference(series_cat_methods):
print("Series.cat: outdated") # noqa: T201
print(extra) # noqa: T201
ret = 1

# Series.dt methods
series_dt_methods = [
i
for i in nw.from_native(pl.Series(), series_only=True).dt.__dir__()
if not i[0].isupper() and i[0] != "_"
]
with open("docs/api-reference/series_dt.md") as fd:
content = fd.read()
documented = [
remove_prefix(i, " - ")
for i in content.splitlines()
if i.startswith(" - ") and not i.startswith(" - _")
]
if missing := set(series_dt_methods).difference(documented):
print("Series.dt: not documented") # noqa: T201
print(missing) # noqa: T201
ret = 1
if extra := set(documented).difference(series_dt_methods):
print("Series.dt: outdated") # noqa: T201
print(extra) # noqa: T201
ret = 1

# Series.str methods
series_str_methods = [
i
for i in nw.from_native(pl.Series(), series_only=True).str.__dir__()
if not i[0].isupper() and i[0] != "_"
]
with open("docs/api-reference/series_str.md") as fd:
content = fd.read()
documented = [
remove_prefix(i, " - ")
for i in content.splitlines()
if i.startswith(" - ") and not i.startswith(" - _")
]
if missing := set(series_str_methods).difference(documented):
print("Series.str: not documented") # noqa: T201
print(missing) # noqa: T201
ret = 1
if extra := set(documented).difference(series_str_methods):
print("Series.str: outdated") # noqa: T201
print(extra) # noqa: T201
ret = 1

# Expr methods
expr_methods = [
i for i in nw.Expr(lambda: 0).__dir__() if not i[0].isupper() and i[0] != "_"
Expand All @@ -141,47 +207,103 @@
print(extra) # noqa: T201
ret = 1

# DTypes
dtypes = [
i for i in nw.dtypes.__dir__() if i[0].isupper() and not i.isupper() and i[0] != "_"
# Expr.cat methods
expr_cat_methods = [
i for i in nw.Expr(lambda: 0).cat.__dir__() if not i[0].isupper() and i[0] != "_"
]
with open("docs/api-reference/dtypes.md") as fd:
with open("docs/api-reference/expr_cat.md") as fd:
content = fd.read()
documented = [
remove_prefix(i, " - ")
for i in content.splitlines()
if i.startswith(" - ") and not i.startswith(" - _")
if i.startswith(" - ")
]
if missing := set(dtypes).difference(documented).difference(BASE_DTYPES):
print("Dtype: not documented") # noqa: T201
if missing := set(expr_cat_methods).difference(documented):
print("Expr.cat: not documented") # noqa: T201
print(missing) # noqa: T201
ret = 1
if extra := set(documented).difference(expr_cat_methods):
print("Expr.cat: outdated") # noqa: T201
print(extra) # noqa: T201
ret = 1

# dt
# Expr.dt methods
expr_dt_methods = [
i for i in nw.Expr(lambda: 0).dt.__dir__() if not i[0].isupper() and i[0] != "_"
]
with open("docs/api-reference/expr_dt.md") as fd:
content = fd.read()
documented = [
remove_prefix(i, " - ")
for i in content.splitlines()
if i.startswith(" - ")
]
if missing := set(expr_dt_methods).difference(documented):
print("Expr.dt: not documented") # noqa: T201
print(missing) # noqa: T201
ret = 1
if extra := set(documented).difference(expr_dt_methods):
print("Expr.dt: outdated") # noqa: T201
print(extra) # noqa: T201
ret = 1

# Series.str methods
series_str_methods = [
i
for i in nw.from_native(pl.Series(), series_only=True).str.__dir__()
if not i[0].isupper() and i[0] != "_"
# Expr.name methods
expr_name_methods = [
i for i in nw.Expr(lambda: 0).name.__dir__() if not i[0].isupper() and i[0] != "_"
]
with open("docs/api-reference/expr_name.md") as fd:
content = fd.read()
documented = [
remove_prefix(i, " - ")
for i in content.splitlines()
if i.startswith(" - ")
]
if missing := set(expr_name_methods).difference(documented):
print("Expr.name: not documented") # noqa: T201
print(missing) # noqa: T201
ret = 1
if extra := set(documented).difference(expr_name_methods):
print("Expr.name: outdated") # noqa: T201
print(extra) # noqa: T201
ret = 1

with open("docs/api-reference/series_str.md") as fd:
# Expr.str methods
expr_str_methods = [
i for i in nw.Expr(lambda: 0).str.__dir__() if not i[0].isupper() and i[0] != "_"
]
with open("docs/api-reference/expr_str.md") as fd:
content = fd.read()
documented = [
remove_prefix(i, " - ")
for i in content.splitlines()
if i.startswith(" - ")
]
if missing := set(expr_str_methods).difference(documented):
print("Expr.str: not documented") # noqa: T201
print(missing) # noqa: T201
ret = 1
if extra := set(documented).difference(expr_str_methods):
print("Expr.str: outdated") # noqa: T201
print(extra) # noqa: T201
ret = 1

# DTypes
dtypes = [
i for i in nw.dtypes.__dir__() if i[0].isupper() and not i.isupper() and i[0] != "_"
]
with open("docs/api-reference/dtypes.md") as fd:
content = fd.read()
documented = [
remove_prefix(i, " - ")
for i in content.splitlines()
if i.startswith(" - ") and not i.startswith(" - _")
]

if missing := set(series_str_methods).difference(documented):
print("Series.str: not documented") # noqa: T201
if missing := set(dtypes).difference(documented).difference(BASE_DTYPES):
print("Dtype: not documented") # noqa: T201
print(missing) # noqa: T201
ret = 1

if extra := set(documented).difference(series_str_methods):
print("Series.str: outdated") # noqa: T201
if extra := set(documented).difference(dtypes):
print("Dtype: outdated") # noqa: T201
print(extra) # noqa: T201
ret = 1

Expand Down
Loading