1 ! Copyright (C) 2006, 2009 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: assocs combinators continuations fry help
4 help.lint.checks help.topics io kernel namespaces parser
5 sequences source-files.errors vocabs.hierarchy vocabs words
6 classes locals tools.errors listener ;
11 lint-failures [ H{ } clone ] initialize
13 TUPLE: help-lint-error < source-file-error ;
15 SYMBOL: +help-lint-failure+
18 { type +help-lint-failure+ }
19 { word ":lint-failures" }
20 { plural "help lint failures" }
21 { icon "vocab:ui/tools/error-list/icons/help-lint-error.tiff" }
22 { quot [ lint-failures get values ] }
23 { forget-quot [ lint-failures get delete-at ] }
26 M: help-lint-error error-type drop +help-lint-failure+ ;
30 : <help-lint-error> ( error topic -- help-lint-error )
31 \ help-lint-error <definition-error> ;
35 : notify-help-lint-error ( error topic -- )
36 lint-failures get pick
37 [ [ [ <help-lint-error> ] keep ] dip set-at ] [ delete-at drop ] if
38 notify-error-observers ;
42 :: check-something ( topic quot -- )
43 [ quot call( -- ) f ] [ ] recover
44 topic notify-help-lint-error ; inline
46 : check-word ( word -- )
47 [ with-file-vocabs ] vocabs-quot set
52 [ check-value-effects ]
53 [ check-class-description ]
54 [ nip [ check-nulls ] [ check-see-also ] [ check-markup ] tri ]
59 : check-article ( article -- )
60 [ with-interactive-vocabs ] vocabs-quot set
63 [ check-article-title ]
64 [ article-content check-markup ] bi
67 : check-about ( vocab -- )
69 '[ _ vocab-help [ lookup-article drop ] when* ] check-something ;
71 : check-vocab ( vocab -- )
72 "Checking " write dup write "..." print flush
74 [ vocab-words [ check-word ] each ]
75 [ vocab-articles get at [ check-article ] each ]
80 : help-lint ( prefix -- )
83 all-disk-vocab-names all-vocabs-list set
84 group-articles vocab-articles set
85 loaded-child-vocab-names
89 : help-lint-all ( -- ) "" help-lint ;
91 : :lint-failures ( -- ) lint-failures get values errors. ;
93 : unlinked-words ( vocab -- seq )
94 vocab-words all-word-help [ article-parent ] reject ;
96 : linked-undocumented-words ( -- seq )
99 [ article-parent ] filter
100 [ predicate? ] reject ;