git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 07/12] Documentation: refactor "api-index.sh" for out-of-tree builds

From
Patrick Steinhardt <ps@pks.im>
Date
Dec 27, 2024, 13:59 UTC
Message-ID
<20241227-b4-pks-meson-docs-v2-7-f61e63edbfa1@pks.im>
In-Reply-To
<20241227-b4-pks-meson-docs-v2-0-f61e63edbfa1@pks.im>

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>
---
 Documentation/Makefile               |  2 +-
 Documentation/technical/api-index.sh | 19 +++++++++++++++----
 2 files changed, 16 insertions(+), 5 deletions(-)
diff --git a/Documentation/Makefile b/Documentation/Makefile
index 4f152077dded75bedd59abd56db5f6f0693908de..b2d146c44f4ded750b5e0766eb66b25cb5ec08e3 100644
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -367,7 +367,7 @@ user-manual.xml: user-manual.txt $(ASCIIDOC_DEPS)
 
 technical/api-index.txt: technical/api-index-skel.txt \
 	technical/api-index.sh $(patsubst %,%.txt,$(API_DOCS))
-	$(QUIET_GEN)cd technical && '$(SHELL_PATH_SQ)' ./api-index.sh
+	$(QUIET_GEN)'$(SHELL_PATH_SQ)' technical/api-index.sh ./technical ./technical/api-index.txt
 
 technical/%.html: ASCIIDOC_EXTRA += -a git-relative-html-prefix=../
 $(patsubst %,%.html,$(API_DOCS) technical/api-index $(TECH_DOCS)): %.html : %.txt \
diff --git a/Documentation/technical/api-index.sh b/Documentation/technical/api-index.sh
index 9c3f4131b8586408acd81d1e60912b51688575ed..296488557434b7fff60ab25f4246a4dc270729c0 100755
--- a/Documentation/technical/api-index.sh
+++ b/Documentation/technical/api-index.sh
@@ -1,6 +1,17 @@
 #!/bin/sh
 
+if test $# -ne 2
+then
+	echo >&2 "USAGE: $0 <SOURCE_DIR> <OUTPUT>"
+	exit 1
+fi
+
+SOURCE_DIR="$1"
+OUTPUT="$2"
+
 (
+	cd "$SOURCE_DIR"
+
 	c=////////////////////////////////////////////////////////////////
 	skel=api-index-skel.txt
 	sed -e '/^\/\/ table of contents begin/q' "$skel"
@@ -18,11 +29,11 @@
 	done
 	echo "$c"
 	sed -n -e '/^\/\/ table of contents end/,$p' "$skel"
-) >api-index.txt+
+) >"$OUTPUT"+
 
-if test -f api-index.txt && cmp api-index.txt api-index.txt+ >/dev/null
+if test -f "$OUTPUT" && cmp "$OUTPUT" "$OUTPUT"+ >/dev/null
 then
-	rm -f api-index.txt+
+	rm -f "$OUTPUT"+
 else
-	mv api-index.txt+ api-index.txt
+	mv "$OUTPUT"+ "$OUTPUT"
 fi
-- 
2.48.0.rc0.311.gb6c66824c1.dirty
Previous: Patrick SteinhardtNext: Patrick Steinhardt
Message 25 of 33 in “meson: wire up missing HTML documentation”
  1. 00/10 meson: wire up missing HTML documentationPatrick Steinhardt, Dec 13, 2024
  2. 01/10 meson: wire up support for AsciiDoctorPatrick Steinhardt, Dec 13, 2024
  3. 02/10 meson: properly wire up dependencies for our docsPatrick Steinhardt, Dec 13, 2024
  4. 03/10 meson: fix generation of merge toolsPatrick Steinhardt, Dec 13, 2024
  5. 04/10 meson: generate HTML pages for all man page categoriesPatrick Steinhardt, Dec 13, 2024
  6. Toon ClaesDec 23, 2024
  7. Patrick SteinhardtDec 27, 2024
  8. 06/10 meson: generate user manualPatrick Steinhardt, Dec 13, 2024
  9. 05/10 Documentation: inline user-manual.confPatrick Steinhardt, Dec 13, 2024
  10. 07/10 Documentation: refactor "api-index.sh" for out-of-tree buildsPatrick Steinhardt, Dec 13, 2024
  11. 09/10 meson: generate articlesPatrick Steinhardt, Dec 13, 2024
  12. 08/10 Documentation: refactor "howto-index.sh" for out-of-tree buildsPatrick Steinhardt, Dec 13, 2024
  13. 10/10 meson: install static files for HTML documentationPatrick Steinhardt, Dec 13, 2024
  14. Toon ClaesDec 23, 2024
  15. Patrick SteinhardtDec 27, 2024
  16. Toon ClaesJan 3, 2025
  17. Patrick SteinhardtJan 3, 2025
  18. 00/12 meson: wire up missing HTML documentationPatrick Steinhardt, Dec 27, 2024
  19. 01/12 meson: wire up support for AsciiDoctorPatrick Steinhardt, Dec 27, 2024
  20. 02/12 meson: properly wire up dependencies for our docsPatrick Steinhardt, Dec 27, 2024
  21. 03/12 meson: fix generation of merge toolsPatrick Steinhardt, Dec 27, 2024
  22. 04/12 meson: generate HTML pages for all man page categoriesPatrick Steinhardt, Dec 27, 2024
  23. 05/12 Documentation: inline user-manual.confPatrick Steinhardt, Dec 27, 2024
  24. 06/12 meson: generate user manualPatrick Steinhardt, Dec 27, 2024
  25. 07/12 Documentation: refactor "api-index.sh" for out-of-tree buildsPatrick Steinhardt, Dec 27, 2024
  26. 08/12 Documentation: refactor "howto-index.sh" for out-of-tree buildsPatrick Steinhardt, Dec 27, 2024
  27. 09/12 meson: generate articlesPatrick Steinhardt, Dec 27, 2024
  28. 10/12 meson: install static files for HTML documentationPatrick Steinhardt, Dec 27, 2024
  29. 11/12 t/Makefile: make "check-meson" work with DashPatrick Steinhardt, Dec 27, 2024
  30. Jonathan NiederJan 2, 2025
  31. Junio C HamanoJan 2, 2025
  32. Junio C HamanoJan 3, 2025
  33. 12/12 Documentation: wire up sanity checks for MesonPatrick Steinhardt, Dec 27, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.