]> gitweb.factorcode.org Git - factor.git/commitdiff
help: adding a default word help if not defined by HELP:.
authorJohn Benediktsson <mrjbq7@gmail.com>
Mon, 4 Apr 2016 22:31:53 +0000 (15:31 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Mon, 4 Apr 2016 22:31:53 +0000 (15:31 -0700)
basis/help/help.factor

index 17468ba0c39bc2ac79c0a74a28495f21a8f24e54..0b5669b26a7de0d0c14aced3eef90fafd73fbcca 100644 (file)
@@ -1,19 +1,17 @@
 ! Copyright (C) 2005, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors arrays assocs classes classes.error classes.tuple
-combinators combinators.short-circuit continuations debugger
-effects generic help.crossref help.markup help.stylesheet
-help.topics io io.styles kernel locals make namespaces prettyprint
-sequences sorting vocabs words words.symbol ;
+USING: accessors arrays assocs classes classes.error
+classes.tuple combinators combinators.short-circuit
+continuations debugger effects generic help.crossref help.markup
+help.stylesheet help.topics io io.styles kernel locals make
+namespaces prettyprint sequences sets sorting vocabs words
+words.symbol ;
 IN: help
 
 GENERIC: word-help* ( word -- content )
 
 : word-help ( word -- content )
-    dup "help" word-prop [ ] [
-        dup word-help* dup
-        [ swap 2array 1array ] [ 2drop f ] if
-    ] ?if ;
+    dup "help" word-prop [ ] [ word-help* ] ?if ;
 
 : $predicate ( element -- )
     { { "object" object } { "?" boolean } } $values
@@ -23,9 +21,20 @@ GENERIC: word-help* ( word -- content )
         " class." ,
     ] { } 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: class word-help* drop f ;
 
-M: predicate word-help* drop \ $predicate ;
+M: predicate word-help* \ $predicate prefix 1array ;
 
 : all-articles ( -- seq )
     articles get keys