Skip to content

Commit dfd668f

Browse files
committed
Merge branch 'ps/check-docs-fix'
"make check-docs" noticed problems and reported to its output but failed to signal its findings with its exit status, which has been corrected. * ps/check-docs-fix: ci/test-documentation: work around SyntaxWarning in Python 3.12 gitlab-ci: add job to run `make check-docs` Documentation/lint-manpages: bubble up errors Makefile: extract script to lint missing/extraneous manpages
2 parents 4551858 + f60fec6 commit dfd668f

File tree

5 files changed

+122
-36
lines changed

5 files changed

+122
-36
lines changed

.gitlab-ci.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,3 +122,12 @@ check-whitespace:
122122
- ./ci/check-whitespace.sh "$CI_MERGE_REQUEST_TARGET_BRANCH_SHA"
123123
rules:
124124
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
125+
126+
documentation:
127+
image: ubuntu:latest
128+
variables:
129+
jobname: Documentation
130+
before_script:
131+
- ./ci/install-dependencies.sh
132+
script:
133+
- ./ci/test-documentation.sh

Documentation/Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,12 +485,16 @@ $(LINT_DOCS_FSCK_MSGIDS): ../fsck.h fsck-msgids.txt
485485

486486
lint-docs-fsck-msgids: $(LINT_DOCS_FSCK_MSGIDS)
487487

488+
lint-docs-manpages:
489+
$(QUIET_GEN)./lint-manpages.sh
490+
488491
## Lint: list of targets above
489492
.PHONY: lint-docs
490493
lint-docs: lint-docs-fsck-msgids
491494
lint-docs: lint-docs-gitlink
492495
lint-docs: lint-docs-man-end-blurb
493496
lint-docs: lint-docs-man-section-order
497+
lint-docs: lint-docs-manpages
494498

495499
ifeq ($(wildcard po/Makefile),po/Makefile)
496500
doc-l10n install-l10n::

Documentation/lint-manpages.sh

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
#!/bin/sh
2+
3+
extract_variable () {
4+
(
5+
cat ../Makefile
6+
cat <<EOF
7+
print_variable:
8+
@\$(foreach b,\$($1),echo XXX \$(b:\$X=) YYY;)
9+
EOF
10+
) |
11+
make -C .. -f - print_variable 2>/dev/null |
12+
sed -n -e 's/.*XXX \(.*\) YYY.*/\1/p'
13+
}
14+
15+
check_missing_docs () (
16+
ret=0
17+
18+
for v in $ALL_COMMANDS
19+
do
20+
case "$v" in
21+
git-merge-octopus) continue;;
22+
git-merge-ours) continue;;
23+
git-merge-recursive) continue;;
24+
git-merge-resolve) continue;;
25+
git-merge-subtree) continue;;
26+
git-fsck-objects) continue;;
27+
git-init-db) continue;;
28+
git-remote-*) continue;;
29+
git-stage) continue;;
30+
git-legacy-*) continue;;
31+
git-?*--?* ) continue ;;
32+
esac
33+
34+
if ! test -f "$v.txt"
35+
then
36+
echo "no doc: $v"
37+
ret=1
38+
fi
39+
40+
if ! sed -e '1,/^### command list/d' -e '/^#/d' ../command-list.txt |
41+
grep -q "^$v[ ]"
42+
then
43+
case "$v" in
44+
git)
45+
;;
46+
*)
47+
echo "no link: $v"
48+
ret=1
49+
;;
50+
esac
51+
fi
52+
done
53+
54+
exit $ret
55+
)
56+
57+
check_extraneous_docs () {
58+
(
59+
sed -e '1,/^### command list/d' \
60+
-e '/^#/d' \
61+
-e '/guide$/d' \
62+
-e '/interfaces$/d' \
63+
-e 's/[ ].*//' \
64+
-e 's/^/listed /' ../command-list.txt
65+
make print-man1 |
66+
grep '\.txt$' |
67+
sed -e 's|^|documented |' \
68+
-e 's/\.txt//'
69+
) | (
70+
all_commands="$(printf "%s " "$ALL_COMMANDS" "$BUILT_INS" "$EXCLUDED_PROGRAMS" | tr '\n' ' ')"
71+
ret=0
72+
73+
while read how cmd
74+
do
75+
case " $all_commands " in
76+
*" $cmd "*) ;;
77+
*)
78+
echo "removed but $how: $cmd"
79+
ret=1;;
80+
esac
81+
done
82+
83+
exit $ret
84+
)
85+
}
86+
87+
BUILT_INS="$(extract_variable BUILT_INS)"
88+
ALL_COMMANDS="$(extract_variable ALL_COMMANDS)"
89+
EXCLUDED_PROGRAMS="$(extract_variable EXCLUDED_PROGRAMS)"
90+
91+
findings=$(
92+
if ! check_missing_docs
93+
then
94+
ret=1
95+
fi
96+
97+
if ! check_extraneous_docs
98+
then
99+
ret=1
100+
fi
101+
102+
exit $ret
103+
)
104+
ret=$?
105+
106+
printf "%s" "$findings" | sort
107+
108+
exit $ret

Makefile

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -3759,42 +3759,6 @@ ALL_COMMANDS += scalar
37593759
.PHONY: check-docs
37603760
check-docs::
37613761
$(MAKE) -C Documentation lint-docs
3762-
@(for v in $(patsubst %$X,%,$(ALL_COMMANDS)); \
3763-
do \
3764-
case "$$v" in \
3765-
git-merge-octopus | git-merge-ours | git-merge-recursive | \
3766-
git-merge-resolve | git-merge-subtree | \
3767-
git-fsck-objects | git-init-db | \
3768-
git-remote-* | git-stage | git-legacy-* | \
3769-
git-?*--?* ) continue ;; \
3770-
esac ; \
3771-
test -f "Documentation/$$v.txt" || \
3772-
echo "no doc: $$v"; \
3773-
sed -e '1,/^### command list/d' -e '/^#/d' command-list.txt | \
3774-
grep -q "^$$v[ ]" || \
3775-
case "$$v" in \
3776-
git) ;; \
3777-
*) echo "no link: $$v";; \
3778-
esac ; \
3779-
done; \
3780-
( \
3781-
sed -e '1,/^### command list/d' \
3782-
-e '/^#/d' \
3783-
-e '/guide$$/d' \
3784-
-e '/interfaces$$/d' \
3785-
-e 's/[ ].*//' \
3786-
-e 's/^/listed /' command-list.txt; \
3787-
$(MAKE) -C Documentation print-man1 | \
3788-
grep '\.txt$$' | \
3789-
sed -e 's|^|documented |' \
3790-
-e 's/\.txt//'; \
3791-
) | while read how cmd; \
3792-
do \
3793-
case " $(patsubst %$X,%,$(ALL_COMMANDS) $(BUILT_INS) $(EXCLUDED_PROGRAMS)) " in \
3794-
*" $$cmd "*) ;; \
3795-
*) echo "removed but $$how: $$cmd" ;; \
3796-
esac; \
3797-
done ) | sort
37983762

37993763
### Make sure built-ins do not have dups and listed in git.c
38003764
#

ci/test-documentation.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ filter_log () {
1111
-e '/^ \* new asciidoc flags$/d' \
1212
-e '/stripped namespace before processing/d' \
1313
-e '/Attributed.*IDs for element/d' \
14+
-e '/SyntaxWarning: invalid escape sequence/d' \
1415
"$1"
1516
}
1617

0 commit comments

Comments
 (0)