Skip to content

Commit

Permalink
Documentation: wire up sanity checks for Meson
Browse files Browse the repository at this point in the history
Wire up sanity checks for Meson to verify that no man pages are missing.
This check is similar to the same check we already have for our tests.

Signed-off-by: Patrick Steinhardt <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
  • Loading branch information
pks-t authored and gitster committed Dec 27, 2024
1 parent d8af27d commit 5419445
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
1 change: 1 addition & 0 deletions Documentation/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ cmds-*.txt
mergetools-*.txt
SubmittingPatches.txt
tmp-doc-diff/
tmp-meson-diff/
GIT-ASCIIDOCFLAGS
/.build/
/GIT-EXCLUDED-PROGRAMS
Expand Down
16 changes: 16 additions & 0 deletions Documentation/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ clean:
$(RM) $(cmds_txt) $(mergetools_txt) *.made
$(RM) GIT-ASCIIDOCFLAGS
$(RM) asciidoc.conf asciidoctor-extensions.rb
$(RM) -rf tmp-meson-diff

docinfo.html: docinfo-html.in
$(QUIET_GEN)$(RM) $@ && cat $< >$@
Expand Down Expand Up @@ -494,13 +495,28 @@ lint-docs-fsck-msgids: $(LINT_DOCS_FSCK_MSGIDS)
lint-docs-manpages:
$(QUIET_GEN)./lint-manpages.sh

.PHONY: lint-docs-meson
lint-docs-meson:
@# awk acts up when trying to match single quotes, so we use \047 instead.
@mkdir -p tmp-meson-diff && \
awk "/^manpages = {$$/ {flag=1 ; next } /^}$$/ { flag=0 } flag { gsub(/^ \047/, \"\"); gsub(/\047 : [157],\$$/, \"\"); print }" meson.build | \
grep -v -e '#' -e '^$$' | \
sort >tmp-meson-diff/meson.txt && \
ls git*.txt scalar.txt | grep -v -e git-bisect-lk2009.txt -e git-tools.txt >tmp-meson-diff/actual.txt && \
if ! cmp tmp-meson-diff/meson.txt tmp-meson-diff/actual.txt; then \
echo "Meson man pages differ from actual man pages:"; \
diff -u tmp-meson-diff/meson.txt tmp-meson-diff/actual.txt; \
exit 1; \
fi

## Lint: list of targets above
.PHONY: lint-docs
lint-docs: lint-docs-fsck-msgids
lint-docs: lint-docs-gitlink
lint-docs: lint-docs-man-end-blurb
lint-docs: lint-docs-man-section-order
lint-docs: lint-docs-manpages
lint-docs: lint-docs-meson

ifeq ($(wildcard po/Makefile),po/Makefile)
doc-l10n install-l10n::
Expand Down
31 changes: 31 additions & 0 deletions Documentation/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -471,3 +471,34 @@ if get_option('docs').contains('html')
subdir('howto')
subdir('technical')
endif

# Sanity check that we are not missing any tests present in 't/'. This check
# only runs once at configure time and is thus best-effort, only. Furthermore,
# it only verifies man pages for the sake of simplicity.
configured_manpages = manpages.keys() + [ 'git-bisect-lk2009.txt', 'git-tools.txt' ]
actual_manpages = run_command(shell, '-c', 'ls git*.txt scalar.txt',
check: true,
env: script_environment,
).stdout().strip().split('\n')

if configured_manpages != actual_manpages
missing_manpage = [ ]
foreach actual_manpage : actual_manpages
if actual_manpage not in configured_manpages
missing_manpage += actual_manpage
endif
endforeach
if missing_manpage.length() > 0
error('Man page found, but not configured:\n\n - ' + '\n - '.join(missing_manpage))
endif

superfluous_manpage = [ ]
foreach configured_manpage : configured_manpages
if configured_manpage not in actual_manpages
superfluous_manpage += configured_manpage
endif
endforeach
if superfluous_manpage.length() > 0
error('Man page configured, but not found:\n\n - ' + '\n - '.join(superfluous_manpage))
endif
endif

0 comments on commit 5419445

Please sign in to comment.