]> gitweb.factorcode.org Git - factor.git/blob - extra/annotations/annotations-docs.factor
Merge branch 'emacs' of http://git.hacks-galore.org/jao/factor
[factor.git] / extra / annotations / annotations-docs.factor
1 USING: accessors arrays combinators definitions generalizations
2 help help.markup help.topics kernel sequences sorting vocabs
3 words ;
4 IN: annotations
5
6 <PRIVATE
7 : comment-word ( base -- word ) "!" prepend "annotations" lookup ; 
8 : comment-usage-word ( base -- word ) "s" append "annotations" lookup ; 
9 : comment-usage.-word ( base -- word ) "s." append "annotations" lookup ; 
10 PRIVATE>
11
12 : $annotation ( element -- )
13     first
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 $unchecked-example ]
17     tri ;
18
19 : $annotation-usage. ( element -- )
20     first
21     [ "Displays a list of words, help articles, and vocabularies that contain " \ $link ] dip comment-word 2array " annotations." 3array $description ;
22
23 : $annotation-usage ( element -- )
24     first
25     { "usages" sequence } $values
26     [ "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 ] bi 1array $description ;
27
28 "Code annotations"
29 {
30     "The " { $vocab-link "annotations" } " vocabulary provides syntax for comment-like annotations that can be looked up with Factor's " { $link usage } " mechanism."
31 }
32 annotation-tags natural-sort
33 [
34     [ \ $subsection swap comment-word 2array ] map append
35     "To look up annotations:" suffix
36 ] [
37     [ \ $subsection swap comment-usage.-word 2array ] map append
38 ] bi
39 <article> "annotations" add-article
40
41 "annotations" vocab "annotations" >>help drop
42
43 annotation-tags [
44     {
45         [ [ \ $annotation swap 2array 1array ] [ comment-word set-word-help ] bi ]
46         [ [ \ $annotation-usage swap 2array 1array ] [ comment-usage-word set-word-help ] bi ]
47         [ [ \ $annotation-usage. swap 2array 1array ] [ comment-usage.-word set-word-help ] bi ]
48         [ [ comment-word ] [ comment-usage-word ] [ comment-usage.-word ] tri 3array related-words ]
49     } cleave
50 ] each