docwatch-bin 2.1.3 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/docwatch +9 -11
- data/lib/docwatch/renderer/markdown.rb +18 -2
- data/lib/docwatch/renderer.rb +4 -3
- data/lib/docwatch/version.rb +1 -1
- data/res/styles.css +202 -100
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b4c55f23d291bc317c8b3da127549ae74d8a1307368c040efe016a9d350d678
|
4
|
+
data.tar.gz: efedeb51bdfdbc88735f1c63f720becd91d9a68305654473ad0c7104214b129a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc65417b707be0b65bca16f28ce072cc4765802ca77bdd34517715dd71d5f92edd07b9dea9e87fdfedf183096fda5c2fed71fe22aaf623be3d9635bbc940b553
|
7
|
+
data.tar.gz: c390dbd697f8f138de53e06a550f23d1ef4f96c7d67dbb21031b1935b391731299c55375176d197f0c091f8f6308334d04ba499367497f3faad34cda4cf942ff
|
data/bin/docwatch
CHANGED
@@ -6,6 +6,7 @@ Params = Struct.new(
|
|
6
6
|
:verbose,
|
7
7
|
:version,
|
8
8
|
:file_path,
|
9
|
+
:default_styles,
|
9
10
|
keyword_init: true,
|
10
11
|
)
|
11
12
|
|
@@ -23,6 +24,7 @@ class Main
|
|
23
24
|
verbose: @opts['--verbose'],
|
24
25
|
version: @opts['--version'],
|
25
26
|
file_path: @opts['<file-path>'],
|
27
|
+
default_styles: @opts['--default-styles'],
|
26
28
|
)
|
27
29
|
end
|
28
30
|
|
@@ -67,7 +69,7 @@ class Main
|
|
67
69
|
exit_invalid_file unless File.exist?(params.file_path)
|
68
70
|
exit_invalid_port unless port_valid
|
69
71
|
|
70
|
-
renderer = Renderer.by_filetype(params.file_path)
|
72
|
+
renderer = Renderer.by_filetype(params.file_path, params.default_styles)
|
71
73
|
exit_unknown_renderer if renderer.nil?
|
72
74
|
|
73
75
|
server = TCPServer.new(port)
|
@@ -108,20 +110,16 @@ usage = <<~EOF
|
|
108
110
|
#{PROGRAM_NAME} ( --version | --help )
|
109
111
|
|
110
112
|
Options:
|
111
|
-
-p, --port
|
112
|
-
|
113
|
-
-
|
114
|
-
|
113
|
+
-p, --port VALUE Listen port [default: 8888]
|
114
|
+
Set to 'random' for a random port
|
115
|
+
-d, --default-styles Use default styling
|
116
|
+
--verbose Be verbose
|
117
|
+
-v, --version Show version
|
118
|
+
-h, --help Show help
|
115
119
|
|
116
120
|
Renderers:
|
117
121
|
markdown (.md)
|
118
122
|
html (.html)
|
119
|
-
|
120
|
-
If #{'--port'.bold} is #{'random'.bold} a random port will be chosen, otherwise the specified
|
121
|
-
one will be used. The default is 8888.
|
122
|
-
|
123
|
-
In #{'--verbose'.bold} mode, incoming HTTP requests and file change event notifications will be
|
124
|
-
printed to standard output.
|
125
123
|
EOF
|
126
124
|
|
127
125
|
begin
|
@@ -7,10 +7,26 @@ module Docwatch
|
|
7
7
|
include Rouge::Plugins::Redcarpet
|
8
8
|
end
|
9
9
|
|
10
|
+
def default_css
|
11
|
+
File.read(Docwatch.root_dir + '/res/styles.css')
|
12
|
+
end
|
13
|
+
|
14
|
+
def css
|
15
|
+
return default_css if @default_styles
|
16
|
+
|
17
|
+
config_dir = ENV.fetch('XDG_CONFIG_HOME', File.expand_path('~/.config'))
|
18
|
+
styles_path = File.join(config_dir, 'docwatch', 'styles.css')
|
19
|
+
|
20
|
+
if File.exist?(styles_path)
|
21
|
+
File.read(styles_path)
|
22
|
+
else
|
23
|
+
default_css
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
10
27
|
def head
|
11
|
-
css = File.read(Docwatch.root_dir + '/res/styles.css')
|
12
28
|
return <<~EOF
|
13
|
-
<title>#{file_path}
|
29
|
+
<title>#{file_path} — docwatch</title>
|
14
30
|
<style>
|
15
31
|
#{css}
|
16
32
|
</style>
|
data/lib/docwatch/renderer.rb
CHANGED
@@ -7,15 +7,16 @@ module Docwatch
|
|
7
7
|
(@@extensions[sym] ||= []) << self
|
8
8
|
end
|
9
9
|
|
10
|
-
def self.by_filetype(file_path)
|
10
|
+
def self.by_filetype(file_path, default_styles)
|
11
11
|
extname = File.extname(file_path)[1..]
|
12
12
|
return if extname.length == 0
|
13
13
|
|
14
|
-
@@extensions[extname.to_sym].first.new(file_path)
|
14
|
+
@@extensions[extname.to_sym].first.new(file_path, default_styles)
|
15
15
|
end
|
16
16
|
|
17
|
-
def initialize(file_path)
|
17
|
+
def initialize(file_path, default_styles)
|
18
18
|
@file_path = file_path
|
19
|
+
@default_styles = default_styles
|
19
20
|
end
|
20
21
|
|
21
22
|
def js
|
data/lib/docwatch/version.rb
CHANGED
data/res/styles.css
CHANGED
@@ -1,172 +1,274 @@
|
|
1
|
-
* {
|
2
|
-
box-sizing: border-box;
|
3
|
-
}
|
4
|
-
|
5
1
|
body {
|
6
2
|
font-family: sans-serif;
|
7
3
|
font-size: 16px;
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
padding: 0.6rem;
|
4
|
+
line-height: 1.5;
|
5
|
+
word-wrap: break-word;
|
6
|
+
width: 900px;
|
12
7
|
margin: 0 auto;
|
13
8
|
}
|
14
9
|
|
15
|
-
a {
|
16
|
-
|
17
|
-
|
10
|
+
a:not([href]) {
|
11
|
+
color: inherit;
|
12
|
+
text-decoration: none
|
18
13
|
}
|
19
14
|
|
20
|
-
|
21
|
-
|
15
|
+
blockquote,
|
16
|
+
details,
|
17
|
+
dl,
|
18
|
+
ol,
|
19
|
+
p,
|
20
|
+
pre,
|
21
|
+
table,
|
22
|
+
ul {
|
23
|
+
margin-top: 0;
|
24
|
+
margin-bottom: 16px
|
22
25
|
}
|
23
26
|
|
24
27
|
hr {
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
28
|
+
height: .25em;
|
29
|
+
padding: 0;
|
30
|
+
margin: 24px 0;
|
31
|
+
background-color: #e1e4e8;
|
32
|
+
border: 0
|
29
33
|
}
|
30
34
|
|
31
|
-
|
32
|
-
|
35
|
+
blockquote {
|
36
|
+
padding: 0 1em;
|
37
|
+
color: #6a737d;
|
38
|
+
border-left: .25em solid #dfe2e5
|
33
39
|
}
|
34
40
|
|
35
|
-
|
36
|
-
|
41
|
+
blockquote>:first-child {
|
42
|
+
margin-top: 0
|
37
43
|
}
|
38
44
|
|
39
|
-
|
40
|
-
|
45
|
+
blockquote>:last-child {
|
46
|
+
margin-bottom: 0
|
47
|
+
}
|
48
|
+
|
49
|
+
kbd {
|
50
|
+
display: inline-block;
|
51
|
+
padding: 3px 5px;
|
52
|
+
font-size: 11px;
|
53
|
+
line-height: 10px;
|
54
|
+
color: #444d56;
|
55
|
+
vertical-align: middle;
|
56
|
+
background-color: #fafbfc;
|
57
|
+
border: 1px solid #c6cbd1;
|
58
|
+
border-bottom-color: #959da5;
|
59
|
+
border-radius: 3px;
|
60
|
+
box-shadow: inset 0 -1px 0 #959da5
|
41
61
|
}
|
42
62
|
|
43
63
|
h1,
|
44
64
|
h2,
|
45
65
|
h3,
|
46
|
-
|
47
|
-
|
66
|
+
h4,
|
67
|
+
h5,
|
68
|
+
h6 {
|
69
|
+
margin-top: 24px;
|
70
|
+
margin-bottom: 16px;
|
71
|
+
font-weight: 600;
|
72
|
+
line-height: 1.25
|
48
73
|
}
|
49
74
|
|
50
|
-
|
51
|
-
|
52
|
-
|
75
|
+
h1 code,
|
76
|
+
h1 tt,
|
77
|
+
h2 code,
|
78
|
+
h2 tt,
|
79
|
+
h3 code,
|
80
|
+
h3 tt,
|
81
|
+
h4 code,
|
82
|
+
h4 tt,
|
83
|
+
h5 code,
|
84
|
+
h5 tt,
|
85
|
+
h6 code,
|
86
|
+
h6 tt {
|
87
|
+
font-size: inherit
|
53
88
|
}
|
54
89
|
|
55
|
-
|
56
|
-
|
90
|
+
h1 {
|
91
|
+
font-size: 2em
|
57
92
|
}
|
58
93
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
padding: 0;
|
94
|
+
h1,
|
95
|
+
h2 {
|
96
|
+
padding-bottom: .3em;
|
97
|
+
border-bottom: 1px solid #eaecef
|
64
98
|
}
|
65
99
|
|
66
|
-
|
67
|
-
font-
|
68
|
-
border: 1px solid #CBE7F6;
|
69
|
-
padding: 0.6rem;
|
70
|
-
padding-left: 1rem;
|
71
|
-
overflow: auto;
|
72
|
-
word-wrap: normal;
|
100
|
+
h2 {
|
101
|
+
font-size: 1.5em
|
73
102
|
}
|
74
103
|
|
75
|
-
|
76
|
-
|
77
|
-
background-color: #eef7fc;
|
78
|
-
font-family: monospace;
|
79
|
-
font-size: 13px;
|
104
|
+
h3 {
|
105
|
+
font-size: 1.25em
|
80
106
|
}
|
81
107
|
|
82
|
-
|
83
|
-
|
84
|
-
padding: 2px;
|
85
|
-
padding-left: 4px;
|
86
|
-
white-space: nowrap;
|
108
|
+
h4 {
|
109
|
+
font-size: 1em
|
87
110
|
}
|
88
111
|
|
89
|
-
|
90
|
-
|
91
|
-
font-style: italic;
|
92
|
-
overflow-x: auto;
|
93
|
-
margin: 0;
|
94
|
-
padding: 0.6rem;
|
95
|
-
padding-left: 1rem;
|
96
|
-
background-color: #eef7fc;
|
112
|
+
h5 {
|
113
|
+
font-size: .875em
|
97
114
|
}
|
98
115
|
|
99
|
-
|
100
|
-
|
116
|
+
h6 {
|
117
|
+
font-size: .85em;
|
118
|
+
color: #6a737d
|
101
119
|
}
|
102
120
|
|
103
|
-
|
104
|
-
|
121
|
+
ol,
|
122
|
+
ul {
|
123
|
+
padding-left: 2em
|
105
124
|
}
|
106
125
|
|
107
|
-
|
108
|
-
|
109
|
-
|
126
|
+
ol.no-list,
|
127
|
+
ul.no-list {
|
128
|
+
padding: 0;
|
129
|
+
list-style-type: none
|
130
|
+
}
|
131
|
+
|
132
|
+
ol ol,
|
133
|
+
ol ul,
|
134
|
+
ul ol,
|
135
|
+
ul ul {
|
136
|
+
margin-top: 0;
|
137
|
+
margin-bottom: 0
|
138
|
+
}
|
139
|
+
|
140
|
+
li {
|
141
|
+
word-wrap: break-all
|
142
|
+
}
|
110
143
|
|
111
|
-
|
112
|
-
|
113
|
-
.highlight .kn,
|
114
|
-
.highlight .kd,
|
115
|
-
.highlight .kp,
|
116
|
-
.highlight .kr,
|
117
|
-
.highlight .kc,
|
118
|
-
.highlight .kt,
|
119
|
-
.highlight .kv {
|
120
|
-
color: #0000b3;
|
144
|
+
li>p {
|
145
|
+
margin-top: 16px
|
121
146
|
}
|
122
147
|
|
123
|
-
|
124
|
-
|
125
|
-
.highlight .sa,
|
126
|
-
.highlight .se,
|
127
|
-
.highlight .sb,
|
128
|
-
.highlight .sc,
|
129
|
-
.highlight .dl,
|
130
|
-
.highlight .sd,
|
131
|
-
.highlight .s2,
|
132
|
-
.highlight .sh,
|
133
|
-
.highlight .sx,
|
134
|
-
.highlight .s1 {
|
135
|
-
color: #b30000;
|
148
|
+
li+li {
|
149
|
+
margin-top: .25em
|
136
150
|
}
|
137
151
|
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
152
|
+
dl {
|
153
|
+
padding: 0
|
154
|
+
}
|
155
|
+
|
156
|
+
dl dt {
|
157
|
+
padding: 0;
|
158
|
+
margin-top: 16px;
|
159
|
+
font-size: 1em;
|
160
|
+
font-style: italic;
|
161
|
+
font-weight: 600
|
144
162
|
}
|
145
163
|
|
164
|
+
dl dd {
|
165
|
+
padding: 0 16px;
|
166
|
+
margin-bottom: 16px
|
167
|
+
}
|
146
168
|
|
147
169
|
table {
|
170
|
+
display: block;
|
148
171
|
width: 100%;
|
172
|
+
overflow: auto
|
149
173
|
}
|
150
174
|
|
151
175
|
table th {
|
152
|
-
font-weight: 600
|
176
|
+
font-weight: 600
|
153
177
|
}
|
154
178
|
|
155
179
|
table td,
|
156
180
|
table th {
|
157
181
|
padding: 6px 13px;
|
158
|
-
border: 1px solid #dfe2e5
|
182
|
+
border: 1px solid #dfe2e5
|
159
183
|
}
|
160
184
|
|
161
185
|
table tr {
|
162
186
|
background-color: #fff;
|
163
|
-
border-top: 1px solid #c6cbd1
|
187
|
+
border-top: 1px solid #c6cbd1
|
164
188
|
}
|
165
189
|
|
166
190
|
table tr:nth-child(2n) {
|
167
|
-
background-color: #f6f8fa
|
191
|
+
background-color: #f6f8fa
|
168
192
|
}
|
169
193
|
|
170
194
|
table img {
|
195
|
+
background-color: initial
|
196
|
+
}
|
197
|
+
|
198
|
+
img {
|
199
|
+
max-width: 100%;
|
200
|
+
box-sizing: initial;
|
201
|
+
background-color: #fff
|
202
|
+
}
|
203
|
+
|
204
|
+
img[align=right] {
|
205
|
+
padding-left: 20px
|
206
|
+
}
|
207
|
+
|
208
|
+
img[align=left] {
|
209
|
+
padding-right: 20px
|
210
|
+
}
|
211
|
+
|
212
|
+
code,
|
213
|
+
tt {
|
214
|
+
padding: .2em .4em;
|
215
|
+
margin: 0;
|
216
|
+
font-size: 85%;
|
217
|
+
background-color: rgba(27, 31, 35, .05);
|
218
|
+
border-radius: 3px
|
219
|
+
}
|
220
|
+
|
221
|
+
code br,
|
222
|
+
tt br {
|
223
|
+
display: none
|
224
|
+
}
|
225
|
+
|
226
|
+
del code {
|
227
|
+
text-decoration: inherit
|
228
|
+
}
|
229
|
+
|
230
|
+
pre {
|
231
|
+
word-wrap: normal
|
232
|
+
}
|
233
|
+
|
234
|
+
pre>code {
|
235
|
+
padding: 0;
|
236
|
+
margin: 0;
|
237
|
+
font-size: 100%;
|
238
|
+
word-break: normal;
|
239
|
+
white-space: pre;
|
240
|
+
background: transparent;
|
241
|
+
border: 0
|
242
|
+
}
|
243
|
+
|
244
|
+
.highlight {
|
245
|
+
margin-bottom: 16px
|
246
|
+
}
|
247
|
+
|
248
|
+
.highlight pre {
|
249
|
+
margin-bottom: 0;
|
250
|
+
word-break: normal
|
251
|
+
}
|
252
|
+
|
253
|
+
.highlight pre,
|
254
|
+
pre {
|
255
|
+
padding: 16px;
|
256
|
+
overflow: auto;
|
257
|
+
font-size: 85%;
|
258
|
+
line-height: 1.45;
|
259
|
+
background-color: #f6f8fa;
|
260
|
+
border-radius: 3px
|
261
|
+
}
|
262
|
+
|
263
|
+
pre code,
|
264
|
+
pre tt {
|
265
|
+
display: inline;
|
266
|
+
max-width: auto;
|
267
|
+
padding: 0;
|
268
|
+
margin: 0;
|
269
|
+
overflow: visible;
|
270
|
+
line-height: inherit;
|
271
|
+
word-wrap: normal;
|
171
272
|
background-color: initial;
|
273
|
+
border: 0
|
172
274
|
}
|