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

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

# Series.{cat, dt, str} methods
for namespace in NAMESPACES.difference({"name"}):
series_methods = [
i
for i in getattr(
nw.from_native(pl.Series(), series_only=True), namespace
).__dir__()
if not i[0].isupper() and i[0] != "_"
]
with open(f"docs/api-reference/series_{namespace}.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_methods).difference(documented):
print(f"Series.{namespace}: not documented") # noqa: T201
print(missing) # noqa: T201
ret = 1
if extra := set(documented).difference(series_methods):
print(f"Series.{namespace}: 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,6 +166,29 @@
print(extra) # noqa: T201
ret = 1

# Expr.{cat, dt, name, str} methods
for namespace in NAMESPACES:
expr_methods = [
i
for i in getattr(nw.Expr(lambda: 0), namespace).__dir__()
if not i[0].isupper() and i[0] != "_"
]
with open(f"docs/api-reference/expr_{namespace}.md") as fd:
content = fd.read()
documented = [
remove_prefix(i, " - ")
for i in content.splitlines()
if i.startswith(" - ")
]
if missing := set(expr_methods).difference(documented):
print(f"Expr.{namespace}: not documented") # noqa: T201
print(missing) # noqa: T201
ret = 1
if extra := set(documented).difference(expr_methods):
print(f"Expr.{namespace}: 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] != "_"
Expand All @@ -156,32 +204,8 @@
print("Dtype: not documented") # noqa: T201
print(missing) # noqa: T201
ret = 1

# dt

# 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
if extra := set(documented).difference(dtypes):
print("Dtype: outdated") # noqa: T201
print(extra) # noqa: T201
ret = 1

Expand Down
Loading