| 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 |
|
| 8 | proc 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 |
|
| 15 | proc 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 |
|
| 25 | proc find-docs(; out) {
|
| 26 | ## Some docs have in_progress: yes, and thus should not be indexed.
|
| 27 | ##
|
| 28 | ## We check this, somewhat hackily, by the presence of the in-progress banner in
|
| 29 | ## the HTML files (as those are what we index, instead of the source markdown.)
|
| 30 |
|
| 31 | var docs = []
|
| 32 | for doc in _release/VERSION/doc/{*,ref/*}.html {
|
| 33 | if ! boolstatus grep 'Warning: Work in progress' $doc >/dev/null {
|
| 34 | call docs->append(doc)
|
| 35 | }
|
| 36 | }
|
| 37 |
|
| 38 | call out->setValue(docs)
|
| 39 | }
|
| 40 |
|
| 41 | proc index() {
|
| 42 | find-docs (&docs)
|
| 43 | index-all @docs (baseDir='_release/VERSION') | parse-jsonl (&indices)
|
| 44 | json write (indices) > _release/VERSION/index.json
|
| 45 | }
|
| 46 |
|
| 47 | runproc @ARGV
|