PageRenderTime 54ms CodeModel.GetById 40ms app.highlight 11ms RepoModel.GetById 2ms app.codeStats 0ms

/unmaintained/easy-help/easy-help.factor

http://github.com/abeaumont/factor
Unknown | 111 lines | 75 code | 36 blank | 0 comment | 0 complexity | 1288a0c9b65b8c0f5190d12d2ade11e8 MD5 | raw file
  1
  2USING: arrays assocs compiler.units 
  3       grouping help help.markup help.topics kernel lexer multiline
  4       namespaces parser sequences splitting words
  5       easy-help.expand-markup ;
  6
  7IN: easy-help
  8
  9! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 10
 11: parse-text-block ( -- array )
 12  
 13  ".." parse-multiline-string
 14  string-lines
 15  1 tail
 16  [ dup "    " head? [ 4 tail ] [ ] if ] map
 17  [ expand-markup ] map
 18  concat
 19  [ dup "" = [ drop { $nl } ] [ ] if ] map ;
 20
 21! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 22
 23: Text: parse-text-block parsed ; parsing
 24
 25: Block: scan-word 1array parse-text-block append parsed ; parsing
 26
 27! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 28
 29: Notes:           { $notes       } parse-text-block append parsed ; parsing
 30: Description:     { $description } parse-text-block append parsed ; parsing
 31: Contract:        { $contract    } parse-text-block append parsed ; parsing
 32: Checked-Example: { $example     } parse-text-block append parsed ; parsing
 33
 34: Class-Description:
 35  { $class-description } parse-text-block append parsed ; parsing
 36
 37! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 38
 39: Code:
 40  
 41  { $code }
 42  parse-text-block [ dup array? [ drop "" ] [ ] if ] map
 43  append
 44  parsed
 45  
 46  ; parsing
 47
 48: Example:
 49  { $heading "Example" }
 50  { $code }
 51  parse-text-block
 52  [ dup array? [ drop "" ] [ ] if ] map ! Each item in $code must be a string
 53  append 
 54  2array parsed ; parsing
 55
 56: Introduction:
 57
 58  { $heading "Introduction" }
 59  parse-text-block
 60  2array parsed ; parsing
 61
 62: Summary:
 63
 64  { $heading "Summary" }
 65  parse-text-block
 66  2array parsed ; parsing
 67
 68! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 69
 70: Values:
 71
 72  ".." parse-multiline-string
 73  string-lines
 74  1 tail
 75  [ dup "    " head? [ 4 tail ] [ ] if ] map
 76  [ " " split1 [ " " first = ] trim-head 2array ] map
 77  \ $values prefix
 78  parsed
 79
 80  ; parsing
 81
 82! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 83
 84: Word:
 85
 86  scan current-vocab create dup old-definitions get
 87  [ delete-at ] with each dup set-word
 88
 89  bootstrap-word dup set-word
 90  dup >link save-location
 91  \ ; parse-until >array swap set-word-help ; parsing
 92
 93! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 94
 95: Heading: { $heading } ".." parse-multiline-string suffix parsed ; parsing
 96
 97! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 98
 99: List:
100
101  { $list }
102
103  ".." parse-multiline-string
104  string-lines
105  1 tail
106  [ dup "    " head? [ 4 tail ] [ ] if ] map
107  [ expand-markup ] map
108
109  append parsed
110
111  ; parsing