Skip to content

docs(readme): fix broken Quick Example and document ASGI#24

Open
LoboGuardian wants to merge 2 commits into
Az107:developfrom
LoboGuardian:docs/readme-accuracy-fixes
Open

docs(readme): fix broken Quick Example and document ASGI#24
LoboGuardian wants to merge 2 commits into
Az107:developfrom
LoboGuardian:docs/readme-accuracy-fixes

Conversation

@LoboGuardian

Copy link
Copy Markdown
Collaborator

What & why

While trying the framework, the README's headline Quick Example does not run:

  • It imports HTeaPot — the package exports htealeaf (an alias of the Server class); there is no HTeaPot symbol, so the import raises ImportError.
  • It ends with application = app.wsgi_app — no wsgi_app attribute exists anywhere in the source. The Server instance is itself the WSGI/ASGI callable and is passed directly to the server (as in demo/demo_wsgi.py).
  • It omits enable_reactivity(app), without which the reactive runtime (_engine/helper.js) is never injected and the counter's buttons don't wire up.

This is the first thing a new user copies, so it fails immediately.

Changes (README only)

  • Rewrite the Quick Example to mirror the working demo/demo_wsgi.py: htealeaf(adapters.WSGI), enable_reactivity(app), and passing app straight to make_server.
  • Pass an explicit Store(..., id="counter") and note why (stores without an explicit id currently share one id).
  • Add an ASGI section (adapters.ASGI + uvicorn) and mention the CGI adapter.
  • Add a Running the demo section and note the Python ≥ 3.10 requirement.
  • Move Installation above the example and link docs/PY2JS.md.

All snippets were checked against the exported API in src/HTeaLeaf/__init__.py and the demos. No code behavior is changed.

Note for maintainers

A couple of code-level issues make the counter only partially reactive today and are worth a follow-up (kept out of this doc PR): Store.react() builds its class name from the id builtin instead of the path argument, and Store.__init__(id=str(uuid4())) evaluates the default once at import so stores collide. Happy to open a separate PR for those.

The headline example imported `HTeaPot` and used `app.wsgi_app`, neither
of which exists — the package exports `htealeaf` (an alias of the Server
class) and the app object is itself the WSGI/ASGI callable, so the
snippet failed at import for every new user. It also omitted the
required `enable_reactivity(app)` call, without which the reactive
counter never wires up.

Rewrite the example to mirror demo/demo_wsgi.py (verified-runnable),
pass an explicit Store id to avoid instance collisions, add an ASGI
section and a "Running the demo" section, note the Python >=3.10
requirement, and link docs/PY2JS.md.
The develop branch renamed the package to lowercase htealeaf, exports
the app class as HteaLeaf (the htealeaf factory alias is gone), removed
enable_reactivity in favour of SuperStore(app) wiring, and dropped
Store.react() — stores are now read server-side with .read() and the
client re-renders via DOM reconciliation. Store ids are auto-generated
per instance since Az107#25, so the explicit id workaround is unnecessary.
Also marks async-first architecture done in the roadmap and notes the
session TTL work on feature/alb-28.
@LoboGuardian LoboGuardian changed the base branch from main to develop July 11, 2026 11:11
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.

1 participant