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