nydp-html 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5c6bd4ce8e9265ae9efdf0b5be0e0d0a19d5e017
4
- data.tar.gz: 714c127398ed568b92ec43b4bf4b38818de09865
3
+ metadata.gz: 9072543e9d73bf1cba1b4a1d3e8a948986afa2cb
4
+ data.tar.gz: 63bcce7beddc22b819218a1d09a66c7d15904c88
5
5
  SHA512:
6
- metadata.gz: 7b9d69c89841bef6e7490406e86c8758b7190558ba6789fac51ca9b19af7ed15568ac3db2899e875bd3b11d92289bb518c3bd40ca25d40b540da9497cf514c24
7
- data.tar.gz: f720b775f02ca686b956fe8f6142bfe80defff0ba8f4d6bfeb72916252f9707f5fb04621d253b385b455fc74382f7227a3600eebf10d5af077eddd24105d99f8
6
+ metadata.gz: 5afdc105df1bcb48d34e124a60ab930456df57fef490698d3f12c4265e04153b357a62e73c6d9d826d9d19c1f1ffea2dbe1b166873434e69331a54c0c06aea09
7
+ data.tar.gz: 227ad74bf6660d041e1b24e468c294d1222d817e52aeb93415912bbaa390c4b9fd45b335ee0af84f8fb81371d1e60239b331a59de818e443071aef1cdaad69df
@@ -1,17 +1,3 @@
1
- ;
2
- ; render-as-textile:
3
- ;
4
- ; (render-as-textile "hello world") ;=> "<p>hello world</p>"
5
- ; (render-as-textile (get-some-text-from 'somewhere)) ;=> (textile-to-html (get-some-text-from 'somewhere))
6
- ; (render-as-textile "hello ~name") ;=> (string-pieces "<p>hello" name "<p>")
7
- ;
8
- ; render-as-haml:
9
- ;
10
- ; (render-as-haml "%p hello world") ;=> "<p>hello world</p>"
11
- ; (render-as-haml (get-some-text-from 'somewhere)) ;=> (haml-to-html (get-some-text-from 'somewhere))
12
- ; (render-as-haml "%p hello ~name") ;=> (string-pieces "<p>hello" name "<p>")
13
- ;
14
-
15
1
  (def interpolate (arg) arg)
16
2
 
17
3
  (def html-process-parts (parts converter)
@@ -31,6 +17,12 @@
31
17
  (map html-interpolatify-arg tuples))))))
32
18
 
33
19
  (mac render-as-haml (arg)
20
+ ; produce code to convert 'arg to html using a haml interpreter
21
+ ; for example:
22
+ ;
23
+ ; (render-as-haml "%p hello world") ;=> "<p>hello world</p>"
24
+ ; (render-as-haml (get-some-text-from 'somewhere)) ;=> (haml-to-html (get-some-text-from 'somewhere))
25
+ ; (render-as-haml "%p hello ~name") ;=> (string-pieces "<p>hello" name "<p>")
34
26
  (if (isa 'string arg)
35
27
  (haml-to-html arg)
36
28
  (and (pair? arg)
@@ -39,6 +31,12 @@
39
31
  `(haml-to-html ,arg)))
40
32
 
41
33
  (mac render-as-textile (arg)
34
+ ; produces code to convert 'arg to html using a textile interpreter
35
+ ; for example:
36
+ ;
37
+ ; (render-as-textile "hello world") ;=> "<p>hello world</p>"
38
+ ; (render-as-textile (get-some-text-from 'somewhere)) ;=> (textile-to-html (get-some-text-from 'somewhere))
39
+ ; (render-as-textile "hello ~name") ;=> (string-pieces "<p>hello" name "<p>")
42
40
  (if (isa 'string arg)
43
41
  (textile-to-html arg)
44
42
  (and (pair? arg)
@@ -49,6 +47,15 @@
49
47
  (def to-css-rule (prop val) (joinstr "" prop ":" val ";"))
50
48
 
51
49
  (def to-css (hsh)
50
+ ; convert given 'hsh to a CSS string. Keys of 'hsh are
51
+ ; css properties; the corresponding values are css values.
52
+ ;
53
+ ; example:
54
+ ; (to-css { background "black" font-size "12px" })
55
+ ;
56
+ ; produces
57
+ ; "background:black;font-size:12px;"
58
+ ;
52
59
  (and hsh
53
60
  (joinstr "" (map (fn (k) (to-css-rule k hsh.,k))
54
61
  (hash-keys hsh)))))
@@ -0,0 +1,62 @@
1
+ (def helpful/type (thing)
2
+ (if (no thing)
3
+ "nil"
4
+ (let type (type-of thing)
5
+ (if (string-match type "ruby/Hash")
6
+ 'ruby-hash
7
+ (string-match type "ruby/")
8
+ 'object
9
+ type))))
10
+
11
+ (def helpful/info (thing)
12
+ ; tries to say something useful about the 'thing
13
+ (if (no thing)
14
+ "nil"
15
+ (pair? thing)
16
+ "list with ~(len thing) elements, first is a ~(helpful/type:car thing)"
17
+ (let mytype (helpful/type thing)
18
+ (if (or (eq? mytype 'hash)
19
+ (eq? mytype 'ruby-hash)
20
+ (eq? mytype 'object))
21
+ (joinstr "\n"
22
+ (map λk(joinstr " -> " k (helpful/type thing.,k))
23
+ (hash-keys thing)))
24
+ "~(inspect thing) is a ~(helpful/type thing)"))))
25
+
26
+ (def helpful/index ()
27
+ ; return the names and types of all the things that are documented
28
+ (joinstr "\n"
29
+ (map (curry inspect:firstn 2)
30
+ (collect dox-with-documentation (dox-all-items)))))
31
+
32
+ (mac helpful/dox (name)
33
+ ; finds documentation for the named thing
34
+ `(let infos (dox-lookup ',name)
35
+ (if (no infos)
36
+ (joinstr " : " ,(pp name) (helpful/info ,name))
37
+ (joinstr "\n\n"
38
+ (map λi(apply dox-show-info i)
39
+ infos)))))
40
+
41
+ (def helpful/examples (name)
42
+ ; finds examples that have been defined for the given 'name
43
+ (let examples (dox-examples name)
44
+ (if examples
45
+ (joinstr "\n"
46
+ (map (curry dox-show-examples name)
47
+ examples)))))
48
+
49
+ (mac help (thing)
50
+ ; returns helpful information about the thing
51
+ ; if thing is nil, show what help is available for
52
+ `(%pre.helpful ,(if (no thing)
53
+ `(helpful/index)
54
+ `(joinstr "\n\n"
55
+ (helpful/dox ,thing)
56
+ (helpful/examples ',thing)))))
57
+
58
+ (def-colon-syntax help names
59
+ (let target (cadr names)
60
+ `(help ,(if (eq? target '||)
61
+ nil
62
+ target))))
@@ -0,0 +1,40 @@
1
+ ;; this function and the following example are used as test-cases in examples-for help
2
+ (def test-example-f (foo)
3
+ ; more than just foo
4
+ (+ 2 foo))
5
+
6
+ (examples-for test-example-f
7
+ ("adds two"
8
+ (test-example-f 99)
9
+ 101))
10
+
11
+ (examples-for help
12
+ ("returns dox and examples for the given name"
13
+ help:test-example-f
14
+ "<pre class='helpful'>Function : test-example-f
15
+
16
+ args : (foo)
17
+
18
+ more than just foo
19
+
20
+ source
21
+ ======
22
+ (def test-example-f (foo)
23
+ (+ 2 foo))
24
+
25
+
26
+
27
+ Examples for test-example-f
28
+ ==================
29
+
30
+ test-example-f adds two
31
+
32
+ running :
33
+ (test-example-f 99)
34
+
35
+ produces : 101
36
+
37
+ --------------------------------
38
+
39
+
40
+ </pre>"))
@@ -1,21 +1,19 @@
1
- (register-test
2
- '(suite "html-tag functions"
3
- (suite "html-tag"
4
- ("returns a html string"
5
- (html-tag "div" { class 'yellow style (to-css { border "1px solid blue" font-size "3em" }) }
6
- (html-tag "h1" nil "Welcome")
7
- (html-tag "p" { class "yadda" } "blah blah"))
8
- "<div class='yellow' style='border:1px solid blue;font-size:3em;'><h1>Welcome</h1><p class='yadda'>blah blah</p></div>"))
9
-
10
- (suite "img"
11
- ("returns an img tag"
12
- (img "/assets/face.png")
13
- "<img src='/assets/face.png'/>"))
14
-
15
- (suite "a"
16
- ("returns an anchor tag"
17
- (link-to "click here!" "/other-page.html" { class "turbo" })
18
- "<a href='/other-page.html' class='turbo'>click here!</a>"))))
1
+ (examples-for html-tag
2
+ ("returns a html string"
3
+ (html-tag "div" { class 'yellow style (to-css { border "1px solid blue" font-size "3em" }) }
4
+ (html-tag "h1" nil "Welcome")
5
+ (html-tag "p" { class "yadda" } "blah blah"))
6
+ "<div class='yellow' style='border:1px solid blue;font-size:3em;'><h1>Welcome</h1><p class='yadda'>blah blah</p></div>"))
7
+
8
+ (examples-for img
9
+ ("returns an img tag"
10
+ (img "/assets/face.png")
11
+ "<img src='/assets/face.png'/>"))
12
+
13
+ (examples-for a
14
+ ("returns an anchor tag"
15
+ (link-to "click here!" "/other-page.html" { class "turbo" })
16
+ "<a href='/other-page.html' class='turbo'>click here!</a>"))
19
17
 
20
18
  (examples-for percent-syntax
21
19
  ("generates a simple html tag"
@@ -30,6 +28,10 @@
30
28
  (%p "hello " (%b.thick "you") " over " (%i "there"))
31
29
  "<p>hello <b class='thick'>you</b> over <i>there</i></p>")
32
30
 
31
+ ("concatenates content"
32
+ (%p (map λx(%span.hello x) '(a b c)))
33
+ "<p><span class='hello'>a</span><span class='hello'>b</span><span class='hello'>c</span></p>")
34
+
33
35
  ("generates html tags with multiple classnames"
34
36
  (%p "hello " (%b.thick.dense "you") " over " (%i "there"))
35
37
  "<p>hello <b class='thick dense'>you</b> over <i>there</i></p>")
@@ -18,8 +18,7 @@ module Nydp
18
18
  end
19
19
 
20
20
  def loadfiles
21
- b = relative_path('../lisp/to-html.nydp')
22
- [b]
21
+ Dir.glob(relative_path '../lisp/html-*.nydp').sort
23
22
  end
24
23
 
25
24
  def testfiles
@@ -1,5 +1,5 @@
1
1
  module Nydp
2
2
  module Html
3
- VERSION = "0.0.8"
3
+ VERSION = "0.0.9"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nydp-html
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Conan Dalton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-08 00:00:00.000000000 Z
11
+ date: 2015-11-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -122,10 +122,12 @@ files:
122
122
  - README.md
123
123
  - Rakefile
124
124
  - bin/nydp-tests
125
+ - lib/lisp/html-010-tools.nydp
126
+ - lib/lisp/html-020-help.nydp
125
127
  - lib/lisp/tests/haml-tests.nydp
128
+ - lib/lisp/tests/help-examples.nydp
126
129
  - lib/lisp/tests/html-tag-tests.nydp
127
130
  - lib/lisp/tests/textile-tests.nydp
128
- - lib/lisp/to-html.nydp
129
131
  - lib/nydp/html.rb
130
132
  - lib/nydp/html/version.rb
131
133
  - nydp-html.gemspec