Skip to content

Commit

Permalink
docs: Kbuild/Makefile: allow check for missing docs at build time
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Jonathan Corbet <[email protected]>
  • Loading branch information
mchehab authored and Jonathan Corbet committed Jun 7, 2019
1 parent 3f9564e commit b1663d7
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Documentation/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
config WARN_MISSING_DOCUMENTS

bool "Warn if there's a missing documentation file"
depends on COMPILE_TEST
help
It is not uncommon that a document gets renamed.
This option makes the Kernel to check for missing dependencies,
warning when something is missing. Works only if the Kernel
is built from a git tree.

If unsure, select 'N'.


5 changes: 5 additions & 0 deletions Documentation/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@

subdir-y := devicetree/bindings/

# Check for broken documentation file references
ifeq ($(CONFIG_WARN_MISSING_DOCUMENTS),y)
$(shell $(srctree)/scripts/documentation-file-ref-check --warn)
endif

# You can set these variables from the command line.
SPHINXBUILD = sphinx-build
SPHINXOPTS =
Expand Down
2 changes: 2 additions & 0 deletions Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,5 @@ source "crypto/Kconfig"
source "lib/Kconfig"

source "lib/Kconfig.debug"

source "Documentation/Kconfig"
9 changes: 9 additions & 0 deletions scripts/documentation-file-ref-check
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,16 @@ $scriptname =~ s,.*/([^/]+/),$1,;
# Parse arguments
my $help = 0;
my $fix = 0;
my $warn = 0;

if (! -d ".git") {
printf "Warning: can't check if file exists, as this is not a git tree";
exit 0;
}

GetOptions(
'fix' => \$fix,
'warn' => \$warn,
'h|help|usage' => \$help,
);

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

0 comments on commit b1663d7

Please sign in to comment.