mirror of
https://github.com/johnkerl/miller.git
synced 2026-07-17 16:38:54 +00:00
* new troubleshooting-csv-and-json-input.md.in page * ../README-docs.md * ../README-docs.md
4.8 KiB
4.8 KiB
Miller docs
Why Mkdocs
- Connects to https://miller.readthedocs.io so people can get their docmods onto the web instead of the self-hosted https://johnkerl.org/miller/doc. Thanks to @pabloab for the great advice!
- More standard look and feel -- lots of people use readthedocs for other things so this should feel familiar.
- We get a Search feature for free.
- Mkdocs vs Sphinx: these are similar tools, but I find that I more easily get better desktop+mobile formatting using Mkdocs.
Setup
pip install mkdocs(orpip3 install mkdocs) as well aspip install mkdocs-material.- The docs include lots of live code examples which are invoked using
mlr, which must be somewhere in your$PATH. - Clone https://github.com/johnkerl/miller and cd into
docs/within your clone.
How the build works
docs/srchas*.md.infiles containing markdown as well as directives for auto-generating code samples. Edit these files, not*.mddirectly.- Within a
*.md.infile, lines likeGENMD_RUN_COMMANDmark a live code sample: the command gets run, and its output included, when the file is processed. - The
genmdsscript readsdocs/src/*.md.inand writesdocs/src/*.md. mkdocs buildreadsdocs/src/*.mdand writes HTML files indocs/site.- Running
makewithin thedocsdirectory handles both of those steps. - TL;DR: just
make docsfrom the Miller base directory.
Everyday editing loop
- In one terminal, cd to the
docsdirectory and leavemkdocs serverunning. - In another terminal, cd to the
docs/srcsubdirectory and edit*.md.in. - Run
genmdsto re-create all the*.mdfiles, orgenmds foo.md.into just re-create thefoo.md.infile you just edited, or (simplest) justmakewithin thedocs/srcsubdirectory. - In your browser, visit http://127.0.0.1:8000
- This doesn't write HTML in
docs/site; HTML is served up directly in the browser -- this is nice for previewing interactive edits.
Adding a new page
- Create
docs/src/foo.md.in. - Add a nav entry in
docs/mkdocs.ymlpointing atfoo.md-- the filename must match the basename of your new.md.inexactly, or the built page won't be linked into the site. - First-time gotcha:
docs/src/Makefile'sgenmdstarget only rebuilds files already listed in$(wildcard *.md). Sincefoo.mddoesn't exist yet, a plainmakewithindocs/srcwon't generate it. Two ways around this:- Simplest: just use
make docsfrom the Miller base directory (ormake -C docs/src forcebuild) -- these force-rungenmdson every*.md.inunconditionally, new or not. - Or, from
docs/src, run./genmds foo.md.indirectly, once, to create the initialfoo.md. After that it's picked up by ordinarymakeruns like any other page.
- Simplest: just use
- Don't work around this by pre-creating an empty
foo.mdyourself (e.g. viatouch): if its mtime ends up newer thanfoo.md.in, make's implicit%.md: %.md.inrule will see the target as up to date and skip regenerating it, silently leaving it empty. git addbothfoo.md.inand the generatedfoo.md.
Publishing build
- cd to the
srcsubdirectory ofdocsand edit*.md.in. make -C ..- This does write HTML in
docs/site. - In your browser, visit
file:///your/path/to/miller/docs/site/index.html - Link-checking:
sudo pip3 install git+https://github.com/linkchecker/linkchecker.gitcd siteandlinkchecker .
Submitting
- Do the publishing-build steps -- in particular,
docs/src/*.md.inanddocs/src/*.mdare both checked in to source control.- TL;DR: edit
docs/src/foo.md.inand runmake docs. - If you don't want to do
pip install mkdocsthen feel free to put up a PR which edits afoo.md.inas well as itsfoo.md.
- TL;DR: edit
git addyour modified files (*.md.inas well as*.md),git commit,git push, and submit a PR at https://github.com/johnkerl/miller.
Style notes
- Miller documents use the Oxford comma: not red, yellow and green, but rather red, yellow, and green.
- CSS: the Mkdocs "material" theme is used, customized via
docs/src/extra.cssfor Miller coloring/branding.
readthedocs
- Published to https://miller.readthedocs.io/en/latest on each commit to
mainin this repo. - https://readthedocs.org/
- https://readthedocs.org/projects/miller/
- https://readthedocs.org/projects/miller/builds/
- https://readthedocs.org/api/v2/webhook/miller/134065/