Docs while you work
kscript serve --with-docs also serves these docs on localhost, next to the site, with a page about your project at /project:
| Command | What it does |
|---|---|
kscript serve --with-docs | The site, and the docs with a page about your project. |
The project page is built from the project itself, and is rebuilt when a script changes. It shows how code is written here (the project's format, standard, layout and lint rules, the packages every script gets, and the folders kscript make puts files in), the routes kscript routes lists, and every function, type and constant each script declares at its top level, with its /// doc comment. Search finds them too.
The docs listen on localhost only, even when the site is served with --host 0.0.0.0, because their examples run code. --docs-port 4190 picks their port (4180, or a free one, otherwise). To have them every time, set "docs": true in the serve section of kscript.json, and "docs_port" to pick the port. --no-docs turns them off for one run. Compiled programs never serve the docs, and neither does kscript serve in the production environment.
For the same docs as a file, run kscript docs --project. It writes .kscript/docs/project.md, Markdown that reads well in an editor, on GitHub or in a code review. From then on, kscript watch, kscript serve and saving a script in the editor keep it up to date. Delete .kscript/docs to stop.