|
0
|
1 # Tools
|
|
|
2
|
|
|
3 All tools work on the site in the current directory. Run them from the site
|
|
|
4 root, the directory with `config.txt`. Each tool prints its usage with `-h`.
|
|
|
5
|
|
|
6 ## make_site.py
|
|
|
7
|
|
|
8 Builds the site. See [build.md](build.md) for what a build does.
|
|
|
9
|
|
|
10 make_site.py [options] [path ...]
|
|
|
11
|
|
|
12 path source files or directories to build.
|
|
|
13 default: all of src/
|
|
|
14 -b, --build-dir DIR
|
|
|
15 build into DIR instead of build_dir from config.txt
|
|
|
16 -c, --clean empty the build directory first; implies --tags
|
|
|
17 -d, --draft also build unpublished pages
|
|
|
18 -q, --quiet print errors only
|
|
|
19 -r, --report print the summary
|
|
|
20 -t, --tags rebuild the tag index pages
|
|
|
21 -v, --verbose print errors, warnings and notices, and the summary
|
|
|
22 -h, --help
|
|
|
23
|
|
|
24 `--quiet` and `--verbose` exclude each other.
|
|
|
25
|
|
|
26 A path can be given relative to the current directory or to `src/`, and must
|
|
|
27 be below `src/`. `--clean` empties the whole build directory, whatever paths
|
|
|
28 are given.
|
|
|
29
|
|
|
30 To build for publishing:
|
|
|
31
|
|
|
32 make_site.py -c
|
|
|
33
|
|
|
34 During writing, without `-c`, only changed pages are rebuilt.
|
|
|
35
|
|
|
36 Requires Python 3.9 or later with python-markdown and Pillow.
|
|
|
37
|
|
|
38 ## make_dist.sh
|
|
|
39
|
|
|
40 Packs the build directory into an archive for one target address.
|
|
|
41
|
|
|
42 make_dist.sh [-m] <name> <url>
|
|
|
43
|
|
|
44 -m, --make run make_site.py -c first
|
|
|
45 name symbolic name of the target, such as test or prod
|
|
|
46 url public address of the target
|
|
|
47
|
|
|
48 The archive is written to `dist/` as `<build dir>-<name>-<version>.tar.gz`,
|
|
|
49 for example `dist/www-test-1.2.tar.gz`, and its path is printed. It holds the
|
|
|
50 build directory under its own name. The version comes from `get_version.sh
|
|
|
51 -f`.
|
|
|
52
|
|
|
53 The pages contain absolute addresses built from `site_url`. When `url` is a
|
|
|
54 different address, the archive gets a copy of the build directory in which
|
|
|
55 `site_url` is replaced with `url` in every HTML file. The build directory is
|
|
|
56 not changed.
|
|
|
57
|
|
|
58 ## get_version.sh
|
|
|
59
|
|
|
60 Prints the version of the site, from the Mercurial repository it is in.
|
|
|
61
|
|
|
62 get_version.sh [-f]
|
|
|
63
|
|
|
64 -f print a version even if the revision is not tagged or
|
|
|
65 the working directory has changes
|
|
|
66
|
|
|
67 The version is the latest tag, if the working directory is at the tagged
|
|
|
68 revision or at the revision that added the tag, and has no changes.
|
|
|
69 Otherwise it is an error. With `-f` the script warns instead and prints the
|
|
|
70 latest tag with a timestamp appended, such as `1.2.20260301_1430`.
|
|
|
71
|
|
|
72 ## update_index.py
|
|
|
73
|
|
|
74 Rewrites the entry lists of the index pages from the headers of the pages
|
|
|
75 they list.
|
|
|
76
|
|
|
77 update_index.py [-n]
|
|
|
78
|
|
|
79 -n, --dry-run print the changes as a diff, write nothing
|
|
|
80
|
|
|
81 ### Directory index pages
|
|
|
82
|
|
|
83 Every `index.md` below `src/`, except the root one, lists the published pages
|
|
|
84 in its own directory. An entry is a link to a `.md` file with an optional
|
|
|
85 date, followed by a definition line with the `subtitle` of the page, or its
|
|
|
86 `description` if there is no subtitle:
|
|
|
87
|
|
|
88 [First steps](first_steps.md) 01.03.2026
|
|
|
89 : Notes from the first week
|
|
|
90
|
|
|
91 The tool replaces the run of entries and keeps all text before and after it.
|
|
|
92 A link to anything other than a `.md` file, such as `[More](notes/)`, is not
|
|
|
93 an entry.
|
|
|
94 The first date in the existing entries decides which header is shown:
|
|
|
95
|
|
|
96 - A full date, `dd.mm.yyyy`, shows `created_at`.
|
|
|
97 - Anything else shows `timeframe`.
|
|
|
98
|
|
|
99 An index without any dated entry is skipped with a warning, because the tool
|
|
|
100 cannot tell which header to use. The first entry has to be written by hand.
|
|
|
101
|
|
|
102 Entries are sorted newest first: by `created_at`, or by the start of
|
|
|
103 `timeframe` (`mm.yyyy` or `yyyy`), then by `updated_at`, then by file
|
|
|
104 modification time, and then by title. A page without a valid date goes last,
|
|
|
105 with a warning.
|
|
|
106
|
|
|
107 ### Root index page
|
|
|
108
|
|
|
109 `src/index.md` gets one section per item of `index_sections` in
|
|
|
110 `config.txt`. Each section lists the newest entries of a directory, as many
|
|
|
111 as `index_recent` says. The links get the directory as a prefix. With
|
|
|
112
|
|
|
113 index_sections: notes:Recent notes, models:Recent models
|
|
|
114 index_recent: 3
|
|
|
115
|
|
|
116 the section under the heading "Recent notes" lists the three newest entries
|
|
|
117 of `src/notes/index.md`. Headings match regardless of case and level. A
|
|
|
118 section runs from its heading to the next heading. The entries are replaced,
|
|
|
119 or inserted at the start of the section, and other text such as a "more" link
|
|
|
120 is kept.
|
|
|
121
|
|
|
122 Without `index_sections` the root index is left alone.
|
|
|
123
|
|
|
124 ### Updated date
|
|
|
125
|
|
|
126 A changed index gets today's date as `updated_at`.
|
|
|
127
|
|
|
128 ## update_updated.sh
|
|
|
129
|
|
|
130 Sets the `updated_at` header of pages to the date of their last
|
|
|
131 modification.
|
|
|
132
|
|
|
133 update_updated.sh [-n] [<filespec> ...]
|
|
|
134
|
|
|
135 -n, --dry-run report only, change nothing
|
|
|
136 filespec files and directories to check, directories
|
|
|
137 recursively. default: src
|
|
|
138
|
|
|
139 For each `.md` file, the tool compares `updated_at` with the date of the
|
|
|
140 file's modification time and prints each difference. Unless `-n` is given,
|
|
|
141 it sets `updated_at` to that date, as an ISO date such as `2026-03-01`. The
|
|
|
142 modification time is kept, so a second run finds nothing to change.
|
|
|
143
|
|
|
144 A value with a time counts as different. A page without `updated_at` gets one
|
|
|
145 as its last header. A file without a `title` header is skipped with a warning.
|
|
|
146 Files that are not `.md` are ignored.
|