nydp 0.1.14 → 0.1.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/lisp/core-012-utils.nydp +30 -0
- data/lib/lisp/core-015-documentation.nydp +78 -68
- data/lib/lisp/core-017-builtin-dox.nydp +15 -8
- data/lib/lisp/core-020-utils.nydp +27 -21
- data/lib/lisp/core-030-syntax.nydp +6 -1
- data/lib/lisp/core-040-utils.nydp +1 -5
- data/lib/lisp/core-045-dox-utils.nydp +1 -1
- data/lib/lisp/core-080-pretty-print.nydp +1 -1
- data/lib/lisp/core-100-utils.nydp +6 -0
- data/lib/lisp/tests/dox-tests.nydp +88 -84
- data/lib/lisp/tests/filter-forms-examples.nydp +46 -0
- data/lib/lisp/tests/mapsum-examples.nydp +5 -0
- data/lib/lisp/tests/push-examples.nydp +25 -0
- data/lib/nydp/tokeniser.rb +1 -1
- data/lib/nydp/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2e6fd1dc5fc3149b5f11a0ebdde15b780b18961e
|
4
|
+
data.tar.gz: f0f7f42ba740494b00425e3c5200acc12b9483c9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 20c231e32e8a611446082c2a3eb144ac5782226dcb15f44224a0a77813577d77bf538cf65f6d897f824f0d2c0e7a8a9f8e054c9d84d6b60b06781ede72d1cb1e
|
7
|
+
data.tar.gz: ba1e3bc4f43c7c10bd8e06bd0ce45e513413b75a8213f0365abcb6389114e42ddf1e0c7746fbe78fc0829c5e711b57726ce11d6c11594b6f83fc674d8b372252
|
@@ -0,0 +1,30 @@
|
|
1
|
+
|
2
|
+
(hash-set macs 'if (fn args
|
3
|
+
(cond (no args) nil
|
4
|
+
(cond (cdr args)
|
5
|
+
(cond (cddr args)
|
6
|
+
`(cond ,(car args) ,(cadr args) (if ,@(cddr args)))
|
7
|
+
`(cond ,(car args) ,(cadr args)))
|
8
|
+
(car args)))))
|
9
|
+
|
10
|
+
(def map (f things)
|
11
|
+
; transforms the list 'things by applying 'f to each item
|
12
|
+
; returns the resulting list
|
13
|
+
(if (no things)
|
14
|
+
nil
|
15
|
+
(pair? things)
|
16
|
+
(cons (f (car things)) (map f (cdr things)))
|
17
|
+
(map f (list things))))
|
18
|
+
|
19
|
+
(def hash-cons (h k v)
|
20
|
+
; push 'v onto the value for 'k in 'h
|
21
|
+
(hash-set h k (cons v (hash-get h k))))
|
22
|
+
|
23
|
+
(def rev-accum (things acc)
|
24
|
+
(cond (no things)
|
25
|
+
acc
|
26
|
+
(rev-accum (cdr things)
|
27
|
+
(cons (car things)
|
28
|
+
acc))))
|
29
|
+
|
30
|
+
(def rev (things) (rev-accum things nil))
|
@@ -1,21 +1,31 @@
|
|
1
|
-
((fn (dox examples chapters)
|
2
|
-
(def dox-
|
3
|
-
(hash-set
|
4
|
-
|
5
|
-
|
6
|
-
|
1
|
+
((fn (dox examples chapters dox-new dox-build)
|
2
|
+
(def dox-build (hsh name what texts args src chapters)
|
3
|
+
(hash-set hsh 'name name )
|
4
|
+
(hash-set hsh 'what what )
|
5
|
+
(hash-set hsh 'texts texts )
|
6
|
+
(hash-set hsh 'args args )
|
7
|
+
(hash-set hsh 'src src )
|
8
|
+
(hash-set hsh 'chapters chapters )
|
9
|
+
hsh)
|
10
|
+
|
11
|
+
(def dox-new (item)
|
12
|
+
(hash-cons dox (hash-get item 'name) item)
|
13
|
+
(dox-add-to-chapters (hash-get item 'chapters) item))
|
14
|
+
|
15
|
+
(def dox-add-doc (name what texts args src chapters)
|
16
|
+
(dox-new (dox-build (hash) name what texts args src chapters)))
|
7
17
|
|
8
18
|
(def dox-add-to-chapter (chapter item)
|
9
|
-
(hash-
|
10
|
-
|
11
|
-
|
12
|
-
|
19
|
+
(hash-cons chapters chapter item))
|
20
|
+
|
21
|
+
(def dox-add-to-chapters (chapters item)
|
22
|
+
(cond chapters
|
23
|
+
(do (dox-add-to-chapter (car chapters) item)
|
24
|
+
(dox-add-to-chapters (cdr chapters) item))
|
25
|
+
item))
|
13
26
|
|
14
27
|
(def dox-add-examples (name example-exprs)
|
15
|
-
(hash-
|
16
|
-
name
|
17
|
-
(cons example-exprs
|
18
|
-
(hash-get examples name))))
|
28
|
+
(hash-cons examples name example-exprs))
|
19
29
|
|
20
30
|
(def dox-lookup (sym) (hash-get dox sym))
|
21
31
|
|
@@ -23,65 +33,68 @@
|
|
23
33
|
|
24
34
|
(def dox-names () (hash-keys dox))
|
25
35
|
|
26
|
-
(def dox-
|
27
|
-
(cond (dox? name)
|
28
|
-
(cadr (car (dox-lookup name)))))
|
29
|
-
|
30
|
-
(def dox-src (name)
|
31
|
-
(cond (dox? name)
|
32
|
-
(car (cddr (cddr (car (dox-lookup name)))))))
|
33
|
-
|
34
|
-
(def dox-examples (name)
|
35
|
-
(hash-get examples name))
|
36
|
-
|
37
|
-
(def dox-example-names () (hash-keys examples))
|
38
|
-
|
39
|
-
(def dox-arg-names (name)
|
36
|
+
(def dox-get-attr (name attr)
|
40
37
|
(cond (dox? name)
|
41
|
-
(
|
42
|
-
|
43
|
-
|
44
|
-
(def
|
45
|
-
(
|
46
|
-
|
47
|
-
|
48
|
-
(
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
(
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
(
|
38
|
+
(hash-get (car (dox-lookup name)) attr)))
|
39
|
+
|
40
|
+
(def dox-what-is? (name) (dox-get-attr name 'what ))
|
41
|
+
(def dox-src (name) (dox-get-attr name 'src ))
|
42
|
+
(def dox-examples (name) (hash-get examples name ))
|
43
|
+
(def dox-args (name) (dox-get-attr name 'args ))
|
44
|
+
(def dox-example-names () (hash-keys examples )))
|
45
|
+
(hash) (hash) (hash) nil)
|
46
|
+
|
47
|
+
(def filter-form (hsh form)
|
48
|
+
; if the car of 'form is a key of 'hsh, add the cdr of 'form to the value of the key in 'hsh
|
49
|
+
; otherwise add the form to the list whose key is nil
|
50
|
+
(cond (cond (pair? form)
|
51
|
+
(hash-key? hsh (car form)))
|
52
|
+
(hash-cons hsh (car form) (cdr form))
|
53
|
+
(hash-cons hsh nil form))
|
54
|
+
hsh)
|
55
|
+
|
56
|
+
(def rev-value-key (key keys old new)
|
57
|
+
(hash-set new key (rev (hash-get old key)))
|
58
|
+
(rev-value-keys keys old new))
|
59
|
+
|
60
|
+
(def rev-value-keys (keys old new)
|
61
|
+
(cond keys
|
62
|
+
(rev-value-key (car keys) (cdr keys) old new)
|
63
|
+
new))
|
64
|
+
|
65
|
+
(def rev-values (hsh)
|
66
|
+
(rev-value-keys (hash-keys hsh) hsh (hash)))
|
67
|
+
|
68
|
+
(def filter-forms (hsh forms)
|
69
|
+
; group forms by their first element, if the first element
|
70
|
+
; is already a key in hsh, collect all other elements under key nil
|
71
|
+
(cond forms
|
72
|
+
(filter-forms (filter-form hsh (car forms)) (cdr forms))
|
73
|
+
(rev-values hsh)))
|
74
|
+
|
75
|
+
(def build-def-hash (hsh)
|
76
|
+
(hash-set hsh 'comment nil)
|
77
|
+
(hash-set hsh 'chapter nil)
|
78
|
+
hsh)
|
79
|
+
|
80
|
+
(def define-mac-expr (name args body-forms)
|
65
81
|
; used internally by 'mac
|
66
|
-
`(do (hash-set macs ',name (fn ,args ,@body))
|
82
|
+
`(do (hash-set macs ',name (fn ,args ,@(hash-get body-forms nil)))
|
67
83
|
(dox-add-doc ',name
|
68
84
|
'mac
|
69
|
-
',
|
85
|
+
',(map car (hash-get body-forms 'comment))
|
70
86
|
',args
|
71
|
-
'(mac ,name ,args ,@body))))
|
87
|
+
'(mac ,name ,args ,@(hash-get body-forms nil)))))
|
72
88
|
|
73
89
|
(hash-set macs 'mac
|
74
90
|
(fn (name args . body)
|
75
|
-
(
|
76
|
-
name
|
77
|
-
args
|
78
|
-
(dox-gather-comments body))))
|
91
|
+
(define-mac-expr name args (filter-forms (build-def-hash (hash)) body))))
|
79
92
|
|
80
93
|
(dox-add-doc 'mac
|
81
94
|
'mac
|
82
95
|
'("define a new global macro")
|
83
96
|
'(name args . body)
|
84
|
-
(
|
97
|
+
'`(hash-set macs ',name (fn ,ooargs ,@body)))
|
85
98
|
|
86
99
|
(dox-add-doc 'do
|
87
100
|
'mac
|
@@ -91,18 +104,15 @@
|
|
91
104
|
|
92
105
|
(mac def-assign args `(assign ,@args))
|
93
106
|
|
94
|
-
(def define-def-expr (name args
|
107
|
+
(def define-def-expr (name args body-forms)
|
95
108
|
; used internally by 'def
|
96
|
-
`(do (def-assign ,name (fn ,args ,@body))
|
109
|
+
`(do (def-assign ,name (fn ,args ,@(hash-get body-forms nil)))
|
97
110
|
(dox-add-doc ',name
|
98
111
|
'def
|
99
|
-
',
|
112
|
+
',(map car (hash-get body-forms 'comment))
|
100
113
|
',args
|
101
|
-
'(def ,name ,args ,@body))))
|
114
|
+
'(def ,name ,args ,@(hash-get body-forms nil)))))
|
102
115
|
|
103
116
|
(mac def (name args . body)
|
104
117
|
; define a new function in the global namespace
|
105
|
-
(
|
106
|
-
name
|
107
|
-
args
|
108
|
-
(dox-gather-comments body)))
|
118
|
+
(define-def-expr name args (filter-forms (build-def-hash (hash)) body)))
|
@@ -1,9 +1,16 @@
|
|
1
|
-
(dox-add-doc 'cons 'def '("with args a and b, returns a new cons cell, (a . b)")
|
2
|
-
(dox-add-doc 'car 'def '("with args a, where a is a cons cell (x . y), return x." "Commonly used to get the first element of a list")
|
3
|
-
(dox-add-doc 'cdr 'def '("with args a, where a is a cons cell (x . y), return y." "Commonly used to get contents of a list, excluding the first element")
|
1
|
+
(dox-add-doc 'cons 'def '("with args a and b, returns a new cons cell, (a . b)") '(a b) nil)
|
2
|
+
(dox-add-doc 'car 'def '("with args a, where a is a cons cell (x . y), return x." "Commonly used to get the first element of a list") '(a) nil)
|
3
|
+
(dox-add-doc 'cdr 'def '("with args a, where a is a cons cell (x . y), return y." "Commonly used to get contents of a list, excluding the first element") '(a) nil)
|
4
4
|
(dox-add-doc '+ 'def '("with rest-args things, return the sum of the elements of things." "Will also increment dates and concatenate strings and lists") 'things nil)
|
5
|
-
(dox-add-doc '- 'def '("return the result of subtracting all other args from the first arg." "(- a b c d) is equivalent to (- a (+ b c d))")
|
6
|
-
(dox-add-doc '* 'def '("with rest-args things, return the product of the elements of things.")
|
7
|
-
(dox-add-doc '/ 'def '("return the result of dividing all other args into the first arg." "(/ a b c d) is equivalent to (/ a (* b c d))")
|
8
|
-
(dox-add-doc '> 'def '("true if each arg is greater than the next arg")
|
9
|
-
(dox-add-doc '< 'def '("true if each arg is less than the next arg")
|
5
|
+
(dox-add-doc '- 'def '("return the result of subtracting all other args from the first arg." "(- a b c d) is equivalent to (- a (+ b c d))") 'things nil)
|
6
|
+
(dox-add-doc '* 'def '("with rest-args things, return the product of the elements of things.") 'things nil)
|
7
|
+
(dox-add-doc '/ 'def '("return the result of dividing all other args into the first arg." "(/ a b c d) is equivalent to (/ a (* b c d))") 'things nil)
|
8
|
+
(dox-add-doc '> 'def '("true if each arg is greater than the next arg") 'things nil)
|
9
|
+
(dox-add-doc '< 'def '("true if each arg is less than the next arg") 'things nil)
|
10
|
+
(dox-add-doc 'mod 'def '("return the remainder after diving a by b") '(a b) nil)
|
11
|
+
(dox-add-doc 'eval 'def '("evaluate the given lisp expression") '(expr) nil)
|
12
|
+
(dox-add-doc 'hash 'def '("create a new Hash instance") nil nil)
|
13
|
+
(dox-add-doc 'apply 'def '("invoke f with args 'args") '(f . args) nil)
|
14
|
+
(dox-add-doc 'date 'def '("create a new date instance") '(year month day) nil)
|
15
|
+
(dox-add-doc 'error 'def '("raise an exception") 'args nil)
|
16
|
+
(dox-add-doc 'parse 'def '("parse the given string and return the corresponding lisp objects") '(str) nil)
|
@@ -1,22 +1,28 @@
|
|
1
|
-
(
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
1
|
+
(dox-add-doc 'if
|
2
|
+
'mac
|
3
|
+
'("with arguments a, return a"
|
4
|
+
"with arguments a b, return b if a is true, otherwise nil"
|
5
|
+
"with arguments a b c, return b if a is true, otherwise return c"
|
6
|
+
"with arguments a b c d, return b if a is true, otherwise return d if c is true, otherwise nil"
|
7
|
+
"with arguments a b c d e, return b if a is true, otherwise return d if c is true, otherwise e"
|
8
|
+
"and so on for subsequent arguments")
|
9
|
+
'args
|
10
|
+
'(cond (no args) nil
|
11
|
+
(cond (cdr args)
|
12
|
+
(cond (cddr args)
|
13
|
+
`(cond ,(car twargs) ,(cadr twargs) (if ,@(cddr twargs)))
|
14
|
+
`(cond ,(car twargs) ,(cadr twargs)))
|
15
|
+
(car args)))
|
16
|
+
'(flow-control))
|
14
17
|
|
15
|
-
(
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
18
|
+
(dox-add-doc 'map
|
19
|
+
'def
|
20
|
+
'("transforms the list 'things by applying 'f to each item"
|
21
|
+
"returns the resulting list")
|
22
|
+
'(f things)
|
23
|
+
'(if (no things)
|
24
|
+
nil
|
25
|
+
(pair? things)
|
26
|
+
(cons (f (car things)) (map f (cdr things)))
|
27
|
+
(map f (list things)))
|
28
|
+
'(list-manipulation))
|
@@ -176,11 +176,16 @@
|
|
176
176
|
,(build-hash-get-key:car rnames)
|
177
177
|
,value-expr)))
|
178
178
|
|
179
|
+
(def hash-get-assignment (lookup value)
|
180
|
+
`(hash-set ,@lookup ,value))
|
181
|
+
|
179
182
|
(mac = (name value)
|
180
183
|
(if (isa 'symbol name)
|
181
184
|
`(assign ,name ,value)
|
182
185
|
(caris 'dot-syntax name)
|
183
|
-
(dot-syntax-assignment (cdr name) value)
|
186
|
+
(dot-syntax-assignment (cdr name) value)
|
187
|
+
(caris 'hash-get name)
|
188
|
+
(hash-get-assignment (cdr name) value)))
|
184
189
|
|
185
190
|
(mac def-assign args `(= ,@args))
|
186
191
|
|
@@ -11,7 +11,7 @@
|
|
11
11
|
(zip (cdr a) (cdr b)))))
|
12
12
|
|
13
13
|
(mac push (x things)
|
14
|
-
`(
|
14
|
+
`(= ,things (cons ,x ,things)))
|
15
15
|
|
16
16
|
(def flatten (things)
|
17
17
|
(let acc nil
|
@@ -286,7 +286,3 @@
|
|
286
286
|
|
287
287
|
(def min things (best < things))
|
288
288
|
(def max things (best > things))
|
289
|
-
|
290
|
-
(def hash-cons (h k v)
|
291
|
-
; push 'v onto the value for 'k in 'h
|
292
|
-
(= h.,k (cons v h.,k)))
|
@@ -58,7 +58,7 @@ Examples for ~name
|
|
58
58
|
(if (no infos)
|
59
59
|
(p "No documentation for" ',name)
|
60
60
|
(each info infos
|
61
|
-
(p
|
61
|
+
(p (dox-show-info info.name info.what info.texts info.args))))
|
62
62
|
(let examples (dox-examples ',name)
|
63
63
|
(if (no examples)
|
64
64
|
(p "No examples for" ',name)
|
@@ -83,7 +83,7 @@
|
|
83
83
|
|
84
84
|
(def pp/find-breaks/mac (form)
|
85
85
|
(if (eq? (dox-what-is? (car form)) 'mac)
|
86
|
-
(let arg-count (list-length:dox-
|
86
|
+
(let arg-count (list-length:dox-args:car form)
|
87
87
|
(cons (firstn arg-count form)
|
88
88
|
(map list (nthcdr arg-count form))))))
|
89
89
|
|
@@ -71,3 +71,9 @@
|
|
71
71
|
(def seqf (start incr)
|
72
72
|
(let i (or incr 1)
|
73
73
|
(fn () (returning start (++ start i)))))
|
74
|
+
|
75
|
+
(def mapply (f args)
|
76
|
+
; like 'map, but assumes each item in 'args is a list
|
77
|
+
; of parameters for 'f. Effectively, calls (apply f item)
|
78
|
+
; for each item in 'args
|
79
|
+
(map λa(apply f a) args))
|
@@ -12,96 +12,100 @@
|
|
12
12
|
(def this-is-an-undocumented-def (a b c)
|
13
13
|
(baz a b c))
|
14
14
|
|
15
|
-
(examples-for
|
16
|
-
("
|
17
|
-
(
|
18
|
-
|
19
|
-
|
20
|
-
("
|
21
|
-
(
|
22
|
-
|
23
|
-
|
24
|
-
(
|
25
|
-
|
26
|
-
(
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
(
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
(
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
(
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
\(def bingo (count)
|
58
|
-
(times count (bark)))
|
59
|
-
"))
|
15
|
+
(examples-for dox-lookup
|
16
|
+
("finds name for a documented macro"
|
17
|
+
(hash-get (car:dox-lookup 'this-is-a-well-documented-macro) 'name)
|
18
|
+
this-is-a-well-documented-macro)
|
19
|
+
|
20
|
+
("finds type for a documented macro"
|
21
|
+
(hash-get (car:dox-lookup 'this-is-a-well-documented-macro) 'what)
|
22
|
+
mac)
|
23
|
+
|
24
|
+
("finds documentation for a documented macro"
|
25
|
+
(hash-get (car:dox-lookup 'this-is-a-well-documented-macro) 'texts)
|
26
|
+
("documentation for me!"))
|
27
|
+
|
28
|
+
("finds arg names for a documented macro"
|
29
|
+
(hash-get (car:dox-lookup 'this-is-a-well-documented-macro) 'args)
|
30
|
+
(a b c))
|
31
|
+
|
32
|
+
("finds source code for a documented macro"
|
33
|
+
(hash-get (car:dox-lookup 'this-is-a-well-documented-macro) 'src)
|
34
|
+
(mac this-is-a-well-documented-macro (a b c)
|
35
|
+
`(foo ,a ,b ,c)))
|
36
|
+
|
37
|
+
("finds name for an undocumented macro"
|
38
|
+
(hash-get (car:dox-lookup 'this-is-an-undocumented-macro) 'name)
|
39
|
+
this-is-an-undocumented-macro)
|
40
|
+
|
41
|
+
("finds type for an undocumented macro"
|
42
|
+
(hash-get (car:dox-lookup 'this-is-an-undocumented-macro) 'what)
|
43
|
+
mac)
|
44
|
+
|
45
|
+
("finds no documentation for an undocumented macro"
|
46
|
+
(hash-get (car:dox-lookup 'this-is-an-undocumented-macro) 'texts)
|
47
|
+
nil)
|
48
|
+
|
49
|
+
("finds arg names for an undocumented macro"
|
50
|
+
(hash-get (car:dox-lookup 'this-is-an-undocumented-macro) 'args)
|
51
|
+
(a b c))
|
52
|
+
|
53
|
+
("finds source code for an undocumented macro"
|
54
|
+
(hash-get (car:dox-lookup 'this-is-an-undocumented-macro) 'src)
|
55
|
+
(mac this-is-an-undocumented-macro (a b c)
|
56
|
+
`(baz ,a ,b ,c))))
|
60
57
|
|
61
58
|
(examples-for dox-lookup
|
62
|
-
("finds
|
63
|
-
(dox-lookup 'this-is-a-well-documented-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
(
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
59
|
+
("finds name for a documented def"
|
60
|
+
(hash-get (car:dox-lookup 'this-is-a-well-documented-def) 'name)
|
61
|
+
this-is-a-well-documented-def)
|
62
|
+
|
63
|
+
("finds type for a documented def"
|
64
|
+
(hash-get (car:dox-lookup 'this-is-a-well-documented-def) 'what)
|
65
|
+
def)
|
66
|
+
|
67
|
+
("finds documentation for a documented def"
|
68
|
+
(hash-get (car:dox-lookup 'this-is-a-well-documented-def) 'texts)
|
69
|
+
("documentation for me!"))
|
70
|
+
|
71
|
+
("finds arg names for a documented def"
|
72
|
+
(hash-get (car:dox-lookup 'this-is-a-well-documented-def) 'args)
|
73
|
+
(a b c))
|
74
|
+
|
75
|
+
("finds source code for a documented def"
|
76
|
+
(hash-get (car:dox-lookup 'this-is-a-well-documented-def) 'src)
|
77
|
+
(def this-is-a-well-documented-def (a b c)
|
78
|
+
(foo a b c)))
|
79
|
+
|
80
|
+
("finds name for an undocumented def"
|
81
|
+
(hash-get (car:dox-lookup 'this-is-an-undocumented-def) 'name)
|
82
|
+
this-is-an-undocumented-def)
|
83
|
+
|
84
|
+
("finds type for an undocumented def"
|
85
|
+
(hash-get (car:dox-lookup 'this-is-an-undocumented-def) 'what)
|
86
|
+
def)
|
87
|
+
|
88
|
+
("finds no documentation for an undocumented def"
|
89
|
+
(hash-get (car:dox-lookup 'this-is-an-undocumented-def) 'texts)
|
90
|
+
nil)
|
91
|
+
|
92
|
+
("finds arg names for an undocumented def"
|
93
|
+
(hash-get (car:dox-lookup 'this-is-an-undocumented-def) 'args)
|
94
|
+
(a b c))
|
95
|
+
|
96
|
+
("finds source code for an undocumented def"
|
97
|
+
(hash-get (car:dox-lookup 'this-is-an-undocumented-def) 'src)
|
98
|
+
(def this-is-an-undocumented-def (a b c)
|
99
|
+
(baz a b c))))
|
100
|
+
|
101
|
+
|
102
|
+
(examples-for dox-args
|
99
103
|
("macro"
|
100
|
-
(dox-
|
104
|
+
(dox-args 'this-is-a-well-documented-macro)
|
101
105
|
(a b c))
|
102
106
|
|
103
107
|
("function def"
|
104
|
-
(dox-
|
108
|
+
(dox-args 'this-is-a-well-documented-def)
|
105
109
|
(a b c)))
|
106
110
|
|
107
111
|
(examples-for dox-src
|
@@ -0,0 +1,46 @@
|
|
1
|
+
(examples-for filter-forms
|
2
|
+
("groups forms by their 'car if the 'car is a key in the given hash"
|
3
|
+
(let ff (filter-forms { car nil comment nil mac nil }
|
4
|
+
'(let x 1
|
5
|
+
; first comment
|
6
|
+
(mac push foo bar)
|
7
|
+
(car that)
|
8
|
+
; another comment
|
9
|
+
(car engine)
|
10
|
+
(drive faster)
|
11
|
+
(mac more macaroni)
|
12
|
+
(car wheels)
|
13
|
+
(mac and cheese)
|
14
|
+
; ok enough cheese
|
15
|
+
(finish cheese)
|
16
|
+
(car go)))
|
17
|
+
(list (hash-keys ff)
|
18
|
+
ff.car
|
19
|
+
ff.comment
|
20
|
+
ff.mac
|
21
|
+
(hash-get ff nil)))
|
22
|
+
((car comment mac nil)
|
23
|
+
((that) (engine) (wheels) (go))
|
24
|
+
(("first comment") ("another comment") ("ok enough cheese"))
|
25
|
+
((push foo bar) (more macaroni) (and cheese))
|
26
|
+
(let x 1 (drive faster) (finish cheese))))
|
27
|
+
|
28
|
+
|
29
|
+
|
30
|
+
("find no comments"
|
31
|
+
(hash-values (filter-forms { comment nil } '((this) (that))))
|
32
|
+
(nil ((this) (that))))
|
33
|
+
|
34
|
+
("finds one comment"
|
35
|
+
(hash-values (filter-forms { comment nil }
|
36
|
+
'((comment "hello") (this) (that))))
|
37
|
+
((("hello")) ((this) (that))))
|
38
|
+
|
39
|
+
("finds more comments"
|
40
|
+
(hash-values (filter-forms { comment nil }
|
41
|
+
'((comment "hello")
|
42
|
+
(comment "more details")
|
43
|
+
(comment "very rigourous")
|
44
|
+
(this)
|
45
|
+
(that))))
|
46
|
+
((("hello") ("more details") ("very rigourous")) ((this) (that)))))
|
@@ -0,0 +1,25 @@
|
|
1
|
+
(examples-for push
|
2
|
+
("push a value onto the beginning of a list"
|
3
|
+
(let x nil
|
4
|
+
(push 'c x)
|
5
|
+
(push 'b x)
|
6
|
+
(push 'a x)
|
7
|
+
x)
|
8
|
+
(a b c))
|
9
|
+
|
10
|
+
("push a value onto the beginning of a list stored in a hash"
|
11
|
+
(let x {}
|
12
|
+
(push 'c x.stuff)
|
13
|
+
(push 'b x.stuff)
|
14
|
+
(push 'a x.stuff)
|
15
|
+
(list (hash-keys x) x.stuff))
|
16
|
+
((stuff) (a b c)))
|
17
|
+
|
18
|
+
("push a value onto the beginning of a list using a hash-get expression"
|
19
|
+
(let x {}
|
20
|
+
(push 1 (hash-get x 'foo))
|
21
|
+
(push 2 (hash-get x 'foo))
|
22
|
+
(push 3 (hash-get x nil))
|
23
|
+
(push 4 (hash-get x nil))
|
24
|
+
(list (hash-keys x) x.foo (hash-get x nil)))
|
25
|
+
((foo nil) (2 1) (4 3))))
|
data/lib/nydp/tokeniser.rb
CHANGED
data/lib/nydp/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nydp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Conan Dalton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04-
|
11
|
+
date: 2016-04-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -86,6 +86,7 @@ files:
|
|
86
86
|
- bin/nydp-tests
|
87
87
|
- lib/lisp/core-000.nydp
|
88
88
|
- lib/lisp/core-010-precompile.nydp
|
89
|
+
- lib/lisp/core-012-utils.nydp
|
89
90
|
- lib/lisp/core-015-documentation.nydp
|
90
91
|
- lib/lisp/core-017-builtin-dox.nydp
|
91
92
|
- lib/lisp/core-020-utils.nydp
|
@@ -118,6 +119,7 @@ files:
|
|
118
119
|
- lib/lisp/tests/empty-examples.nydp
|
119
120
|
- lib/lisp/tests/error-tests.nydp
|
120
121
|
- lib/lisp/tests/explain-mac-examples.nydp
|
122
|
+
- lib/lisp/tests/filter-forms-examples.nydp
|
121
123
|
- lib/lisp/tests/foundation-test.nydp
|
122
124
|
- lib/lisp/tests/group-by-examples.nydp
|
123
125
|
- lib/lisp/tests/hash-examples.nydp
|
@@ -131,6 +133,7 @@ files:
|
|
131
133
|
- lib/lisp/tests/plus-plus-examples.nydp
|
132
134
|
- lib/lisp/tests/pre-compile-examples.nydp
|
133
135
|
- lib/lisp/tests/pretty-print-tests.nydp
|
136
|
+
- lib/lisp/tests/push-examples.nydp
|
134
137
|
- lib/lisp/tests/quasiquote-examples.nydp
|
135
138
|
- lib/lisp/tests/range-examples.nydp
|
136
139
|
- lib/lisp/tests/relative-months-examples.nydp
|