diff --git a/README.md b/README.md index 75fab68..30d17d9 100644 --- a/README.md +++ b/README.md @@ -129,6 +129,8 @@ The following `config.toml` fields populate `` tags in `index.html` at bui `index.html` is rendered from [`python/contributor_network/templates/index.html.j2`](./python/contributor_network/templates/index.html.j2) by `contributor-network build` and is gitignored. To change page structure, edit the template (not the generated file). Forks can override the meta-tag values without modifying the template. +`contributor-network build` writes `index.html` and `public/data/` relative to the current working directory (pass `--directory ` to relocate the data files). This lets downstream consumers (e.g. site forks) install the package and run the build from any working tree. + ## Branding This visualization uses the Development Seed brand colors: diff --git a/python/contributor_network/cli.py b/python/contributor_network/cli.py index d6a9f00..ffa8f49 100644 --- a/python/contributor_network/cli.py +++ b/python/contributor_network/cli.py @@ -32,13 +32,12 @@ def render_index_html(config: Config) -> str: ) -ROOT = Path(__file__).absolute().parents[2] DEFAULT_CONFIG_PATH = "config.toml" directory = click.option( "--directory", type=click.Path(path_type=Path), - default=ROOT / "public" / "data", - help="The data directory", + default=Path("public") / "data", + help="The data directory (resolved against cwd if relative)", ) config = click.option( "-c", @@ -174,8 +173,9 @@ def build(directory: Path, config_path: str | None, all_contributors: bool) -> N ) print(f"Generated config.json in {directory}") - (ROOT / "index.html").write_text(render_index_html(config)) - print(f"Generated index.html at {ROOT / 'index.html'}") + index_html = Path("index.html") + index_html.write_text(render_index_html(config)) + print(f"Generated index.html at {index_html}") @main.command()