Skip to content

Commit 88e08b9

Browse files
pks-tgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ae0b339 commit 88e08b9

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

Documentation/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ user-manual.xml: user-manual.txt $(ASCIIDOC_DEPS)
367367

368368
technical/api-index.txt: technical/api-index-skel.txt \
369369
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
371371

372372
technical/%.html: ASCIIDOC_EXTRA += -a git-relative-html-prefix=../
373373
$(patsubst %,%.html,$(API_DOCS) technical/api-index $(TECH_DOCS)): %.html : %.txt \

Documentation/technical/api-index.sh

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
#!/bin/sh
22

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+
312
(
13+
cd "$SOURCE_DIR"
14+
415
c=////////////////////////////////////////////////////////////////
516
skel=api-index-skel.txt
617
sed -e '/^\/\/ table of contents begin/q' "$skel"
@@ -18,11 +29,11 @@
1829
done
1930
echo "$c"
2031
sed -n -e '/^\/\/ table of contents end/,$p' "$skel"
21-
) >api-index.txt+
32+
) >"$OUTPUT"+
2233

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
2435
then
25-
rm -f api-index.txt+
36+
rm -f "$OUTPUT"+
2637
else
27-
mv api-index.txt+ api-index.txt
38+
mv "$OUTPUT"+ "$OUTPUT"
2839
fi

0 commit comments

Comments
 (0)