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 ;
7 FROM: help.lint.checks => all-vocabs ;
8 FROM: vocabs => child-vocabs ;
13 lint-failures [ H{ } clone ] initialize
15 TUPLE: help-lint-error < source-file-error ;
17 SYMBOL: +help-lint-failure+
20 { type +help-lint-failure+ }
21 { word ":lint-failures" }
22 { plural "help lint failures" }
23 { icon "vocab:ui/tools/error-list/icons/help-lint-error.tiff" }
24 { quot [ lint-failures get values ] }
25 { forget-quot [ lint-failures get delete-at ] }
28 M: help-lint-error error-type drop +help-lint-failure+ ;
32 : <help-lint-error> ( error topic -- help-lint-error )
33 \ help-lint-error <definition-error> ;
37 : notify-help-lint-error ( error topic -- )
38 lint-failures get pick
39 [ [ [ <help-lint-error> ] keep ] dip set-at ] [ delete-at drop ] if
40 notify-error-observers ;
44 :: check-something ( topic quot -- )
45 [ quot call( -- ) f ] [ ] recover
46 topic notify-help-lint-error ; inline
48 : check-word ( word -- )
49 [ with-file-vocabs ] vocabs-quot set
54 [ check-value-effects ]
55 [ check-class-description ]
57 [ nip [ check-nulls ] [ check-see-also ] [ check-markup ] tri ]
62 : check-article ( article -- )
63 [ with-interactive-vocabs ] vocabs-quot set
66 [ check-article-title ]
67 [ article-content check-markup ] bi
70 : check-about ( vocab -- )
72 '[ _ vocab-help [ lookup-article drop ] when* ] check-something ;
74 : check-vocab ( vocab -- )
75 "Checking " write dup write "..." print flush
77 [ words [ check-word ] each ]
78 [ vocab-articles get at [ check-article ] each ]
83 : help-lint ( prefix -- )
86 all-vocab-names all-vocabs set
87 group-articles vocab-articles set
92 : help-lint-all ( -- ) "" help-lint ;
94 : :lint-failures ( -- ) lint-failures get values errors. ;
96 : unlinked-words ( vocab -- seq )
97 words all-word-help [ article-parent not ] filter ;
99 : linked-undocumented-words ( -- seq )
101 [ word-help not ] filter
102 [ article-parent ] filter
103 [ predicate? not ] filter ;