]> gitweb.factorcode.org Git - factor.git/blobdiff - extra/annotations/annotations-docs.factor
factor: trim using lists
[factor.git] / extra / annotations / annotations-docs.factor
index c340554119e4020ccda9d349888cfd62e6b2ebbc..eee45528a3b8c703d0bec13b4b395a10cb7d6be0 100644 (file)
@@ -1,14 +1,48 @@
-USING: accessors arrays combinators definitions generalizations
-help help.markup help.topics kernel sequences sorting vocabs
-words ;
+USING: accessors arrays combinators combinators.smart help
+help.markup help.topics kernel sequences sorting tools.crossref
+vocabs words ;
 IN: annotations
 
 <PRIVATE
-: comment-word ( base -- word ) "!" prepend "annotations" lookup ; 
-: comment-usage-word ( base -- word ) "s" append "annotations" lookup ; 
-: comment-usage.-word ( base -- word ) "s." append "annotations" lookup ; 
+: comment-word ( base -- word ) "!" prepend "annotations" lookup-word ;
+: comment-usage-word ( base -- word ) "s" append "annotations" lookup-word ;
+: comment-usage.-word ( base -- word ) "s." append "annotations" lookup-word ;
 PRIVATE>
 
+: $annotation ( element -- )
+    first
+    [ "!" " your comment here" surround 1array $syntax ]
+    [ [ "Treats the rest of the line after the exclamation point as a code annotation that can be looked up with the " \ $link ] dip comment-usage.-word 2array " word." 3array $description ]
+    [ ": foo ( x y z -- w )\n    !" " --w-ó()ò-w-- kilroy was here\n    + * ;" surround 1array $code ]
+    tri ;
+
+: <$annotation> ( word -- element )
+    \ $annotation swap 2array 1array ;
+
+: $annotation-usage. ( element -- )
+    first
+    [ "Displays a list of words, help articles, and vocabularies that contain " \ $link ] dip comment-word 2array " annotations." 3array $description ;
+
+: <$annotation-usage.> ( word -- element )
+    \ $annotation-usage. swap 2array 1array ;
+
+: $annotation-usage ( element -- )
+    first [
+        [ "Returns a list of words, help articles, and vocabularies that contain " ] dip
+        [
+            comment-word <$link>
+            " annotations. For a more user-friendly display, use the "
+        ] [
+            comment-usage.-word <$link>
+            " word."
+        ] bi
+    ] output>array $description ;
+
+: <$annotation-usage> ( word -- element )
+    [ { $values { "usages" sequence } } ] dip
+    \ $annotation-usage swap 2array
+    2array ;
+
 "Code annotations"
 {
     "The " { $vocab-link "annotations" } " vocabulary provides syntax for comment-like annotations that can be looked up with Factor's " { $link usage } " mechanism."
@@ -22,21 +56,13 @@ annotation-tags natural-sort
 ] bi
 <article> "annotations" add-article
 
-"annotations" vocab "annotations" >>help drop
+"annotations" lookup-vocab "annotations" >>help drop
 
 annotation-tags [
     {
-        [ [ \ $syntax ] dip "!" " your comment here" surround 2array ]
-        [ [ \ $description "Treats the rest of the line after the exclamation point as a code annotation that can be looked up with the " \ $link ] dip comment-usage.-word 2array " word." 4array ]
-        [ [ \ $unchecked-example ] dip ": foo ( x y z -- w )\n    !" " --w-ó()ò-w-- kilroy was here\n    + * ;" surround 2array 3array ]
-        [ comment-word set-word-help ]
-
-        [ [ \ $description "Displays a list of words, help articles, and vocabularies that contain " \ $link ] dip comment-word 2array " annotations." 4array 1array ]
-        [ comment-usage.-word set-word-help ]
-
-        [ [ { $values { "usages" sequence } } \ $description "Returns a list of words, help articles, and vocabularies that contain " \ $link ] dip [ comment-word 2array " annotations. For a more user-friendly display, use the " \ $link ] [ comment-usage.-word 2array " word." 6 narray 2array ] bi ]
-        [ comment-usage-word set-word-help ]
-
+        [ [ <$annotation> ] [ comment-word set-word-help ] bi ]
+        [ [ <$annotation-usage> ] [ comment-usage-word set-word-help ] bi ]
+        [ [ <$annotation-usage.> ] [ comment-usage.-word set-word-help ] bi ]
         [ [ comment-word ] [ comment-usage-word ] [ comment-usage.-word ] tri 3array related-words ]
     } cleave
 ] each