Git fork

Documentation: refactor "api-index.sh" for out-of-tree builds

The "api-index.sh" script generates an index of API-related
documentation. The script does not handle out-of-tree builds and thus
cannot be used easily by Meson.

Refactor it to be independent of locations by both accepting a source
directory where the API docs live as well as a path to an output file.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

authored by

Patrick Steinhardt and committed by
Junio C Hamano
88e08b92 ae0b3393

+16 -5
+1 -1
Documentation/Makefile
··· 367 367 368 368 technical/api-index.txt: technical/api-index-skel.txt \ 369 369 technical/api-index.sh $(patsubst %,%.txt,$(API_DOCS)) 370 - $(QUIET_GEN)cd technical && '$(SHELL_PATH_SQ)' ./api-index.sh 370 + $(QUIET_GEN)'$(SHELL_PATH_SQ)' technical/api-index.sh ./technical ./technical/api-index.txt 371 371 372 372 technical/%.html: ASCIIDOC_EXTRA += -a git-relative-html-prefix=../ 373 373 $(patsubst %,%.html,$(API_DOCS) technical/api-index $(TECH_DOCS)): %.html : %.txt \
+15 -4
Documentation/technical/api-index.sh
··· 1 1 #!/bin/sh 2 2 3 + if test $# -ne 2 4 + then 5 + echo >&2 "USAGE: $0 <SOURCE_DIR> <OUTPUT>" 6 + exit 1 7 + fi 8 + 9 + SOURCE_DIR="$1" 10 + OUTPUT="$2" 11 + 3 12 ( 13 + cd "$SOURCE_DIR" 14 + 4 15 c=//////////////////////////////////////////////////////////////// 5 16 skel=api-index-skel.txt 6 17 sed -e '/^\/\/ table of contents begin/q' "$skel" ··· 18 29 done 19 30 echo "$c" 20 31 sed -n -e '/^\/\/ table of contents end/,$p' "$skel" 21 - ) >api-index.txt+ 32 + ) >"$OUTPUT"+ 22 33 23 - if test -f api-index.txt && cmp api-index.txt api-index.txt+ >/dev/null 34 + if test -f "$OUTPUT" && cmp "$OUTPUT" "$OUTPUT"+ >/dev/null 24 35 then 25 - rm -f api-index.txt+ 36 + rm -f "$OUTPUT"+ 26 37 else 27 - mv api-index.txt+ api-index.txt 38 + mv "$OUTPUT"+ "$OUTPUT" 28 39 fi