factor/basis/help/lint/lint.factor

105 lines
2.7 KiB
Factor
Raw Normal View History

2009-01-27 05:27:22 -05:00
! Copyright (C) 2006, 2009 Slava Pestov.
2007-09-20 18:09:08 -04:00
! See http://factorcode.org/license.txt for BSD license.
USING: assocs combinators continuations fry help
help.lint.checks help.topics io kernel namespaces parser
sequences source-files.errors vocabs.hierarchy vocabs words
classes locals tools.errors listener ;
2009-04-11 22:26:36 -04:00
FROM: help.lint.checks => all-vocabs ;
FROM: vocabs => child-vocabs ;
2007-09-20 18:09:08 -04:00
IN: help.lint
SYMBOL: lint-failures
lint-failures [ H{ } clone ] initialize
TUPLE: help-lint-error < source-file-error ;
SYMBOL: +help-lint-failure+
T{ error-type
{ type +help-lint-failure+ }
{ word ":lint-failures" }
{ plural "help lint failures" }
{ icon "vocab:ui/tools/error-list/icons/help-lint-error.tiff" }
{ quot [ lint-failures get values ] }
{ forget-quot [ lint-failures get delete-at ] }
} define-error-type
M: help-lint-error error-type drop +help-lint-failure+ ;
<PRIVATE
: <help-lint-error> ( error topic -- help-lint-error )
\ help-lint-error <definition-error> ;
PRIVATE>
: help-lint-error ( error topic -- )
2009-04-13 15:40:03 -04:00
lint-failures get pick
[ [ [ <help-lint-error> ] keep ] dip set-at ] [ delete-at drop ] if
notify-error-observers ;
<PRIVATE
:: check-something ( topic quot -- )
[ quot call( -- ) f ] [ ] recover
topic help-lint-error ; inline
2007-09-20 18:09:08 -04:00
: check-word ( word -- )
2009-01-27 05:11:43 -05:00
[ with-file-vocabs ] vocabs-quot set
2007-12-11 22:36:40 -05:00
dup word-help [
2009-04-11 22:26:36 -04:00
[ >link ] keep '[
_ dup word-help {
[ check-values ]
[ check-value-effects ]
[ check-class-description ]
[ nip [ check-nulls ] [ check-see-also ] [ check-markup ] tri ]
} 2cleave
2007-12-11 22:36:40 -05:00
] check-something
] [ drop ] if ;
2007-09-20 18:09:08 -04:00
: check-article ( article -- )
2009-01-27 05:11:43 -05:00
[ with-interactive-vocabs ] vocabs-quot set
>link dup '[
2009-01-27 05:27:22 -05:00
_
[ check-article-title ]
[ article-content check-markup ] bi
] check-something ;
2007-09-20 18:09:08 -04:00
2008-06-30 02:44:46 -04:00
: check-about ( vocab -- )
vocab-link boa dup
'[ _ vocab-help [ lookup-article drop ] when* ] check-something ;
2008-06-30 02:44:46 -04:00
: check-vocab ( vocab -- )
2010-01-25 07:01:27 -05:00
"Checking " write dup write "..." print flush
[ check-about ]
[ words [ check-word ] each ]
[ vocab-articles get at [ check-article ] each ]
tri ;
2007-09-20 18:09:08 -04:00
PRIVATE>
: help-lint ( prefix -- )
2007-12-11 22:36:40 -05:00
[
2009-06-18 20:34:56 -04:00
auto-use? off
all-vocab-names all-vocabs set
group-articles vocab-articles set
2008-02-26 21:20:30 -05:00
child-vocabs
[ check-vocab ] each
2008-02-26 21:20:30 -05:00
] with-scope ;
: help-lint-all ( -- ) "" help-lint ;
2007-09-20 18:09:08 -04:00
2009-05-04 14:10:27 -04:00
: :lint-failures ( -- ) lint-failures get values errors. ;
: unlinked-words ( vocab -- seq )
words all-word-help [ article-parent not ] filter ;
2007-09-20 18:09:08 -04:00
: linked-undocumented-words ( -- seq )
all-words
[ word-help not ] filter
[ article-parent ] filter
[ predicate? not ] filter ;
2007-09-20 18:09:08 -04:00
2008-02-26 21:20:30 -05:00
MAIN: help-lint