OILS / doctools / search_index.ysh View on Github | oils.pub

30 lines, 19 significant
1#!bin/ysh
2
3# Driver for doctools/search_index.py
4#
5# To index all HTML files in _release/VERSION/doc:
6# $0 index
7
8proc index-all(...files;; baseDir) {
9 for file in (files) {
10 echo Indexing $file >&2
11 doctools/search_index.py --base-dir $baseDir $file
12 }
13}
14
15proc parse-jsonl(; place) {
16 var index = []
17 for line in (io.stdin) {
18 var parsed = fromJson(line)
19 call index->extend(parsed)
20 }
21
22 call place->setValue(index)
23}
24
25proc index() {
26 index-all _release/VERSION/doc/{*,ref/*}.html (baseDir='_release/VERSION') | parse-jsonl (&indices)
27 json write (indices) > _release/VERSION/index.json
28}
29
30runproc @ARGV