1 USING: accessors arrays combinators combinators.smart help
2 help.markup help.topics kernel sequences sorting tools.crossref
7 : comment-word ( base -- word ) "!" prepend "annotations" lookup-word ;
8 : comment-usage-word ( base -- word ) "s" append "annotations" lookup-word ;
9 : comment-usage.-word ( base -- word ) "s." append "annotations" lookup-word ;
12 : $annotation ( element -- )
14 [ "!" " your comment here" surround 1array $syntax ]
15 [ [ "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 ]
16 [ ": foo ( x y z -- w )\n !" " --w-ó()ò-w-- kilroy was here\n + * ;" surround 1array $code ]
19 : <$annotation> ( word -- element )
20 \ $annotation swap 2array 1array ;
22 : $annotation-usage. ( element -- )
24 [ "Displays a list of words, help articles, and vocabularies that contain " \ $link ] dip comment-word 2array " annotations." 3array $description ;
26 : <$annotation-usage.> ( word -- element )
27 \ $annotation-usage. swap 2array 1array ;
29 : $annotation-usage ( element -- )
31 [ "Returns a list of words, help articles, and vocabularies that contain " ] dip
34 " annotations. For a more user-friendly display, use the "
36 comment-usage.-word <$link>
39 ] output>array $description ;
41 : <$annotation-usage> ( word -- element )
42 [ { $values { "usages" sequence } } ] dip
43 \ $annotation-usage swap 2array
48 "The " { $vocab-link "annotations" } " vocabulary provides syntax for comment-like annotations that can be looked up with Factor's " { $link usage } " mechanism."
50 annotation-tags natural-sort
52 [ \ $subsection swap comment-word 2array ] map append
53 "To look up annotations:" suffix
55 [ \ $subsection swap comment-usage.-word 2array ] map append
57 <article> "annotations" add-article
59 "annotations" lookup-vocab "annotations" >>help drop
63 [ [ <$annotation> ] [ comment-word set-word-help ] bi ]
64 [ [ <$annotation-usage> ] [ comment-usage-word set-word-help ] bi ]
65 [ [ <$annotation-usage.> ] [ comment-usage.-word set-word-help ] bi ]
66 [ [ comment-word ] [ comment-usage-word ] [ comment-usage.-word ] tri 3array related-words ]