1 ! Copyright (C) 2006, 2009 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: assocs classes combinators command-line continuations
4 help help.lint.checks help.topics io kernel listener namespaces
5 parser sequences source-files.errors system tools.errors vocabs
6 vocabs.hierarchy vocabs.hierarchy.private vocabs.loader words ;
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.png" }
22 { quot [ lint-failures get values ] }
23 { forget-quot [ lint-failures get delete-at ] }
25 M: help-lint-error error-type drop +help-lint-failure+ ;
29 : <help-lint-error> ( error topic -- help-lint-error )
30 help-lint-error new-source-file-error ;
34 : notify-help-lint-error ( error topic -- )
35 lint-failures get pick
36 [ [ [ <help-lint-error> ] keep ] dip set-at ] [ delete-at drop ] if
37 notify-error-observers ;
41 :: check-something ( topic quot -- )
42 [ quot call( -- ) f ] [ ] recover
43 topic notify-help-lint-error ; inline
45 : check-word ( word -- )
46 [ with-file-vocabs ] vocabs-quot set
47 dup "help" word-prop [
49 _ dup "help" word-prop {
51 [ check-value-effects ]
52 [ check-class-description ]
54 [ nip check-see-also ]
60 : check-article ( article -- )
61 [ with-interactive-vocabs ] vocabs-quot set
64 [ check-article-title ]
65 [ article-content check-markup ] bi
68 : check-about ( vocab -- )
70 '[ _ vocab-help [ lookup-article drop ] when* ] check-something ;
72 : help-lint-vocab ( vocab -- )
73 "Checking " write dup vocab-name write "..." print flush
75 [ vocab-words [ check-word ] each ]
76 [ vocab-articles get at [ check-article ] each ]
79 : help-lint-vocabs ( vocabs -- )
82 group-articles vocab-articles set
83 [ help-lint-vocab ] each
88 : help-lint ( prefix -- )
89 loaded-child-vocab-names help-lint-vocabs ;
91 : help-lint-all ( -- ) "" help-lint ;
93 : :lint-failures ( -- ) lint-failures get values errors. ;
95 : unlinked-words ( vocab -- seq )
96 vocab-words all-word-help [ article-parent ] reject ;
98 : linked-undocumented-words ( -- seq )
101 [ article-parent ] filter
102 [ predicate? ] reject ;
104 : test-lint-main ( -- )
106 dup vocab-roots get member? [
107 "" vocabs-to-load [ require-all ] keep
109 [ load ] [ loaded-child-vocab-names ] bi
110 ] if help-lint-vocabs
112 lint-failures get assoc-empty?
113 [ [ "==== FAILING LINT" print :lint-failures flush ] unless ]