Documentation
On Klok, documentation follows the code. Every build on main describes the project it built, and the project's
documentation on docs.klok.dev is made from that description: the parts a build knows (routes, topics, datamodels,
configuration keys) are written by code, the explanations by Kloker, and the hand-written pages come from the project's
own klok-docs/ folder. Documentation is where a tenant decides what the platform generates for every project and
who reads each project's documentation, and where the REST API changes of its services are listed.
- In the menu: Run → Documentation, with the tabs Status (
/documentation/overview), Generation (/tenant-admin/documentation, where a Klok Framework Admin also gets the Projects tab) and Visibility (/tenant-admin/documentation/visibility, shown to admins) - For: developers and architects read; the Tenant Admin decides what is generated; the owners and admins of the tenant and of its domains decide who reads each project
- Reads: klok.dev's database (what repositories reported, and the REST API changes from the builds); the generation settings from tenant klok's ODL; who reads each project from its documentation project in GitLab
How A Project's Documentation Is Made
- Every build on
mainpublishes the project's documentation payload,KlokProjectDocumentationV1: the project'sklok-docs/pages, its README, the routes found in the code with their sources, the datamodels and the masked configuration keys. A Gradle project's jobklok_docs_publishdoes it with./gradlew publishKlokDocs; any other repository withklok docs send. - KlokDocumentationEgress (solution KLK007) reads the payload and writes the repository's documentation project under
klok/documentation/…: theklok-docs/pages as they are, a page per route and datamodel, the configuration keys, and the facts sections, all without a model. Kloker writes the AI sections through Klok AI, after the rest, including the regions a page marks withKLOK:GENERATED. - The documentation project's own pipeline publishes it to docs.klok.dev, for the readers its
klok-documentation-settings.jsonnames (Visibility, below). The same run writes the repository's agent skill into the tenant's catalog, without a model, which is what Kloker → Knowledge lists.
The documentation projects are output: KlokDocumentationEgress writes them again on every run, so their pages are never
edited by hand. Change the project's klok-docs/ in the same merge request as the code it describes, or the settings on
Generation. The one file people change in a documentation project is klok-documentation-settings.json, who reads
it, which the egress never touches. In GitLab, the generated documentation projects are reached only by the tenant's
owners and admins, KlokDocumentationEgress and klok.dev.
KlokDocumentationEgress reads tenant klok's topic and that of each tenant on its list, so the projects of a tenant that is not on the list get no generated documentation. A tenant on the list does not see the failures of its own payloads: they show for tenant klok's people, and what the tenant sees is that no documentation appears (Another tenant's documentation).
What You See
Status
Status lists the repositories whose pipeline has reported a build or a documentation publish to klok.dev, with their state, when they were last published and built, and Open docs, Pipeline and Regenerate on each row. Nothing reports to klok.dev yet (frontend-klok-dev#43), so the list says that no repository has reported; the documentation itself is published whether or not klok.dev hears about it.
API changes under the list works today: one row per change to the REST API of a service whose build sent an OpenAPI document, with the project and its version, Breaking when the change breaks callers, the commit and when. Open a row for what changed since the previous build, written by Kloker (or by rules when Kloker is not configured), and whether its documentation pages were published.
Generation
Generation decides what the platform generates for every project of the tenant: the languages, the model (Kloker-nothink in the standard), the system prompt, the image style of the project images and the order of the table of contents on Settings; the chapters and their sections on Chapters; and on Override, exactly what is stored. Every chapter and section says where it comes from: Klok standard, Overridden, Added or Disabled.
Visibility
Visibility lists the tenant's documentation projects that you may read or change: the doc id with its source repository (or guide for a hand-written one), its domain, Who reads it (default or set, and Shared with the other tenants that read it too) and the Last change of the setting with who made it. All domains narrows the list to one domain. Every project has one of five levels:
| Level | Who reads the documentation on docs.klok.dev |
|---|---|
| Public | everyone, without signing in |
| Global | everyone who signs in to Klok, in every tenant |
| Tenant | every member of the tenant |
| Members | the domain's members and the tenant's owners, admins and developers; for a project outside a business domain, the tenant's owners, admins and developers |
| Admins | the owners and admins of the domain and of the tenant; outside a business domain, the tenant's owners and admins |
The default follows the project's path: Public in a public group, Global in tenant klok's global group, Tenant
everywhere else. Documentation is open by default, so that what is built can be found and reused. An integration
project's and a datamodel's Overview shows the level of its documentation too, with Change for those who may
change it, and the row Shared with says which other tenants have the project, with Share with a tenant for the
tenant's owners and admins. Who Can Read Documentation says what
a share is.
Walkthrough: See What Is Written By Code And What By Kloker
-
Open Generation → Chapters and then a chapter, here Routes: one page per route, of the route legs chosen.
-
Read its sections in page order. Topics, datamodels and configuration is a FACTS section, rendered from the project without a model. Overview, Class structure, Mapping logic and Sequence diagram are AI sections, written by Kloker from the route's source and the prompt shown when you open the section. Improvements and suggestions ships disabled.
-
To change what is generated, edit a setting, a chapter or a section, or switch one off with Disable in its ⋮ menu, and choose Save. Only a Tenant Admin (or a Klok Framework Admin) saves; everyone else reads the page.
-
Override shows what Save stores: only the differences from the Klok standard. Everything you leave alone keeps following the standard, so an improved prompt in a new release reaches your projects.
A change takes effect from each project's next documentation run; saving regenerates nothing by itself. To refresh one
project now, retry its documentation job in GitLab (klok_docs_publish, or klok_docs_send). Regenerating a project
from klok.dev without running its whole pipeline is
frontend-klok-dev#70.
Walkthrough: Decide Who Reads A Project
-
Open Visibility and find the project; All domains narrows the list to one domain. From an integration project's or a datamodel's Overview, Change next to its documentation opens the same dialog.
-
Choose ⋮ → Change who reads it. The tenant's owners and admins may change every project of the tenant; a domain's owners and admins change their domain's projects, up to Global. Public is the tenant's owners' and admins' alone.
-
Choose the level, or The default to take the setting away again, and write Why. A level that hides the documentation from the rest of the tenant (Members, Admins) says so before you save.
-
Save. klok.dev commits
klok-documentation-settings.jsonat the documentation project's root, straight to its default branch, with your reason as the message body. docs.klok.dev shows the new level once the documentation project's pipeline has published it; until then it keeps the last one.
By hand: edit klok-documentation-settings.json in the documentation project in GitLab ({ "visibility": "global" },
or delete the file for the default), or run klok docs visibility <doc-id> --set <level> --reason <text>. klok.dev
reads the file from GitLab every time the list opens, so a change made by hand shows at once.
What Happens In Git
| In klok.dev | Where it lands | Who | By hand |
|---|---|---|---|
A build on main (not a klok.dev action) |
The payload on the broker; KLK007 commits the documentation project under klok/documentation/…, whose pipeline publishes it |
The pipeline, after a person merged the change | Retry klok_docs_publish or klok_docs_send in GitLab |
| Generation → Save | Nothing in Git: the tenant's override, dev.klok.klok.datamodel.common.klok_documentation_config_v1.KlokDocumentationConfigV1 with the tenant as its id, in tenant klok's ODL |
A Tenant Admin or Klok Framework Admin | PUT /api/odl/<that type>/<tenant> on tenant klok's ODL, with the realm role klok-odl-writer |
| Publish pages on an API change | The REST API page and the changelog committed to the documentation project under docs/generated/api/ |
Whoever may work on the repository | — |
| Regenerate on a Status row | A new pipeline on the repository's default branch | A role in the repository's domain, the tenant or the platform | Run the pipeline in GitLab |
| Visibility → Save | klok-documentation-settings.json at the root of the documentation project, committed straight to its default branch without a merge request, as chore(docs): set visibility of <doc-id> to <level> (or … back to the default, which deletes the file) or chore(docs): share <doc-id> with <tenant>, with the reason as the body and Changed-by: <username> |
The tenant's owners and admins; a domain's owners and admins for their domain's projects, up to Global, and not who it is shared with | Edit or delete the file in the documentation project, or klok docs visibility <doc-id> --set <level> --reason <text> (--share <tenant>) |
| Your own pages | klok-docs/ in the project, in the merge request of the change they describe |
The project's reviewers | The same, in GitLab or a clone |
See What klok.dev Does In Git for every page.
Who Does What
| Automation | Kloker | You |
|---|---|---|
Every build on main publishes the payload; KlokDocumentationEgress copies klok-docs/, renders the facts sections and the route, datamodel and REST API pages, creates a missing documentation project, and writes the agent skills, all without a model; the documentation project's pipeline publishes, with who reads it; klok.dev records the REST API changes |
Writes the AI sections (with Kloker-nothink in the standard), the description of each REST API change, and the motif of each project image, which Kloker Image draws | Write klok-docs/: why the project is built the way it is, and how each role uses it, in the same merge request as the code; as Tenant Admin, decide what is generated; as an owner or admin of the tenant or a domain, decide who reads each project |
See You, The Automation And Kloker.
How It Connects
The same payload that builds the documentation also fills the Context Graph: the Gradle job posts
it to klok.dev as well. The documentation is read on docs.klok.dev, its project image shows on the project's card under
Integration Projects, and the skills made from it are what agents know about the tenant
under Kloker → Knowledge (Kloker). The REST API changes come from the builds of services like
klok-api-ai and klok-api-odl.
Who reads a project's documentation also decides who sees its text inside klok.dev: the context graph, its search and Kloker leave out the documents of a Members or Admins project for whoever may not read it on docs.klok.dev, and a log analysis never takes them (Logs). The tenant's and domains' owners and admins who decide it are appointed under Tenant.
Read More
- klok.dev's reference: Home and documentation status, Documentation generation and Documentation projects
- Why the setting is a file in the documentation project: Documentation visibility is set in the documentation project
- KlokDocumentationEgress: klok-documentation-egress