docs: one page for a coding assistant, and a copy-page control on every page - #20
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Three things, one docs change.
A "Copy page" control above every page. It copies the page as Markdown, or opens it in
ChatGPT / Claude / Perplexity. It works because
scripts/emit_markdown.pyruns after thebuild and writes every
docs/<path>.mdnext to the HTML it built, so each page has aplain-text twin one URL away:
/agents/and/agents.md,/guide/configuration/and/guide/configuration.md. The Docs workflow gains that one step.docs/agents.md— the whole library on one page, written for a coding assistant. Thepublic surface, the session-lifetime and transaction-ownership rules, the mistakes a model
actually makes with a Unit of Work, and a map of which page to fetch for the rest. Every
name on it is checked against
sqlalchemy_foundation_kit.__all__; the top-level table isexactly those 40 names, nothing invented and nothing left out. It is in the nav as "For AI
agents", right under Home, and linked from the README.
The API reference declines both the control and the twin (
copy_page: false): itsMarkdown is a list of instructions to mkdocstrings, not the API, so a model fetching
/reference.mdwould learn nothing.The rule that keeps it honest.
CONTRIBUTING.mdgains a section saying the page ispart of the public API and goes stale in the same pull request that changes it — a stale
one is worse than none, because it teaches a model an API that no longer exists. The pull
request checklist now names the file.
What the page reports that the code does, and the docs do not
Writing it against the source turned up five things worth their own issues. The page states
them because it has to be true; none of them are fixed here.
import sqlalchemy_foundation_kitfails on a clean install —session/connection.pyimports
asyncpgat module scope andasyncpgis not independencies.AsyncSessionManager.get_transaction()raisesTypeErroron every call, with orwithout an isolation level: it passes
execution_options=to the session factory, andSession.__init__has no such argument. The README, the index and the quick start allshow it as the primary write path.
uow.transaction(isolation_level=...),managed_session(...)andquery(...)raiseInvalidRequestError:apply_isolation_levelcallssession.connection(), whichautobegins, and then tries to set the level on a connection that already has a
transaction. Only engine-level
isolation_levelworks today.hash(), which is salted per process, so tworeplicas take different locks and both proceed.
guide/advanced.mdrecommends stringkeys for exactly the case this breaks.
contrib.diandcontrib.dependency_injectorfail on import without their extra with abare
AttributeErrorinstead of theImportErrorcheck_dishka()was written to give.How to see it
The Docs workflow deploys on merge; the control and the page are live at
https://bedrock-python.github.io/sqlalchemy-foundation-kit/agents/ once it does. Locally:
zensical serverebuilds into the same directory without the emit step, so a servedpreview answers 404 to the control — build the site to try it.
docs/assets/stylesheets/copy-page.css,docs/assets/javascripts/copy-page.js,overrides/main.htmlandscripts/emit_markdown.pyare byte-identical across theorganisation on purpose, so they can be updated in one sweep.
uv.lockis untouched.