docwatch-bin 2.1.2 → 2.2.0
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 +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 +205 -98
- 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,167 +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
|
|
43
|
+
}
|
|
44
|
+
|
|
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
|
|
37
61
|
}
|
|
38
62
|
|
|
39
63
|
h1,
|
|
40
64
|
h2,
|
|
41
|
-
|
|
42
|
-
|
|
65
|
+
h3,
|
|
66
|
+
h4,
|
|
67
|
+
h5,
|
|
68
|
+
h6 {
|
|
69
|
+
margin-top: 24px;
|
|
70
|
+
margin-bottom: 16px;
|
|
71
|
+
font-weight: 600;
|
|
72
|
+
line-height: 1.25
|
|
43
73
|
}
|
|
44
74
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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
|
|
48
88
|
}
|
|
49
89
|
|
|
50
|
-
|
|
51
|
-
|
|
90
|
+
h1 {
|
|
91
|
+
font-size: 2em
|
|
52
92
|
}
|
|
53
93
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
padding: 0;
|
|
94
|
+
h1,
|
|
95
|
+
h2 {
|
|
96
|
+
padding-bottom: .3em;
|
|
97
|
+
border-bottom: 1px solid #eaecef
|
|
59
98
|
}
|
|
60
99
|
|
|
61
|
-
|
|
62
|
-
font-
|
|
63
|
-
border: 1px solid #CBE7F6;
|
|
64
|
-
padding: 0.6rem;
|
|
65
|
-
padding-left: 1rem;
|
|
66
|
-
overflow: auto;
|
|
67
|
-
word-wrap: normal;
|
|
100
|
+
h2 {
|
|
101
|
+
font-size: 1.5em
|
|
68
102
|
}
|
|
69
103
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
background-color: #eef7fc;
|
|
73
|
-
font-family: monospace;
|
|
74
|
-
font-size: 13px;
|
|
104
|
+
h3 {
|
|
105
|
+
font-size: 1.25em
|
|
75
106
|
}
|
|
76
107
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
padding: 2px;
|
|
80
|
-
padding-left: 4px;
|
|
81
|
-
white-space: nowrap;
|
|
108
|
+
h4 {
|
|
109
|
+
font-size: 1em
|
|
82
110
|
}
|
|
83
111
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
font-style: italic;
|
|
87
|
-
overflow-x: auto;
|
|
88
|
-
margin: 0;
|
|
89
|
-
padding: 0.6rem;
|
|
90
|
-
padding-left: 1rem;
|
|
91
|
-
background-color: #eef7fc;
|
|
112
|
+
h5 {
|
|
113
|
+
font-size: .875em
|
|
92
114
|
}
|
|
93
115
|
|
|
94
|
-
|
|
95
|
-
|
|
116
|
+
h6 {
|
|
117
|
+
font-size: .85em;
|
|
118
|
+
color: #6a737d
|
|
96
119
|
}
|
|
97
120
|
|
|
98
|
-
|
|
99
|
-
|
|
121
|
+
ol,
|
|
122
|
+
ul {
|
|
123
|
+
padding-left: 2em
|
|
100
124
|
}
|
|
101
125
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
126
|
+
ol.no-list,
|
|
127
|
+
ul.no-list {
|
|
128
|
+
padding: 0;
|
|
129
|
+
list-style-type: none
|
|
130
|
+
}
|
|
105
131
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
.highlight .kc,
|
|
113
|
-
.highlight .kt,
|
|
114
|
-
.highlight .kv {
|
|
115
|
-
color: #0000b3;
|
|
132
|
+
ol ol,
|
|
133
|
+
ol ul,
|
|
134
|
+
ul ol,
|
|
135
|
+
ul ul {
|
|
136
|
+
margin-top: 0;
|
|
137
|
+
margin-bottom: 0
|
|
116
138
|
}
|
|
117
139
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
.highlight .sa,
|
|
121
|
-
.highlight .se,
|
|
122
|
-
.highlight .sb,
|
|
123
|
-
.highlight .sc,
|
|
124
|
-
.highlight .dl,
|
|
125
|
-
.highlight .sd,
|
|
126
|
-
.highlight .s2,
|
|
127
|
-
.highlight .sh,
|
|
128
|
-
.highlight .sx,
|
|
129
|
-
.highlight .s1 {
|
|
130
|
-
color: #b30000;
|
|
140
|
+
li {
|
|
141
|
+
word-wrap: break-all
|
|
131
142
|
}
|
|
132
143
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
.highlight .cm,
|
|
136
|
-
.highlight .c1,
|
|
137
|
-
.highlight .cs {
|
|
138
|
-
color: green;
|
|
144
|
+
li>p {
|
|
145
|
+
margin-top: 16px
|
|
139
146
|
}
|
|
140
147
|
|
|
148
|
+
li+li {
|
|
149
|
+
margin-top: .25em
|
|
150
|
+
}
|
|
151
|
+
|
|
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
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
dl dd {
|
|
165
|
+
padding: 0 16px;
|
|
166
|
+
margin-bottom: 16px
|
|
167
|
+
}
|
|
141
168
|
|
|
142
169
|
table {
|
|
170
|
+
display: block;
|
|
143
171
|
width: 100%;
|
|
172
|
+
overflow: auto
|
|
144
173
|
}
|
|
145
174
|
|
|
146
175
|
table th {
|
|
147
|
-
font-weight: 600
|
|
176
|
+
font-weight: 600
|
|
148
177
|
}
|
|
149
178
|
|
|
150
179
|
table td,
|
|
151
180
|
table th {
|
|
152
181
|
padding: 6px 13px;
|
|
153
|
-
border: 1px solid #dfe2e5
|
|
182
|
+
border: 1px solid #dfe2e5
|
|
154
183
|
}
|
|
155
184
|
|
|
156
185
|
table tr {
|
|
157
186
|
background-color: #fff;
|
|
158
|
-
border-top: 1px solid #c6cbd1
|
|
187
|
+
border-top: 1px solid #c6cbd1
|
|
159
188
|
}
|
|
160
189
|
|
|
161
190
|
table tr:nth-child(2n) {
|
|
162
|
-
background-color: #f6f8fa
|
|
191
|
+
background-color: #f6f8fa
|
|
163
192
|
}
|
|
164
193
|
|
|
165
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;
|
|
166
272
|
background-color: initial;
|
|
273
|
+
border: 0
|
|
167
274
|
}
|