1 ! Copyright (C) 2006, 2009 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: assocs continuations fry help help.lint.checks
4 help.topics io kernel namespaces parser sequences
5 source-files.errors vocabs.hierarchy vocabs words classes
6 locals tools.errors listener ;
7 FROM: help.lint.checks => all-vocabs ;
12 lint-failures [ H{ } clone ] initialize
14 TUPLE: help-lint-error < source-file-error ;
16 SYMBOL: +help-lint-failure+
19 { type +help-lint-failure+ }
20 { word ":lint-failures" }
21 { plural "help lint failures" }
22 { icon "vocab:ui/tools/error-list/icons/help-lint-error.tiff" }
23 { quot [ lint-failures get values ] }
24 { forget-quot [ lint-failures get delete-at ] }
27 M: help-lint-error error-type drop +help-lint-failure+ ;
31 : <help-lint-error> ( error topic -- help-lint-error )
32 \ help-lint-error <definition-error> ;
36 : help-lint-error ( error topic -- )
37 lint-failures get pick
38 [ [ [ <help-lint-error> ] keep ] dip set-at ] [ delete-at drop ] if
39 notify-error-observers ;
43 :: check-something ( topic quot -- )
44 [ quot call( -- ) f ] [ ] recover
45 topic help-lint-error ; inline
47 : check-word ( word -- )
48 [ with-file-vocabs ] vocabs-quot set
53 [ check-class-description ]
54 [ nip [ check-nulls ] [ check-see-also ] [ check-markup ] tri ] 2tri
58 : check-article ( article -- )
59 [ with-interactive-vocabs ] vocabs-quot set
62 [ check-article-title ]
63 [ article-content check-markup ] bi
66 : check-about ( vocab -- )
68 '[ _ vocab-help [ article drop ] when* ] check-something ;
70 : check-vocab ( vocab -- )
71 "Checking " write dup write "..." print
73 [ words [ check-word ] each ]
74 [ vocab-articles get at [ check-article ] each ]
79 : help-lint ( prefix -- )
81 all-vocabs-seq [ vocab-name ] map all-vocabs set
82 group-articles vocab-articles set
87 : help-lint-all ( -- ) "" help-lint ;
89 : :lint-failures ( -- ) lint-failures get values errors. ;
91 : unlinked-words ( words -- seq )
92 all-word-help [ article-parent not ] filter ;
94 : linked-undocumented-words ( -- seq )
96 [ word-help not ] filter
97 [ article-parent ] filter
98 [ predicate? not ] filter ;