wobblyhead hg > wobbly_ssg
diff doc/tools.md @ 0:71dd8d58a8e5 default tip
cleaned up re-init from net_wobblyhead_www project tooling
| author | ark |
|---|---|
| date | 2026-10-22 14:59 +0200 |
| parents | |
| children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/doc/tools.md Thu Oct 22 14:59:43 2026 +0200 @@ -0,0 +1,146 @@ +# Tools + +All tools work on the site in the current directory. Run them from the site +root, the directory with `config.txt`. Each tool prints its usage with `-h`. + +## make_site.py + +Builds the site. See [build.md](build.md) for what a build does. + + make_site.py [options] [path ...] + + path source files or directories to build. + default: all of src/ + -b, --build-dir DIR + build into DIR instead of build_dir from config.txt + -c, --clean empty the build directory first; implies --tags + -d, --draft also build unpublished pages + -q, --quiet print errors only + -r, --report print the summary + -t, --tags rebuild the tag index pages + -v, --verbose print errors, warnings and notices, and the summary + -h, --help + +`--quiet` and `--verbose` exclude each other. + +A path can be given relative to the current directory or to `src/`, and must +be below `src/`. `--clean` empties the whole build directory, whatever paths +are given. + +To build for publishing: + + make_site.py -c + +During writing, without `-c`, only changed pages are rebuilt. + +Requires Python 3.9 or later with python-markdown and Pillow. + +## make_dist.sh + +Packs the build directory into an archive for one target address. + + make_dist.sh [-m] <name> <url> + + -m, --make run make_site.py -c first + name symbolic name of the target, such as test or prod + url public address of the target + +The archive is written to `dist/` as `<build dir>-<name>-<version>.tar.gz`, +for example `dist/www-test-1.2.tar.gz`, and its path is printed. It holds the +build directory under its own name. The version comes from `get_version.sh +-f`. + +The pages contain absolute addresses built from `site_url`. When `url` is a +different address, the archive gets a copy of the build directory in which +`site_url` is replaced with `url` in every HTML file. The build directory is +not changed. + +## get_version.sh + +Prints the version of the site, from the Mercurial repository it is in. + + get_version.sh [-f] + + -f print a version even if the revision is not tagged or + the working directory has changes + +The version is the latest tag, if the working directory is at the tagged +revision or at the revision that added the tag, and has no changes. +Otherwise it is an error. With `-f` the script warns instead and prints the +latest tag with a timestamp appended, such as `1.2.20260301_1430`. + +## update_index.py + +Rewrites the entry lists of the index pages from the headers of the pages +they list. + + update_index.py [-n] + + -n, --dry-run print the changes as a diff, write nothing + +### Directory index pages + +Every `index.md` below `src/`, except the root one, lists the published pages +in its own directory. An entry is a link to a `.md` file with an optional +date, followed by a definition line with the `subtitle` of the page, or its +`description` if there is no subtitle: + + [First steps](first_steps.md) 01.03.2026 + : Notes from the first week + +The tool replaces the run of entries and keeps all text before and after it. +A link to anything other than a `.md` file, such as `[More](notes/)`, is not +an entry. +The first date in the existing entries decides which header is shown: + +- A full date, `dd.mm.yyyy`, shows `created_at`. +- Anything else shows `timeframe`. + +An index without any dated entry is skipped with a warning, because the tool +cannot tell which header to use. The first entry has to be written by hand. + +Entries are sorted newest first: by `created_at`, or by the start of +`timeframe` (`mm.yyyy` or `yyyy`), then by `updated_at`, then by file +modification time, and then by title. A page without a valid date goes last, +with a warning. + +### Root index page + +`src/index.md` gets one section per item of `index_sections` in +`config.txt`. Each section lists the newest entries of a directory, as many +as `index_recent` says. The links get the directory as a prefix. With + + index_sections: notes:Recent notes, models:Recent models + index_recent: 3 + +the section under the heading "Recent notes" lists the three newest entries +of `src/notes/index.md`. Headings match regardless of case and level. A +section runs from its heading to the next heading. The entries are replaced, +or inserted at the start of the section, and other text such as a "more" link +is kept. + +Without `index_sections` the root index is left alone. + +### Updated date + +A changed index gets today's date as `updated_at`. + +## update_updated.sh + +Sets the `updated_at` header of pages to the date of their last +modification. + + update_updated.sh [-n] [<filespec> ...] + + -n, --dry-run report only, change nothing + filespec files and directories to check, directories + recursively. default: src + +For each `.md` file, the tool compares `updated_at` with the date of the +file's modification time and prints each difference. Unless `-n` is given, +it sets `updated_at` to that date, as an ISO date such as `2026-03-01`. The +modification time is kept, so a second run finds nothing to change. + +A value with a time counts as different. A page without `updated_at` gets one +as its last header. A file without a `title` header is skipped with a warning. +Files that are not `.md` are ignored.
