rtfdoc 0.1.1 → 0.1.2

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
  SHA256:
3
- metadata.gz: 93d5fa719f81ab8e2a7c7796e9c982d46b789e9865fff3fa845df311983efdf8
4
- data.tar.gz: 6494491a42493a3da01be644f21b2785c4095991a7336fd34cc7814e1b25b42b
3
+ metadata.gz: a6fe3681c1ed97593bf930b2affe79ce710f8e02ba25220fc2568eb259819907
4
+ data.tar.gz: 1987316da892c9fafc03b7d541cd772cb767c51730729a2063108048d8bec032
5
5
  SHA512:
6
- metadata.gz: f440ca29a0788b8314ea0c3ae94babf016e773482853b2c6ffd0d347cc3fc92782557ee11dd1b090ba1107095bd1a45f78f79bf22c3835fb28f35a38768b548b
7
- data.tar.gz: b54bc1e8acdecbb93d23464c8733c487e4f8bb21c186d27039d588522b8b3051dcb1a7118852037232b7d704c03da4c2d0c435c66121a8cf208f8b7d02730da1
6
+ metadata.gz: c0993193c6965352819b9e435b3333b5890a98bc685cfc293bc613e97ffc8e72489b4898471ad2e9537d0ab6334e191c30e864deaa17f5a1917baaf3b41d830d
7
+ data.tar.gz: 449972e46595c02fdda34c6957e7a37ec7e6222ca88dbbbd96e3d3d246438e33d39da704b8df9dbddbbc231964bbce32aa9957fcc823ba28643e265522730448
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rtfdoc (0.1.0)
4
+ rtfdoc (0.1.2)
5
5
  erubi (~> 1.9.0)
6
6
  redcarpet (~> 3.5.0)
7
7
  rouge (~> 3.20.0)
@@ -91,14 +91,23 @@ module RTFDoc
91
91
  if language == 'attributes' || language == 'parameters'
92
92
  AttributesComponent.new(code, language).output
93
93
  elsif language == 'response'
94
- <<-HTML
95
- <div class="section-response">
96
- <div class="response-topbar">RESPONSE</div>
97
- <pre><code>#{rouge_formatter.format(rouge_lexer.lex(code.strip))}</code></pre>
98
- </div>
99
- HTML
94
+ format_code('RESPONSE', code)
95
+ elsif language == 'title_and_code'
96
+ title, _code = code.split("\n", 2)
97
+ title ||= 'RESPONSE'
98
+ format_code(title, _code)
100
99
  end
101
100
  end
101
+
102
+ private def format_code(title, code)
103
+ <<-HTML
104
+ <div class="section-response">
105
+ <div class="response-topbar">#{title}</div>
106
+ <pre><code>#{rouge_formatter.format(rouge_lexer.lex(code.strip))}</code></pre>
107
+ </div>
108
+ HTML
109
+ end
110
+
102
111
  end
103
112
 
104
113
  class Template
@@ -157,7 +166,7 @@ module RTFDoc
157
166
  parse_metadata(YAML.load(raw_content.slice!(0, idx + 3)))
158
167
  end
159
168
 
160
- raise 'missing metadata' if resource && !@path && !@method
169
+ raise 'missing metadata' if resource && !meta_section? && !@path && !@method
161
170
 
162
171
  @content, @example = raw_content.split('$$$')
163
172
  end
@@ -179,17 +188,28 @@ module RTFDoc
179
188
  end
180
189
 
181
190
  def signature
182
- sig = <<-HTML.strip!
191
+ anchor(sig)
192
+ end
193
+
194
+ def example_to_html
195
+ res = super
196
+ @resource && res && !meta_section? ? res.sub('RESPONSE', sig) : res
197
+ end
198
+
199
+ private
200
+
201
+ def sig
202
+ @sig ||= <<-HTML.strip!
183
203
  <div class="endpoint-def">
184
204
  <div class="method method__#{method.downcase}">#{method.upcase}</div>
185
205
  <div class="path">#{path}</div>
186
206
  </div>
187
207
  HTML
188
-
189
- anchor(sig)
190
208
  end
191
209
 
192
- private
210
+ def meta_section?
211
+ name == 'desc' || name == 'object'
212
+ end
193
213
 
194
214
  def menu_title
195
215
  @menu_title || name.capitalize
@@ -1,3 +1,3 @@
1
1
  module RTFDoc
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -29,14 +29,19 @@
29
29
  --endpoints-line-height: 22px;
30
30
  --table-font-size: 14px;
31
31
  --table-line-height: 18px;
32
- --code-font-size: 14px; }
32
+ --code-font-size: 14px;
33
+ }
33
34
 
34
35
  * {
35
36
  box-sizing: border-box;
36
- word-wrap: break-word; }
37
+ word-wrap: break-word;
38
+ -moz-osx-font-smoothing: grayscale;
39
+ -webkit-font-smoothing: antialiased;
40
+ }
37
41
 
38
42
  html {
39
- overflow: auto; }
43
+ overflow: auto;
44
+ }
40
45
 
41
46
  body {
42
47
  margin: 0;
@@ -46,7 +51,9 @@ body {
46
51
  overflow-y: scroll;
47
52
  max-width: 100%;
48
53
  -moz-osx-font-smoothing: grayscale;
49
- background-color: var(--background-color); }
54
+ -webkit-font-smoothing: antialiased;
55
+ background-color: var(--background-color);
56
+ }
50
57
 
51
58
  body[data-theme="dark"] {
52
59
  --background-color: var(--sail-gray900);
@@ -79,7 +86,8 @@ body[data-theme="dark"] {
79
86
  --code-numbers: #56b6c2;
80
87
  --code-booleans: #d19a66;
81
88
  --child-list-title-color: var(--sail-gray500);
82
- --child-list-title-hover-color: var(--sail-gray100); }
89
+ --child-list-title-hover-color: var(--sail-gray100);
90
+ }
83
91
 
84
92
  body[data-theme="light"] {
85
93
  --background-color: #fff;
@@ -112,7 +120,8 @@ body[data-theme="light"] {
112
120
  --code-numbers: #005cc5;
113
121
  --code--booleans: #e36209;
114
122
  --child-list-title-color: #586069;
115
- --child-list-title-hover-color: #24292e; }
123
+ --child-list-title-hover-color: #24292e;
124
+ }
116
125
 
117
126
  #sidebar {
118
127
  width: var(--sidebar-width);
@@ -122,20 +131,24 @@ body[data-theme="light"] {
122
131
  left: 0;
123
132
  bottom: 0;
124
133
  z-index: 10;
125
- box-shadow: -1px 0 0 0 var(--divider-color) inset; }
134
+ box-shadow: -1px 0 0 0 var(--divider-color) inset;
135
+ }
126
136
 
127
137
  .sidebar-header {
128
138
  color: var(--nav-header-color);
129
139
  padding: 16px;
130
140
  display: flex;
131
141
  flex-direction: row;
132
- justify-content: space-between; }
133
- .sidebar-header .sidebar-title {
142
+ justify-content: space-between;
143
+ .sidebar-title {
134
144
  font-size: 15px;
135
- line-height: 20px; }
136
- .sidebar-header .api {
145
+ line-height: 20px;
146
+ }
147
+ .api {
137
148
  text-transform: uppercase;
138
- color: var(--brand-color); }
149
+ color: var(--brand-color);
150
+ }
151
+ }
139
152
 
140
153
  .sidebar-nav {
141
154
  margin-top: 16px; }
@@ -330,59 +343,81 @@ ul {
330
343
  .section-response {
331
344
  background: var(--response-background-color);
332
345
  border-radius: 8px;
333
- box-shadow: 0 0 0 1px var(--response-shadow-color); }
334
- .section-response .response-topbar {
346
+ box-shadow: 0 0 0 1px var(--response-shadow-color);
347
+ max-height: 83vh;
348
+ overflow-y: auto;
349
+
350
+ .response-topbar {
335
351
  background: var(--block-header-background-color);
336
352
  padding: 10px 12px;
337
353
  font-weight: 500;
338
354
  font-size: 12px;
339
355
  color: var(--response-header-color);
340
- border-radius: 8px 8px 0 0; }
341
- .section-response p {
356
+ border-radius: 8px 8px 0 0;
357
+ text-transform: uppercase;
358
+
359
+ .endpoint-def .method { width: auto }
360
+ }
361
+
362
+ p {
342
363
  margin: 0;
343
- padding: 12px var(--sp20); }
344
- .section-response pre {
364
+ padding: 12px var(--sp20);
365
+ }
366
+
367
+ pre {
345
368
  margin: 0;
346
369
  padding: 12px;
347
370
  color: var(--code-color);
348
371
  font-family: var(--monospace-font);
349
372
  font-size: var(--code-font-size);
350
373
  font-weight: 400;
351
- line-height: 18px; }
374
+ line-height: 18px;
375
+ }
376
+ }
352
377
 
353
- .section-endpoints {
354
- padding: 12px 22px; }
355
- .section-endpoints .endpoint-def {
356
- display: flex;
357
- flex-direction: row;
358
- font-family: var(--monospace-font);
359
- font-size: var(--code-font-size);
360
- font-weight: 500;
361
- line-height: 22px;
362
- color: var(--endpoints-def-color); }
363
- .section-endpoints .method {
378
+ .endpoint-def {
379
+ display: flex;
380
+ flex-direction: row;
381
+ font-family: var(--monospace-font);
382
+ font-size: var(--code-font-size);
383
+ font-weight: 500;
384
+ line-height: 22px;
385
+ color: var(--endpoints-def-color);
386
+
387
+ .method {
364
388
  text-align: right;
365
389
  width: 55px;
366
- margin-right: 7px; }
367
- .section-endpoints .method__get {
368
- color: var(--sail-blue400); }
369
- .section-endpoints .method__post {
370
- color: #50b573; }
371
- .section-endpoints .method__patch,
372
- .section-endpoints .method__put {
373
- color: #50b573; }
374
- .section-endpoints .method__delete {
375
- color: var(--redish); }
376
- .section-endpoints a {
377
- text-decoration: none; }
378
- .section-endpoints a:hover .method {
379
- filter: brightness(calc(100% + var(--filter-ratio))); }
380
- .section-endpoints a:hover .path {
381
- color: var(--endpoints-def-hover-color); }
390
+ margin-right: 7px;
391
+ text-transform: uppercase;
392
+ }
393
+
394
+ .path { text-transform: none }
395
+
396
+ .method__get { color: var(--sail-blue400); }
397
+ .method__post { color: #50b573; }
398
+ .method__patch,
399
+ .method__put {
400
+ color: #50b573;
401
+ }
402
+ .method__delete { color: var(--redish); }
403
+ }
404
+
405
+ .section-endpoints {
406
+ padding: 12px 22px;
407
+
408
+ a { text-decoration: none; }
409
+ a:hover .method {
410
+ filter: brightness(calc(100% + var(--filter-ratio)));
411
+ }
412
+ a:hover .path {
413
+ color: var(--endpoints-def-hover-color);
414
+ }
415
+ }
382
416
 
383
417
  h3 {
384
418
  margin-top: 20px;
385
- padding-top: 16px; }
419
+ padding-top: 16px;
420
+ }
386
421
 
387
422
  h3,
388
423
  .section-list .section-list-title {
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rtfdoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - ccocchi