factor/basis/help/lint/lint.factor

93 lines
2.3 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 continuations fry help help.lint.checks
help.topics io kernel namespaces parser sequences
source-files.errors tools.vocabs vocabs words classes
locals ;
2009-04-11 22:26:36 -04:00
FROM: help.lint.checks => all-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+
M: help-lint-error source-file-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 -- )
over [
[ <help-lint-error> ] keep
lint-failures get set-at
] [ nip lint-failures get delete-at ] if ;
<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 '[
2009-01-27 05:11:43 -05:00
_ dup word-help
[ check-values ]
[ check-class-description ]
[ nip [ check-nulls ] [ check-see-also ] [ check-markup ] tri ] 2tri
2007-12-11 22:36:40 -05:00
] check-something
] [ drop ] if ;
: check-words ( words -- ) [ check-word ] each ;
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 -- )
2009-01-27 05:11:43 -05:00
dup '[ _ vocab-help [ article drop ] when* ] check-something ;
2008-06-30 02:44:46 -04:00
: check-vocab ( vocab -- )
2008-02-26 21:20:30 -05:00
"Checking " write dup write "..." print
vocab
[ 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
[
all-vocabs-seq [ vocab-name ] map 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
2007-12-11 22:36:40 -05:00
: unlinked-words ( words -- seq )
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