webapidoc 0.0.6 → 0.0.7

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.
@@ -1,4 +1,4 @@
1
- <%= @data[:title] %> Documentation
1
+ <%= @data["title"] %> Documentation
2
2
  ====================
3
3
 
4
4
  Welcome
@@ -1,4 +1,4 @@
1
- <%= @data[:title] %> Sample Page
1
+ <%= @data["title"] %> Sample Page
2
2
  ====================
3
3
 
4
4
  Paragraphs
@@ -61,3 +61,12 @@ This is just some code.
61
61
  ]
62
62
 
63
63
  This is some `code` within a paragraph. More to come!
64
+ This is just some more code.
65
+
66
+ [
67
+ {
68
+ "title": "apples",
69
+ "count": [12000, 20000],
70
+ "description": {"text": "...", "sensitive": false}
71
+ }
72
+ ]
@@ -1,5 +1,6 @@
1
1
  title: "WebAPIDoc"
2
2
  description: "Static HTML Documentation for JSON APIs"
3
+ url: "http://localhost:3000"
3
4
 
4
5
  chapters:
5
6
  -
@@ -8,9 +8,7 @@ module Webapidoc
8
8
  raise "both paths are invalid: #{t}"
9
9
  end
10
10
 
11
- def self.build(data=nil)
12
-
13
- @data = data
11
+ def self.build
14
12
 
15
13
  publicDir = "public/documentation"
16
14
  docDir = "app/documentation"
@@ -18,9 +16,10 @@ module Webapidoc
18
16
 
19
17
  # get config hash
20
18
  configFile = 'config/webapidoc.yml'
21
- config = YAML.load_file(configFile).freeze
19
+ @data = YAML.load_file(configFile).freeze
22
20
 
23
- puts "building webapidoc for " + config["title"]
21
+ puts "building webapidoc for " + @data["title"]
22
+ puts "api url: " + @data["url"]
24
23
 
25
24
  # clean up
26
25
  FileUtils.remove_dir publicDir if File.exists?(publicDir)
@@ -33,7 +32,7 @@ module Webapidoc
33
32
  # copy jquery
34
33
  FileUtils.copy(libDir + "/js/jquery.js", publicDir + "/js/jquery.js")
35
34
 
36
- # copy highlighter
35
+ # copy highlight
37
36
  FileUtils.copy(libDir + "/js/highlight.js", publicDir + "/js/highlight.js")
38
37
 
39
38
  # compile webapidoc style
@@ -45,7 +44,7 @@ module Webapidoc
45
44
  @chapters = []
46
45
 
47
46
  # get chapter info
48
- config["chapters"].each_with_index do | chapter, idx|
47
+ @data["chapters"].each_with_index do | chapter, idx|
49
48
 
50
49
  inFile = "#{docDir}/#{chapter["file"]}.md"
51
50
  outFile = chapter["file"] + ".html"
@@ -18,7 +18,7 @@
18
18
 
19
19
  */
20
20
 
21
- $color-text: #333;
21
+ $color-text: #666;
22
22
  $color: #148773;
23
23
  $color-highlight: #17BCA5;
24
24
  $color-code: #f0f0f0;
@@ -67,7 +67,7 @@ table {
67
67
  h1, h2, h3, h4, h5, h6 {
68
68
  font-family: inherit;
69
69
  line-height: normal;
70
- font-weight: 400;
70
+ font-weight: 300;
71
71
  color: inherit;
72
72
  background-color: transparent;
73
73
  border-bottom: none;
@@ -132,7 +132,7 @@ pre {
132
132
  body {
133
133
 
134
134
  font-family: "Lato", Calibri, Arial, sans-serif;
135
- font-weight: 400;
135
+ font-weight: 300;
136
136
  color: $color-text;
137
137
 
138
138
  background: #f9f9f9;
@@ -360,7 +360,7 @@ p {
360
360
  font-size: 16px;
361
361
  line-height: 1.4;
362
362
  text-align: justify;
363
- font-weight: 400;
363
+ font-weight: 300;
364
364
  margin-top: 12px;
365
365
  }
366
366
 
@@ -478,16 +478,50 @@ p.version {
478
478
  margin-top: 24px;
479
479
  }
480
480
 
481
- /* #Code Styles, from tomorrow style -> http://jmblog.github.com/color-themes-for-google-code-highlightjs
481
+ /* #Code Styles
482
482
  ================================================== */
483
483
 
484
- pre {
484
+ /* inline code */
485
+ code {
486
+ font-family: monospace;
487
+ background: $color-code;
488
+ color: #718c00;
489
+ border-radius: 4px;
490
+ text-shadow: none;
491
+ font-size: 14px;
492
+ line-height: 20px;
493
+ padding: 2px;
494
+ padding-left:4px;
495
+ padding-right:4px;
496
+ }
497
+
498
+ /* editor */
499
+ .ace_editor {
500
+ width: 100%;
501
+ display: block;
502
+ position: relative;
503
+ margin-top: 24px;
504
+ margin-bottom: 24px;
505
+ border: 1px solid #ddd;
506
+ }
507
+
508
+ /* #Response Code Styles, from tomorrow style -> http://jmblog.github.com/color-themes-for-google-code-highlightjs
509
+ ================================================== */
510
+
511
+ pre.response {
512
+ padding: 10px;
513
+
514
+ border: 1px solid #ddd;
515
+ background: #F0F0F0;
516
+ border-radius: 4px;
517
+ box-shadow: 1px 1px 10px white;
518
+
485
519
  .comment, .title {
486
520
  color: #8e908c;
487
521
  }
488
522
  }
489
523
 
490
- pre {
524
+ pre.response {
491
525
  .variable, .attribute, .tag, .regexp, .ruby .constant {
492
526
  color: #c82829;
493
527
  }
@@ -506,29 +540,29 @@ pre {
506
540
  }
507
541
  }
508
542
 
509
- pre {
543
+ pre.response {
510
544
  .number, .preprocessor, .built_in, .literal, .params, .constant {
511
545
  color: #f5871f;
512
546
  }
513
547
  }
514
548
 
515
- pre {
549
+ pre.response {
516
550
  .class, .ruby .class .title, .css .rules .attribute {
517
551
  color: #eab700;
518
552
  }
519
553
  }
520
554
 
521
- pre {
555
+ pre.response {
522
556
  .string, .value, .inheritance, .header, .ruby .symbol, .xml .cdata {
523
557
  color: #718c00;
524
558
  }
525
559
  }
526
560
 
527
- pre .css .hexcolor {
561
+ pre.response .css .hexcolor {
528
562
  color: #3e999f;
529
563
  }
530
564
 
531
- pre {
565
+ pre.response {
532
566
  .function {
533
567
  color: #4271ae;
534
568
  }
@@ -547,21 +581,7 @@ pre {
547
581
  }
548
582
  }
549
583
 
550
- code {
551
- font-family: monospace;
552
- background: $color-code;
553
- color: #718c00;
554
- border-radius: 4px;
555
- box-shadow: 1px 1px 10px #fff;
556
- text-shadow: none;
557
- font-size: 14px;
558
- line-height: 20px;
559
- padding: 2px;
560
- padding-left:4px;
561
- padding-right:4px;
562
- }
563
-
564
- pre {
584
+ pre.response {
565
585
  margin-top: 12px;
566
586
 
567
587
  .keyword, .javascript .function {
@@ -570,6 +590,15 @@ pre {
570
590
  code {
571
591
  display: block;
572
592
  padding: 12px;
593
+ background: $color-code;
594
+ color: #718c00;
595
+ border-radius: 4px;
596
+ text-shadow: none;
597
+ line-height: 20px;
598
+
599
+ font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Droid Sans Mono', 'Consolas', monospace;
600
+ font-size: 12px;
601
+
573
602
  }
574
603
  .coffeescript .javascript, .javascript .xml, .tex .formula {
575
604
  opacity: 0.5;
@@ -581,6 +610,8 @@ pre {
581
610
  }
582
611
  }
583
612
 
613
+
614
+
584
615
  /* #Print Styles
585
616
  ================================================== */
586
617
 
@@ -2,10 +2,10 @@
2
2
  <html lang="en">
3
3
  <head>
4
4
  <meta charset="utf-8">
5
- <title>Webapidoc for <%= @data[:title] %></title>
5
+ <title>Webapidoc for <%= @data["title"] %></title>
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
- <meta name="description" content="in-depth WebAPI documentation for <%= @data[:title] %>">
8
- <meta name="author" content="the nice guys from <%= @data[:title] %>">
7
+ <meta name="description" content="in-depth WebAPI documentation for <%= @data["title"] %>">
8
+ <meta name="author" content="the nice guys from <%= @data["title"] %>">
9
9
 
10
10
  <!-- SVG version of grayscale filter: desaturate.svg -->
11
11
  <svg version="1.1" xmlns="http://www.w3.org/2000/svg" style="display: none;">
@@ -32,12 +32,8 @@
32
32
  <script src="/documentation/js/jquery.js"></script>
33
33
  <script src="/documentation/js/highlight.js"></script>
34
34
 
35
- <!-- enable script highlighting -->
36
- <script>
37
- $(document).ready(function() {
38
- hljs.initHighlightingOnLoad();
39
- });
40
- </script>
35
+ <!-- Ace Code Editor -->
36
+ <script src="http://d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js" type="text/javascript" charset="utf-8"></script>
41
37
 
42
38
  <!-- Fav and touch icons -->
43
39
  <link rel="shortcut icon" href="favicon.ico">
@@ -78,10 +74,62 @@
78
74
  <!--/row-->
79
75
 
80
76
  <footer>
81
- <p>&copy; <%= @data[:title] %> 2012</p>
77
+ <p>&copy; <%= @data["title"] %> 2012</p>
82
78
  </footer>
83
79
 
84
80
  </div>
85
81
 
82
+ <!-- enable script highlighting -->
83
+ <script>
84
+ $(document).ready(function() {
85
+
86
+ $("#content > pre > code").each( function (idx) {
87
+ var $editor = $(this);
88
+ var id = "editor" + idx;
89
+ var height = $editor.height();
90
+
91
+ $editor.attr("id", id)
92
+
93
+ /* build editor */
94
+ var editor = ace.edit(id);
95
+ editor.setTheme("ace/theme/tomorrow");
96
+ editor.getSession().setMode("ace/mode/javascript");
97
+
98
+ $editor.css("height", ((height+8) + "px"));
99
+
100
+ /* build response field */
101
+ var rid = "response" + idx;
102
+ var $response = $('<pre><code>change code to see response...</code></pre>').attr("id", rid).addClass("response");
103
+
104
+ $editor.after($response);
105
+
106
+ /* bind editor change function for api requests */
107
+ editor.on("change", function(e) {
108
+ console.log(e);
109
+
110
+ /* validate json */
111
+ var query = "";
112
+
113
+ try {
114
+ query = JSON.stringify($.parseJSON(editor.getValue()));
115
+ }
116
+ catch (err) {
117
+ return;
118
+ }
119
+ var url = "<%= @data['url'] %>";
120
+ $.getJSON(url + '&source=' + encodeURIComponent(query)).complete(function (data) {
121
+
122
+
123
+ $response.html("<code>" + data.responseText + "</code>");
124
+ hljs.highlightBlock($response[0]);
125
+ });
126
+ });
127
+
128
+ })
129
+
130
+ });
131
+
132
+ </script>
133
+
86
134
  </body>
87
135
  </html>
@@ -1,4 +1,4 @@
1
1
  module Webapidoc
2
2
  NAME = "webapidoc"
3
- VERSION = "0.0.6"
3
+ VERSION = "0.0.7"
4
4
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webapidoc
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 6
10
- version: 0.0.6
9
+ - 7
10
+ version: 0.0.7
11
11
  platform: ruby
12
12
  authors:
13
13
  - Adrian Fuhrmann