rain-doc 0.0.7 → 0.0.8

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: df089a5bc4bd8767575912bd945d21d61e1f130a
4
- data.tar.gz: 5bcfac44baee8a2e7181c5fca1c64b93218d4ae3
3
+ metadata.gz: 92ea5b3512a732bd0fe45d4352ffc26ab76d68ba
4
+ data.tar.gz: 141fd51fb9902ab6fb6d4ded0505a6c80ee3e55c
5
5
  SHA512:
6
- metadata.gz: 1d92bc03a756b62a923691850b12553360a721460df0549cf91a64f20312f846625468c25d158b296f066932cd4bcb51748b9a9412891f133b8e2565a4a8231c
7
- data.tar.gz: 7205b1029816eb138f513e7efe6d710242db5c1a78e4979c1d0ae658c17e0eb0ae2b4bce7c5ef94a218b8f47f495da168b5ffc3142949a05a00abf563758366e
6
+ metadata.gz: 863f0f4e70124d1a8df0534d5ae2b83fc8a77cfbdd4e7cbba8c7d73e92fc502b2fcae7e64b0ff8e8ca9d120594cb054b2b3c49c9bea30ebf18c0e95fe7a4f6ce
7
+ data.tar.gz: 8cc352acd390172c7f210429c4f5680fb374d09c40bd8b8ab07b1d40d8a838aac3d252f572b2b4d4821cecc54dfaaabe8364e1485bf84148de2fbb5579ec681b
@@ -1,3 +1,5 @@
1
+ require 'redcarpet'
2
+
1
3
  module Rain
2
4
  class Output
3
5
 
@@ -56,6 +58,12 @@ module Rain
56
58
 
57
59
  # create an openstruct from the current doc and render into the template
58
60
  doc_os = OpenStruct.new(doc.to_hash)
61
+
62
+ # convert the doc lines from each of the doc parts
63
+ # from markdown to HTML.
64
+ doc_os = doc_to_markdown(doc_os)
65
+
66
+ # render the doc into the ERB template.
59
67
  doc_rendered = ERB.new(doc_template).result(doc_os.instance_eval {binding})
60
68
 
61
69
  # create a struct with the rendered doc output then render into the layout with nav
@@ -176,5 +184,28 @@ module Rain
176
184
  File.open("./rain_out/#{file_name}", 'w') { |file| file.write(html) }
177
185
  end
178
186
 
187
+ def doc_to_markdown(doc)
188
+
189
+ # loop through all of the doc pars
190
+ markdown_renderer = Redcarpet::Markdown.new(Redcarpet::Render::HTML, tables: true, fenced_code_blocks: true)
191
+ doc[:parts].each do |part|
192
+
193
+ # join the lines and render with markdown.
194
+ part[:markdown] = markdown_renderer.render(part[:doc].join("\n"))
195
+
196
+ # loop through all of the params and render their markdown
197
+ part[:params].each do |param|
198
+ param[:markdown] = markdown_renderer.render(param[:text].join("\n"))
199
+ end
200
+
201
+ # loop through all of the headers and render their markdown
202
+ part[:headers].each do |header|
203
+ header[:markdown] = markdown_renderer.render(header[:text].join("\n"))
204
+ end
205
+ end
206
+
207
+ doc
208
+ end
209
+
179
210
  end
180
211
  end
@@ -35,6 +35,20 @@ p {
35
35
  background-color: #e54400;
36
36
  }
37
37
 
38
+ /* Styles to make rendered markdown output fonts smaller than defaults, to avoid gigantic headers etc. */
39
+ .rain-doc-markdown p,
40
+ .rain-doc-markdown h1, .rain-doc-markdown h2, .rain-doc-markdown h3,
41
+ .rain-doc-markdown h4, .rain-doc-markdown h5, .rain-doc-markdown h6 {
42
+ font-size: 1.2em;
43
+ }
44
+ .rain-doc-markdown h1 { font-size: 2em; }
45
+ .rain-doc-markdown h2 { font-size: 1.8em; }
46
+ .rain-doc-markdown h3 { font-size: 1.6em; }
47
+ .rain-doc-markdown h4 { font-size: 1.4em; }
48
+ .rain-doc-markdown h5 { font-size: 1.2em; }
49
+ .rain-doc-markdown h6 { font-size: 1em; }
50
+ .rain-doc-markdown table > tbody > tr > td > p { font-size: 1em !important; margin: 0 !important; }
51
+
38
52
  /* Footer and rain version information styles */
39
53
  .rain-version-info {
40
54
  text-align: center;
@@ -14,13 +14,13 @@
14
14
  <% end %>
15
15
 
16
16
  <!-- display all of the docs together for the doc_part -->
17
- <p><% doc_part[:doc].each do |doc| %>
18
- <%= doc %>&nbsp;
19
- <% end %></p>
17
+ <div class="rain-doc-markdown">
18
+ <%= doc_part[:markdown] %>
19
+ </p>
20
20
 
21
21
  <!-- show all of the params in a table -->
22
22
  <% if doc_part[:params].length > 0 %>
23
- <h5>Parameters</h5>
23
+ <h4>Parameters</h4>
24
24
  <table class="u-full-width">
25
25
  <thead>
26
26
  <tr>
@@ -35,7 +35,7 @@
35
35
  <td><%= param[:name] %></td>
36
36
  <td><%= param[:type] %></td>
37
37
  <td><%= param[:default].nil? ? 'N/A' : param[:default] %></td>
38
- <td><%= param[:text].join(' ') %></td>
38
+ <td><%= param[:markdown] %></td>
39
39
  </tr>
40
40
  <% end %>
41
41
  </table>
@@ -43,7 +43,7 @@
43
43
 
44
44
  <!-- show all of the headers in a table -->
45
45
  <% if doc_part[:headers].length > 0 %>
46
- <h5>Headers</h5>
46
+ <h4>Headers</h4>
47
47
  <table class="u-full-width">
48
48
  <thead>
49
49
  <tr>
@@ -51,10 +51,10 @@
51
51
  <th>Description</th>
52
52
  </tr>
53
53
  </thead>
54
- <% doc_part[:headers].each do |param| %>
54
+ <% doc_part[:headers].each do |header| %>
55
55
  <tr>
56
- <td><%= param[:name] %></td>
57
- <td><%= param[:text].join(' ') %></td>
56
+ <td><%= header[:name] %></td>
57
+ <td><%= header[:markdown] %></td>
58
58
  </tr>
59
59
  <% end %>
60
60
  </table>
@@ -62,7 +62,7 @@
62
62
 
63
63
  <!-- show all of the responses with examples -->
64
64
  <% if doc_part[:responses].length > 0 %>
65
- <h5>Response Examples</h5>
65
+ <h4>Response Examples</h4>
66
66
  <% doc_part[:responses].each do |response| %>
67
67
  <p><strong><%= response[:code] %></strong> <%= response[:id].upcase %></p>
68
68
  <pre><code><%= response[:text].join("\n") %></code></pre>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rain-doc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Brennan
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - '='
53
53
  - !ruby/object:Gem::Version
54
54
  version: 0.19.1
55
+ - !ruby/object:Gem::Dependency
56
+ name: redcarpet
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '='
60
+ - !ruby/object:Gem::Version
61
+ version: 3.2.2
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '='
67
+ - !ruby/object:Gem::Version
68
+ version: 3.2.2
55
69
  description: "Rain is a gem to generate beautiful and customizable API documentation,
56
70
  inspired by yard and rdoc. The aim of Rain is to generate beautiful
57
71
  API documentation from a ruby comment syntax with markdown mixed in. \n The