-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.py
More file actions
79 lines (68 loc) · 2.58 KB
/
cli.py
File metadata and controls
79 lines (68 loc) · 2.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
"""Functions for the exposed CLI."""
from pathlib import Path
from typing import Any, Optional
from cyclopts import App, Parameter, config
# from seedcase_flower.config import Config as FlowerConfig
from seedcase_flower.internals import BuildStyle, _read_properties, _resolve_uri
app = App(
name="seedcase-flower",
help="Flower generates human-readable documentation from Data Packages.",
default_parameter=Parameter(negative=()),
config=[
config.Toml(
".flower.toml",
search_parents=True,
use_commands_as_keys=False,
),
config.Toml(
"pyproject.toml",
root_keys=["tool", "seedcase-flower"],
search_parents=True,
use_commands_as_keys=False,
),
],
)
@app.command()
def build(
uri: str = "datapackage.json",
style: BuildStyle = BuildStyle.quarto_one_page,
template_dir: Optional[Path] = None,
output_dir: Path = Path("docs"),
verbose: bool = False,
) -> None:
"""Build human-readable documentation from a `datapackage.json` file.
Args:
uri: The URI to a datapackage.json file.
style: The style used to structure the output. If a template directory
is given, this parameter will be ignored.
template_dir: The directory that contains the Jinja template
files and `sections.toml`. When set, it will override any
built-in style given by the `style` parameter.
output_dir: The directory to save the generated files in.
verbose: If True, prints additional information to the console.
"""
path: Path = _resolve_uri(uri)
properties: dict[str, Any] = _read_properties(path)
# One item per section, rendered from template.
# Internally uses Jinja2 to render templates with metadata, which
# are loaded within `build_sections()`. The Jinja2 templates and
# and the `sections.toml` file are loaded from the template directory,
# given by the `template_dir` arg or by the built-in styles (which points
# to a Flower internal template directory).
# config = FlowerConfig(
# style=style,
# template_dir=template_dir,
# output_dir=output_dir
# )
# output: list[BuiltSection] = build_sections(
# properties,
# config
# )
# output_files: list[Path] = write_sections(output, output_dir)
if verbose:
print(
output_dir, properties, template_dir, style
) # Placeholder for unused args
def view() -> str:
"""Display the contents of a `datapackage.json` in a human-friendly way."""
return ""