Add a simple script to locate areas of a DocBook file where
<indexterms> are sparse. Also add makefile glue so that this may be invoked on the Handbook or any other document in the FDP tree by typing "make indexcheck". Sponsored by: FreeBSD Mall, Inc.
This commit is contained in:
parent
34ccdb09ce
commit
8a01141e46
Notes:
svn2git
2020-12-08 03:00:23 +00:00
svn path=/head/; revision=16770
2 changed files with 48 additions and 0 deletions
42
share/misc/indexreport.pl
Normal file
42
share/misc/indexreport.pl
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
#!/usr/bin/perl
|
||||||
|
#
|
||||||
|
# Report on the sparsity of indexterms in specified DocBook SGML files.
|
||||||
|
#
|
||||||
|
# Usage : indexreport.pl <sgmlfiles> ...
|
||||||
|
#
|
||||||
|
# $FreeBSD$
|
||||||
|
#
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
|
||||||
|
# Number of lines in which we expect to see at least one indexterm.
|
||||||
|
my $threshold = 75;
|
||||||
|
|
||||||
|
foreach my $filename (@ARGV) {
|
||||||
|
print "Checking $filename...\n";
|
||||||
|
check_index($filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
# check_index(filename)
|
||||||
|
#
|
||||||
|
# Checks for indexterms in a given filename and prints a warning for
|
||||||
|
# sparse areas of the file that may not be fully indexed.
|
||||||
|
|
||||||
|
sub check_index($) {
|
||||||
|
my $filename = $_[0];
|
||||||
|
open(SGMLFILE, $filename) || die "Could not open $filename : $!";
|
||||||
|
my $linecnt = 0;
|
||||||
|
my $lastterm = 0;
|
||||||
|
|
||||||
|
foreach my $line (<SGMLFILE>) {
|
||||||
|
if ($line =~ /<indexterm>/) {
|
||||||
|
if (($linecnt - $lastterm) > $threshold) {
|
||||||
|
printf "%d lines with no indexterm starting at %s:%d\n",
|
||||||
|
$linecnt - $lastterm, $filename, $lastterm;
|
||||||
|
}
|
||||||
|
$lastterm = ++$linecnt;
|
||||||
|
} else {
|
||||||
|
$linecnt++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -143,6 +143,7 @@ XSLTPROC?= ${PREFIX}/bin/xsltproc
|
||||||
XSLHTML?= ${DOC_PREFIX}/share/xsl/freebsd-html.xsl
|
XSLHTML?= ${DOC_PREFIX}/share/xsl/freebsd-html.xsl
|
||||||
XSLHTMLCHUNK?= ${DOC_PREFIX}/share/xsl/freebsd-html-chunk.xsl
|
XSLHTMLCHUNK?= ${DOC_PREFIX}/share/xsl/freebsd-html-chunk.xsl
|
||||||
XSLFO?= ${DOC_PREFIX}/share/xsl/freebsd-fo.xsl
|
XSLFO?= ${DOC_PREFIX}/share/xsl/freebsd-fo.xsl
|
||||||
|
INDEXREPORTSCRIPT= ${DOC_PREFIX}/share/misc/indexreport.pl
|
||||||
|
|
||||||
IMAGES_LIB?=
|
IMAGES_LIB?=
|
||||||
|
|
||||||
|
@ -686,6 +687,11 @@ spellcheck:
|
||||||
@${HTML2TXT} ${HTML2TXTOPTS} ${.CURDIR}/${_entry} | ${ISPELL} ${ISPELLOPTS}
|
@${HTML2TXT} ${HTML2TXTOPTS} ${.CURDIR}/${_entry} | ${ISPELL} ${ISPELLOPTS}
|
||||||
.endfor
|
.endfor
|
||||||
|
|
||||||
|
indexreport:
|
||||||
|
.for _entry in ${SRCS:M*.sgml}
|
||||||
|
@echo "indexreport ${_entry}"
|
||||||
|
@${PERL} ${INDEXREPORTSCRIPT} ${.CURDIR}/${_entry}
|
||||||
|
.endfor
|
||||||
|
|
||||||
#
|
#
|
||||||
# Build a list of install-format targets to be installed. These will be
|
# Build a list of install-format targets to be installed. These will be
|
||||||
|
|
Loading…
Reference in a new issue