tools/docs/documentation-file-ref-check

Source file repositories/reference/linux-study-clean/tools/docs/documentation-file-ref-check

File Facts

System
Linux kernel
Corpus path
tools/docs/documentation-file-ref-check
Extension
[no extension]
Size
5841 bytes
Lines
246
Domain
Support Tooling And Documentation
Bucket
tools
Inferred role
Support Tooling And Documentation: tools
Status
atlas-only

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

if ($f =~ m/tools/) {
			my $path = $f;
			$path =~ s,(.*)/.*,$1,;
			$path =~ s,testing/selftests/bpf,bpf/bpftool,;
			next if (grep -e, glob("$path/$ref $path/../$ref $path/$fulref"));
		}

		# Discard known false-positives
		if (defined($false_positives{$f})) {
			next if ($false_positives{$f} eq $fulref);
		}

		if ($fix) {
			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";
		}
	}
}
close IN;

exit 0 if (!$fix);

# Step 2: Seek for file name alternatives
print "Auto-fixing broken references. Please double-check the results\n";

foreach my $ref (keys %broken_ref) {
	my $new =$ref;

	my $basedir = ".";
	# On translations, only seek inside the translations directory
	$basedir  = $1 if ($ref =~ m,(Documentation/translations/[^/]+),);

	# get just the basename
	$new =~ s,.*/,,;

	my $f="";

	# usual reason for breakage: DT file moved around
	if ($ref =~ /devicetree/) {
		# usual reason for breakage: DT file renamed to .yaml
		if (!$f) {
			my $new_ref = $ref;
			$new_ref =~ s/\.txt$/.yaml/;
			$f=$new_ref if (-f $new_ref);
		}

		if (!$f) {
			my $search = $new;
			$search =~ s,^.*/,,;
			$f = qx(find Documentation/devicetree/ -iname "*$search*") if ($search);
			if (!$f) {
				# Manufacturer name may have changed
				$search =~ s/^.*,//;
				$f = qx(find Documentation/devicetree/ -iname "*$search*") if ($search);
			}
		}
	}

	# usual reason for breakage: file renamed to .rst
	if (!$f) {
		$new =~ s/\.txt$/.rst/;
		$f=qx(find $basedir -iname $new) if ($new);
	}

	# usual reason for breakage: use dash or underline

Annotation

Implementation Notes