From 72205cfb4fba955665f09ff6c1a0f68365f1c5fc Mon Sep 17 00:00:00 2001 From: aboydnw Date: Wed, 6 May 2026 18:50:03 +0000 Subject: [PATCH 1/3] feat: make `contributor-network build` output paths cwd-relative MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Removes the `__file__`-derived `ROOT` constant from the build command so the rendered `index.html` and the data directory are no longer pinned to the location of the installed package. Defaults are now relative to the current working directory: - `--directory` defaults to `public/data` (was `ROOT / "public" / "data"`) - new `--html-output` flag, defaults to `index.html` (was `ROOT / "index.html"`) Upstream behavior is unchanged when run from the repo root. Downstream consumers can now install the CLI as a package and run `build` from anywhere — useful for site forks that overlay their own config and let upstream render `index.html` into their working tree. Co-Authored-By: Claude Opus 4.7 (1M context) --- README.md | 2 ++ python/contributor_network/cli.py | 24 ++++++++++++++++++------ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 75fab68..6a6f074 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. +By default `contributor-network build` writes `index.html` and `public/data/` relative to the current working directory; pass `--html-output ` and `--directory ` to override. 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..b8269b7 100644 --- a/python/contributor_network/cli.py +++ b/python/contributor_network/cli.py @@ -32,13 +32,18 @@ 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 (relative paths are resolved against the current working directory)", +) +html_output = click.option( + "--html-output", + type=click.Path(path_type=Path), + default=Path("index.html"), + help="Where to write the rendered index.html (relative paths are resolved against the current working directory)", ) config = click.option( "-c", @@ -118,9 +123,15 @@ def fetch( @main.command() @directory +@html_output @config @all_contributors -def build(directory: Path, config_path: str | None, all_contributors: bool) -> None: +def build( + directory: Path, + html_output: Path, + config_path: str | None, + all_contributors: bool, +) -> None: """Generate CSVs and config.json for the contributor network site.""" config = Config.from_toml(config_path or DEFAULT_CONFIG_PATH) contributors = ( @@ -174,8 +185,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'}") + html_output.parent.mkdir(parents=True, exist_ok=True) + html_output.write_text(render_index_html(config)) + print(f"Generated index.html at {html_output}") @main.command() From 143684547a93c9a1ee046b466f48a690d71d13ef Mon Sep 17 00:00:00 2001 From: aboydnw Date: Wed, 6 May 2026 18:52:14 +0000 Subject: [PATCH 2/3] style: shorten Click help strings to satisfy ruff E501 Co-Authored-By: Claude Opus 4.7 (1M context) --- python/contributor_network/cli.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/contributor_network/cli.py b/python/contributor_network/cli.py index b8269b7..dc9196e 100644 --- a/python/contributor_network/cli.py +++ b/python/contributor_network/cli.py @@ -37,13 +37,13 @@ def render_index_html(config: Config) -> str: "--directory", type=click.Path(path_type=Path), default=Path("public") / "data", - help="The data directory (relative paths are resolved against the current working directory)", + help="The data directory (resolved against cwd if relative)", ) html_output = click.option( "--html-output", type=click.Path(path_type=Path), default=Path("index.html"), - help="Where to write the rendered index.html (relative paths are resolved against the current working directory)", + help="Where to write the rendered index.html (resolved against cwd if relative)", ) config = click.option( "-c", From 56c09cea04f03a28215501b8e01ff08f53318ef7 Mon Sep 17 00:00:00 2001 From: aboydnw Date: Wed, 6 May 2026 18:54:14 +0000 Subject: [PATCH 3/3] refactor: drop unused --html-output flag (cwd is sufficient) The cwd-relative default already lets downstream consumers control the output location by chdir'ing before calling build. The extra flag added API surface for a case nobody had. Co-Authored-By: Claude Opus 4.7 (1M context) --- README.md | 2 +- python/contributor_network/cli.py | 20 ++++---------------- 2 files changed, 5 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 6a6f074..30d17d9 100644 --- a/README.md +++ b/README.md @@ -129,7 +129,7 @@ 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. -By default `contributor-network build` writes `index.html` and `public/data/` relative to the current working directory; pass `--html-output ` and `--directory ` to override. This lets downstream consumers (e.g. site forks) install the package and run the build from any working tree. +`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 diff --git a/python/contributor_network/cli.py b/python/contributor_network/cli.py index dc9196e..ffa8f49 100644 --- a/python/contributor_network/cli.py +++ b/python/contributor_network/cli.py @@ -39,12 +39,6 @@ def render_index_html(config: Config) -> str: default=Path("public") / "data", help="The data directory (resolved against cwd if relative)", ) -html_output = click.option( - "--html-output", - type=click.Path(path_type=Path), - default=Path("index.html"), - help="Where to write the rendered index.html (resolved against cwd if relative)", -) config = click.option( "-c", "--config", @@ -123,15 +117,9 @@ def fetch( @main.command() @directory -@html_output @config @all_contributors -def build( - directory: Path, - html_output: Path, - config_path: str | None, - all_contributors: bool, -) -> None: +def build(directory: Path, config_path: str | None, all_contributors: bool) -> None: """Generate CSVs and config.json for the contributor network site.""" config = Config.from_toml(config_path or DEFAULT_CONFIG_PATH) contributors = ( @@ -185,9 +173,9 @@ def build( ) print(f"Generated config.json in {directory}") - html_output.parent.mkdir(parents=True, exist_ok=True) - html_output.write_text(render_index_html(config)) - print(f"Generated index.html at {html_output}") + index_html = Path("index.html") + index_html.write_text(render_index_html(config)) + print(f"Generated index.html at {index_html}") @main.command()