Skip to content

Commit b1663d7

Browse files
mchehabJonathan Corbet
authored and
Jonathan Corbet
committed
docs: Kbuild/Makefile: allow check for missing docs at build time
While this doesn't make sense for production Kernels, in order to avoid regressions when documents are touched, let's add a check target at the make file. Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org> Signed-off-by: Jonathan Corbet <corbet@lwn.net>
1 parent 3f9564e commit b1663d7

File tree

4 files changed

+29
-0
lines changed

4 files changed

+29
-0
lines changed

Documentation/Kconfig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
config WARN_MISSING_DOCUMENTS
2+
3+
bool "Warn if there's a missing documentation file"
4+
depends on COMPILE_TEST
5+
help
6+
It is not uncommon that a document gets renamed.
7+
This option makes the Kernel to check for missing dependencies,
8+
warning when something is missing. Works only if the Kernel
9+
is built from a git tree.
10+
11+
If unsure, select 'N'.
12+
13+

Documentation/Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44

55
subdir-y := devicetree/bindings/
66

7+
# Check for broken documentation file references
8+
ifeq ($(CONFIG_WARN_MISSING_DOCUMENTS),y)
9+
$(shell $(srctree)/scripts/documentation-file-ref-check --warn)
10+
endif
11+
712
# You can set these variables from the command line.
813
SPHINXBUILD = sphinx-build
914
SPHINXOPTS =

Kconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,5 @@ source "crypto/Kconfig"
3030
source "lib/Kconfig"
3131

3232
source "lib/Kconfig.debug"
33+
34+
source "Documentation/Kconfig"

scripts/documentation-file-ref-check

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,16 @@ $scriptname =~ s,.*/([^/]+/),$1,;
2222
# Parse arguments
2323
my $help = 0;
2424
my $fix = 0;
25+
my $warn = 0;
26+
27+
if (! -d ".git") {
28+
printf "Warning: can't check if file exists, as this is not a git tree";
29+
exit 0;
30+
}
2531

2632
GetOptions(
2733
'fix' => \$fix,
34+
'warn' => \$warn,
2835
'h|help|usage' => \$help,
2936
);
3037

@@ -139,6 +146,8 @@ while (<IN>) {
139146
if (!($ref =~ m/(scripts|Kconfig|Kbuild)/)) {
140147
$broken_ref{$ref}++;
141148
}
149+
} elsif ($warn) {
150+
print STDERR "Warning: $f references a file that doesn't exist: $fulref\n";
142151
} else {
143152
print STDERR "$f: $fulref\n";
144153
}

0 commit comments

Comments
 (0)