Skip to content

Fix CLI: package standalone.html, use directory= instead of os.chdir, add tests#22

Merged
pearsonkyle merged 2 commits intofeature/cli-tool-and-docsfrom
copilot/sub-pr-21
Mar 13, 2026
Merged

Fix CLI: package standalone.html, use directory= instead of os.chdir, add tests#22
pearsonkyle merged 2 commits intofeature/cli-tool-and-docsfrom
copilot/sub-pr-21

Conversation

Copy link
Contributor

Copilot AI commented Mar 13, 2026

The docbuddy CLI assumed a repo-style layout (docs/ adjacent to package root) that doesn't exist after pip install, and used os.chdir() to a broad parent directory instead of scoping the HTTP server to just the package assets.

Changes

  • New src/docbuddy/standalone.html: Packaged copy of docs/index.html with DOCBUDDY_LOCAL_BASE = './static' (sibling of the file in the installed package) instead of '../src/docbuddy/static' (repo layout only). Dynamic window.location.href replaces the hardcoded localhost:8008 URL.

  • cli.py rewrite:

    • Finds assets via files("docbuddy").joinpath("standalone.html") — works for both pip install and editable installs
    • Replaces os.chdir(docs_path.parent) with functools.partial(SimpleHTTPRequestHandler, directory=pkg_dir), scoping the server strictly to the package directory
    • Serves /standalone.html instead of /docs/index.html
    • Emits a clear error and exits cleanly when assets are missing
  • CLI tests (4 new): packaged file presence, static path correctness, error-exit on missing assets, directory= kwarg enforcement.

  • docs/index.html: Hardcoded URL replaced with "default port 8008" copy.

  • README: Updated URL reference to /standalone.html.


📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.

… add tests, fix hardcoded URLs

Co-authored-by: pearsonkyle <4556546+pearsonkyle@users.noreply.github.com>
Copilot AI changed the title [WIP] Add docbuddy command for local doc access Fix CLI: package standalone.html, use directory= instead of os.chdir, add tests Mar 13, 2026
Copilot AI requested a review from pearsonkyle March 13, 2026 05:29
@pearsonkyle pearsonkyle marked this pull request as ready for review March 13, 2026 05:30
@pearsonkyle pearsonkyle merged commit 7daf48c into feature/cli-tool-and-docs Mar 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants