@@ -88,6 +88,7 @@ ALL_TXT_SRC = nut-names.txt daisychain.txt \
88
88
release-notes.txt ChangeLog.txt solaris-usb.txt
89
89
90
90
ASPELL_FILTER_PATH = @ASPELL_FILTER_PATH@
91
+ # NOTE: This can be set by caller such as nut-website builder:
91
92
NUT_SPELL_DICT = nut.dict
92
93
EXTRA_DIST += $(ALL_TXT_SRC ) $(SHARED_DEPS ) $(IMAGE_FILES ) \
93
94
$(IMAGE_LOGO_FILES ) $(IMAGE_LOGO_FILES_JENKINS_NUT ) $(CABLES_IMAGES ) $(NUT_SPELL_DICT ) \
@@ -145,6 +146,16 @@ all-docs: docs
145
146
146
147
check-docs : check-pdf check-html-single check-html-chunked check-man
147
148
149
+ # Not called by default, but handy for maintainers to check which words
150
+ # in the custom dictionary are used or not by the current NUT codebase.
151
+ # Note that historically many words were added to facilitate rendition
152
+ # of the nut-website (long ago splintered from main nut repository),
153
+ # but since recently it has a way to track its own additions to the
154
+ # dictionary file. This code should help populate it as well, and keep
155
+ # only relevant entries in the appropriate corner of the sources.
156
+ # Note this can take 5-10 minutes!
157
+ spellcheck-report-dict-usage : $(NUT_SPELL_DICT ) .usage-report
158
+
148
159
pdf : $(ASCIIDOC_PDF )
149
160
# also build the HTML manpages with these targets
150
161
html-single : $(ASCIIDOC_HTML_SINGLE )
@@ -611,6 +622,41 @@ spellcheck-interactive:
611
622
@echo " Documentation spell check not available since 'aspell' was not found (or missing its English dictionary)."
612
623
endif !HAVE_ASPELL
613
624
625
+ # Note that NUT_SPELL_DICT may be an include snippet without the header line.
626
+ # To exclude files like `docs/nut.dict` or `nut-website.dict(.addons)` from
627
+ # the usage lookups, we assume that a `*.dict*` pattern fits any used names.
628
+ # Entries prefixed with '+++' mean something used in NUT sources in context
629
+ # that aspell is likely to treat as a word (standalone or surrounded by certain
630
+ # chars); otherwise in entries prefixed with '---' we print hit counts and
631
+ # contents (if any, ending with '^^^') for the character pattern across the
632
+ # whole Git-tracked codebase (case-insensitively for good measure).
633
+ # Note this can take 5-10 minutes!
634
+ # TOTHINK: Constrain to (caller-specified or default) SPELLCHECK_SRC?
635
+ $(NUT_SPELL_DICT ) .usage-report : $(NUT_SPELL_DICT )
636
+ @echo " Preparing $@ " ; \
637
+ LANG=C; LC_ALL=C; export LANG; export LC_ALL; \
638
+ grep -v -E ' ^personal_ws' < $? \
639
+ | while read W ; do ( \
640
+ cd " $( abs_top_srcdir) " || exit ; \
641
+ git grep -q " $$ W" -- ' :!*.dict*' || git grep -qE " [0-9_,./\ -]$$ W[0-9_,./\ -]" -- ' :!*.dict*' ) \
642
+ && echo " +++ $$ W" \
643
+ || ( \
644
+ HITS_CS=" ` git grep " $$ W" -- ' :!*.dict*' ` " || true ; \
645
+ HITS_CI=" ` git grep -i " $$ W" -- ' :!*.dict*' ` " || true ; \
646
+ if [ -n " $$ HITS_CS" ] ; then HITC_CS=" ` echo " $$ HITS_CS" | wc -l` " ; else HITC_CS=0; fi ; \
647
+ if [ -n " $$ HITS_CI" ] ; then HITC_CI=" ` echo " $$ HITS_CI" | wc -l` " ; else HITC_CI=0; fi ; \
648
+ printf ' %s (%d case-sensitive/%d case-insensitive)\n' " --- $$ W" " $$ HITC_CS" " $$ HITC_CI" ; \
649
+ if [ " $$ HITC_CS" != 0 ] ; then echo " $$ HITS_CS" ; echo " ^^^" ; else \
650
+ if [ " $$ HITC_CI" != 0 ] ; then echo " $$ HITS_CI" ; echo " ^^^" ; fi ; \
651
+ fi ; \
652
+ ); \
653
+ done > " $@ .tmp"
654
+ test -f " $@ .tmp" && mv -f " $@ .tmp" " $@ "
655
+ @echo " Reporting words from $? possibly not used in current inspected code base revision under $( abs_top_srcdir) " >&2 ; \
656
+ grep -E ' ^--- ' < " $@ " | grep ' (0)' || echo " SUCCESS: None found"
657
+
658
+ CLEANFILES += $(NUT_SPELL_DICT ) .usage-report.tmp
659
+ MAINTAINERCLEANFILES += $(NUT_SPELL_DICT ) .usage-report
614
660
615
661
# When building out-of-tree, be sure to have all asciidoc resources
616
662
# under the same dir structure (tool limitation)
0 commit comments