Skip to content

Commit

Permalink
docs: add namespace methods in check_api_reference.py (#1144)
Browse files Browse the repository at this point in the history
* docs: add check on Series.dt methods being in api-reference

* docs: add check on Series.cat methods being in api-reference

* chore: remove extra blanks

* docs: add check on documented, yet no longer existent methods on dtype

* docs: add check on Expr.{cat, dt, name, str} methods being in api-reference

* chore: remove useless check and move checks on Series.{cat, dt, str} higher up

* docs: apply suggested changes
  • Loading branch information
AlessandroMiola authored Oct 7, 2024
1 parent f9a5c60 commit a2c1a10
Showing 1 changed file with 50 additions and 26 deletions.
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

0 comments on commit a2c1a10

Please sign in to comment.