help: change the "help" word-prop to store the actual documentation.
Change word-help to massage the $inputs and $outputs when requested. Revert the help.lint.coverage checks to still look for $values.master
parent
409ce057f3
commit
ad1e4dcd11
|
@ -9,8 +9,25 @@ IN: help
|
|||
|
||||
GENERIC: word-help* ( word -- content )
|
||||
|
||||
<PRIVATE
|
||||
|
||||
: inputs-and-outputs ( content word -- content' word )
|
||||
over [ dup array? [ { $values } head? ] [ drop f ] if ] find drop [
|
||||
'[ _ cut unclip rest ] dip [
|
||||
stack-effect [ in>> ] [ out>> ] bi
|
||||
[ [ dup pair? [ first ] when ] map ] bi@
|
||||
[ '[ ?first _ member? ] filter ] bi-curry@
|
||||
\ $inputs \ $outputs
|
||||
[ '[ @ _ prefix ] ] bi-curry@ bi* bi
|
||||
2array glue
|
||||
] keep
|
||||
] when* ;
|
||||
|
||||
PRIVATE>
|
||||
|
||||
: word-help ( word -- content )
|
||||
dup "help" word-prop [ ] [ word-help* ] ?if ;
|
||||
[ dup "help" word-prop [ ] [ word-help* ] ?if ]
|
||||
[ inputs-and-outputs drop ] bi ;
|
||||
|
||||
M: word word-help*
|
||||
stack-effect [ in>> ] [ out>> ] bi [
|
||||
|
@ -183,22 +200,5 @@ help-hook [ [ print-topic ] ] initialize
|
|||
: remove-word-help ( word -- )
|
||||
f "help" set-word-prop ;
|
||||
|
||||
<PRIVATE
|
||||
|
||||
: inputs-and-outputs ( content word -- content' word )
|
||||
over [ dup array? [ { $values } head? ] [ drop f ] if ] find drop [
|
||||
'[ _ cut unclip rest ] dip [
|
||||
stack-effect [ in>> ] [ out>> ] bi
|
||||
[ [ dup pair? [ first ] when ] map ] bi@
|
||||
[ '[ ?first _ member? ] filter ] bi-curry@
|
||||
\ $inputs \ $outputs
|
||||
[ '[ @ _ prefix ] ] bi-curry@ bi* bi
|
||||
2array glue
|
||||
] keep
|
||||
] when* ;
|
||||
|
||||
PRIVATE>
|
||||
|
||||
: set-word-help ( content word -- )
|
||||
inputs-and-outputs
|
||||
[ swap "help" set-word-prop ] keep xref-article ;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
USING: assocs classes combinators command-line continuations fry
|
||||
help help.lint.checks help.topics io kernel listener locals
|
||||
namespaces parser sequences source-files.errors system
|
||||
tools.errors vocabs vocabs.hierarchy ;
|
||||
tools.errors vocabs vocabs.hierarchy words ;
|
||||
IN: help.lint
|
||||
|
||||
SYMBOL: lint-failures
|
||||
|
@ -45,13 +45,15 @@ PRIVATE>
|
|||
|
||||
: check-word ( word -- )
|
||||
[ with-file-vocabs ] vocabs-quot set
|
||||
dup word-help [
|
||||
dup "help" word-prop [
|
||||
[ >link ] keep '[
|
||||
_ dup word-help {
|
||||
_ dup "help" word-prop {
|
||||
[ check-values ]
|
||||
[ check-value-effects ]
|
||||
[ check-class-description ]
|
||||
[ nip [ check-nulls ] [ check-see-also ] [ check-markup ] tri ]
|
||||
[ nip check-nulls ]
|
||||
[ nip check-see-also ]
|
||||
[ nip check-markup ]
|
||||
} 2cleave
|
||||
] check-something
|
||||
] [ drop ] if ;
|
||||
|
|
|
@ -118,12 +118,12 @@ M: word-help-coverage summary
|
|||
} cond ?remove-$values ;
|
||||
|
||||
: word-defines-sections ( word -- seq )
|
||||
word-help [ ignored-words member? not ] filter [ ?first ] map ;
|
||||
"help" word-prop [ ignored-words member? not ] filter [ ?first ] map ;
|
||||
|
||||
! only words that need examples, need to have them nonempty
|
||||
! not defining examples is not the same as an empty { $examples }
|
||||
: empty-examples? ( word -- ? )
|
||||
word-help \ $examples swap elements [ f ] [ first rest empty? ] if-empty ;
|
||||
"help" word-prop \ $examples swap elements [ f ] [ first rest empty? ] if-empty ;
|
||||
|
||||
: missing-sections ( word -- missing )
|
||||
[ should-define ] [ word-defines-sections ] bi diff ;
|
||||
|
|
Loading…
Reference in New Issue