Skip to content

Commit

Permalink
fix dataset links in docs
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxHalford committed May 27, 2023
1 parent f1dff70 commit db64184
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 24 deletions.
37 changes: 15 additions & 22 deletions docs/parse/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,50 +483,43 @@ def print_module(mod, path, overview, depth=0, verbose=False):
classes = inspect.getmembers(mod, lambda x: inspect.isclass(x) and ispublic(x))
funcs = inspect.getmembers(mod, lambda x: inspect.isfunction(x) and ispublic(x))

# Classes

# Overview
if hasattr(mod, "_docs_overview"):
mod._docs_overview(functools.partial(print, file=overview))
else:
if classes and funcs:
print("\n**Classes**\n", file=overview)

for _, c in classes:
if verbose:
print(f"{mod_name}.{c.__name__}")

# Add the class to the overview
slug = snake_to_kebab(c.__name__)
print(
li(link(c.__name__, f"../{mod_short_path}/{slug}")),
end="",
file=overview,
)

# Write down the class' docstring
with open(mod_path.joinpath(slug).with_suffix(".md"), "w") as file:
print_docstring(obj=c, file=file)

# Functions

if classes and funcs:
print("\n**Functions**\n", file=overview)

for _, f in funcs:
if verbose:
print(f"{mod_name}.{f.__name__}")

# Add the function to the overview
slug = snake_to_kebab(f.__name__)
print(
li(link(f.__name__, f"../{mod_short_path}/{slug}")),
end="",
file=overview,
)

# Write down the function' docstring
with open(mod_path.joinpath(slug).with_suffix(".md"), "w") as file:
print_docstring(obj=f, file=file)
# Docstrings
for _, c in classes:
if verbose:
print(f"{mod_name}.{c.__name__}")
slug = snake_to_kebab(c.__name__)
with open(mod_path.joinpath(slug).with_suffix(".md"), "w") as file:
print_docstring(obj=c, file=file)

for _, f in funcs:
if verbose:
print(f"{mod_name}.{f.__name__}")
slug = snake_to_kebab(f.__name__)
with open(mod_path.joinpath(slug).with_suffix(".md"), "w") as file:
print_docstring(obj=f, file=file)

# Sub-modules
for name, submod in inspect.getmembers(mod, inspect.ismodule):
Expand Down
4 changes: 2 additions & 2 deletions river/datasets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ def _docs_overview(print):
dataset = eval(dataset_name)()

details = {
"Name": f"[{dataset_name}](/api/datasets/{dataset_name})",
"Name": f"[{dataset_name}](../datasets/{dataset_name})",
"Samples": dataset.n_samples,
"Features": dataset.n_features,
"Sparse": ":material-check:" if dataset.sparse else "",
"Sparse": "✔️" if dataset.sparse else "",
}

if dataset.task == base.REG:
Expand Down

0 comments on commit db64184

Please sign in to comment.