]> gitweb.factorcode.org Git - factor.git/blob - extra/easy-help/easy-help.factor
c59fbab6ee30ccb8cb673f35dc7f5c8af1e60f91
[factor.git] / extra / easy-help / easy-help.factor
1
2 USING: kernel multiline parser arrays
3        sequences splitting grouping help.markup ;
4
5 IN: easy-help
6
7 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
8
9 : Description:
10
11   ".." parse-multiline-string
12   string-lines
13   1 tail
14   [ dup "   " head? [ 4 tail     ] [ ] if ] map
15   [ dup ""    =     [ drop { $nl } ] [ ] if ] map
16   \ $description prefix
17   parsed
18   
19   ; parsing
20
21 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
22
23 : Example:
24
25   { $heading "Example" } parsed
26
27   ".." parse-multiline-string
28   string-lines
29   [ dup "   " head? [ 4 tail ] [ ] if ] map
30   [ "" = not ] filter
31   ! \ $example prefix
32   \ $code prefix
33   parsed
34
35   ; parsing
36
37 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
38
39 : Summary:
40
41   ".." parse-multiline-string
42   string-lines
43   1 tail
44   [ dup "   " head? [ 4 tail     ] [ ] if ] map
45   [ dup ""    =     [ drop { $nl } ] [ ] if ] map
46   { $heading "Summary" } prefix
47   parsed
48   
49   ; parsing
50
51 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
52
53 : Values:
54
55   ".." parse-multiline-string
56   string-lines
57   1 tail
58   [ dup "   " head? [ 4 tail ] [ ] if ] map
59   [ " " split1 [ " " first = ] trim-left 2array ] map
60   \ $values prefix
61   parsed
62
63   ; parsing
64
65 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
66
67 : Word:
68
69   scan current-vocab create dup old-definitions get
70   [ delete-at ] with each dup set-word
71
72   bootstrap-word dup set-word
73   dup >link save-location
74   \ ; parse-until >array swap set-word-help ; parsing