help: adding a default word help if not defined by HELP:.

locals-and-roots
John Benediktsson 2016-04-04 15:31:53 -07:00
parent 68bdd4196b
commit bdd4d49ac1
1 changed files with 20 additions and 11 deletions

View File

@ -1,19 +1,17 @@
! Copyright (C) 2005, 2010 Slava Pestov. ! Copyright (C) 2005, 2010 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: accessors arrays assocs classes classes.error classes.tuple USING: accessors arrays assocs classes classes.error
combinators combinators.short-circuit continuations debugger classes.tuple combinators combinators.short-circuit
effects generic help.crossref help.markup help.stylesheet continuations debugger effects generic help.crossref help.markup
help.topics io io.styles kernel locals make namespaces prettyprint help.stylesheet help.topics io io.styles kernel locals make
sequences sorting vocabs words words.symbol ; namespaces prettyprint sequences sets sorting vocabs words
words.symbol ;
IN: help IN: help
GENERIC: word-help* ( word -- content ) GENERIC: word-help* ( word -- content )
: word-help ( word -- content ) : word-help ( word -- content )
dup "help" word-prop [ ] [ dup "help" word-prop [ ] [ word-help* ] ?if ;
dup word-help* dup
[ swap 2array 1array ] [ 2drop f ] if
] ?if ;
: $predicate ( element -- ) : $predicate ( element -- )
{ { "object" object } { "?" boolean } } $values { { "object" object } { "?" boolean } } $values
@ -23,9 +21,20 @@ GENERIC: word-help* ( word -- content )
" class." , " class." ,
] { } make $description ; ] { } make $description ;
M: word word-help* drop f ; M: word word-help*
stack-effect [ in>> ] [ out>> ] bi [
[
dup pair? [
first2 dup effect? [ \ $quotation swap 2array ] when
] [
object
] if
] { } map>assoc
] bi@ append members \ $values prefix 1array ;
M: predicate word-help* drop \ $predicate ; M: class word-help* drop f ;
M: predicate word-help* \ $predicate prefix 1array ;
: all-articles ( -- seq ) : all-articles ( -- seq )
articles get keys articles get keys