History

Update Redis documentation (7.0.8)

Fixes #1873.

Simon Legner committed 3 years ago

Commit 993ac991 parent e1dbdf53 files · +518 −24Browse files

Showing the changes to lib/docs (3 of 3 files). Show all

Unified · Split

3 files
  1. lib/docs/filters/redis/clean_html.rb +8 −2
  2. lib/docs/filters/redis/entries.rb +499 −19
  3. lib/docs/scrapers/redis.rb +11 −3
lib/docs/filters/redis/clean_html.rb+8−2
@@ -3,14 +3,20 @@ module Docs · 2 unmodified lines
3 class CleanHtmlFilter < Filter3 class CleanHtmlFilter < Filter
4 def call4 def call
5 if root_page?5 if root_page?
6 at_css('ul')['class'] = 'commands'6 if root_page?
7 slug_types = {}
8 css('article[data-group]').each do |node|
9 slug_types[node.at_css('a')['href']] = node['data-group']
10 end
11 # binding.pry
12 end
7 else13 else
8 title = at_css('h1')14 title = at_css('h1')
9 title.after("<pre>#{title.content.strip}</pre>")15 title.after("<pre>#{title.content.strip}</pre>")
10 title.content = title.content.split(' ').first16 title.content = title.content.split(' ').first
11 end17 end
12 18
13 css('nav', 'aside', 'form', '.anchor-link').remove19 css('nav', 'aside', '.page-feedback', '.anchor-link').remove
14 20
15 css('> article', '.article-main', 'pre > code', '.container').each do |node|21 css('> article', '.article-main', 'pre > code', '.container').each do |node|
16 node.before(node.children).remove22 node.before(node.children).remove
lib/docs/filters/redis/entries.rb+499−19
@@ -1,30 +1,510 @@
1module Docs1module Docs
2 class Redis2 class Redis
3 class EntriesFilter < Docs::EntriesFilter3 class EntriesFilter < Docs::EntriesFilter
4
4 def get_name5 def get_name
5 slug.gsub('-', ' ')6 slug.gsub('-', ' ').remove('/')
6 end7 end
7 8
8 def get_type9 def get_type
9 case at_css('aside > ul:last-child a').content.strip10 SLUG_NAMES[SLUG_TYPES[slug]]
10 when 'DEL' then 'Keys'
11 when 'APPEND' then 'Strings'
12 when 'HDEL' then 'Hashes'
13 when 'BLPOP' then 'Lists'
14 when 'SADD' then 'Sets'
15 when 'BZPOPMAX' then 'Sorted Sets'
16 when 'PSUBSCRIBE' then 'Pub/Sub'
17 when 'DISCARD' then 'Transactions'
18 when 'EVAL' then 'Scripting'
19 when 'AUTH' then 'Connection'
20 when 'BGREWRITEAOF' then 'Server'
21 when 'PFADD' then 'HyperLogLog'
22 when 'CLUSTER ADDSLOTS' then 'Cluster'
23 when 'GEOADD' then 'Geo'
24 when 'XACK' then 'Stream'
25 else 'Miscellaneous'
26 end
27 end11 end
12
13 # obtain from https://redis.io/commands/ via lib/docs/filters/redis/clean_html.rb using `binding.pry`
14 SLUG_TYPES = {
15 "acl-cat/" => "server",
16 "acl-deluser/" => "server",
17 "acl-dryrun/" => "server",
18 "acl-genpass/" => "server",
19 "acl-getuser/" => "server",
20 "acl-list/" => "server",
21 "acl-load/" => "server",
22 "acl-log/" => "server",
23 "acl-save/" => "server",
24 "acl-setuser/" => "server",
25 "acl-users/" => "server",
26 "acl-whoami/" => "server",
27 "append/" => "string",
28 "asking/" => "cluster",
29 "auth/" => "connection",
30 "bf.add/" => "bf",
31 "bf.card/" => "bf",
32 "bf.exists/" => "bf",
33 "bf.info/" => "bf",
34 "bf.insert/" => "bf",
35 "bf.loadchunk/" => "bf",
36 "bf.madd/" => "bf",
37 "bf.mexists/" => "bf",
38 "bf.reserve/" => "bf",
39 "bf.scandump/" => "bf",
40 "bgrewriteaof/" => "server",
41 "bgsave/" => "server",
42 "bitcount/" => "bitmap",
43 "bitfield/" => "bitmap",
44 "bitfield_ro/" => "bitmap",
45 "bitop/" => "bitmap",
46 "bitpos/" => "bitmap",
47 "blmove/" => "list",
48 "blmpop/" => "list",
49 "blpop/" => "list",
50 "brpop/" => "list",
51 "brpoplpush/" => "list",
52 "bzmpop/" => "sorted-set",
53 "bzpopmax/" => "sorted-set",
54 "bzpopmin/" => "sorted-set",
55 "cf.add/" => "cf",
56 "cf.addnx/" => "cf",
57 "cf.count/" => "cf",
58 "cf.del/" => "cf",
59 "cf.exists/" => "cf",
60 "cf.info/" => "cf",
61 "cf.insert/" => "cf",
62 "cf.insertnx/" => "cf",
63 "cf.loadchunk/" => "cf",
64 "cf.mexists/" => "cf",
65 "cf.reserve/" => "cf",
66 "cf.scandump/" => "cf",
67 "client-caching/" => "connection",
68 "client-getname/" => "connection",
69 "client-getredir/" => "connection",
70 "client-id/" => "connection",
71 "client-info/" => "connection",
72 "client-kill/" => "connection",
73 "client-list/" => "connection",
74 "client-no-evict/" => "connection",
75 "client-pause/" => "connection",
76 "client-reply/" => "connection",
77 "client-setname/" => "connection",
78 "client-tracking/" => "connection",
79 "client-trackinginfo/" => "connection",
80 "client-unblock/" => "connection",
81 "client-unpause/" => "connection",
82 "cluster-addslots/" => "cluster",
83 "cluster-addslotsrange/" => "cluster",
84 "cluster-bumpepoch/" => "cluster",
85 "cluster-count-failure-reports/" => "cluster",
86 "cluster-countkeysinslot/" => "cluster",
87 "cluster-delslots/" => "cluster",
88 "cluster-delslotsrange/" => "cluster",
89 "cluster-failover/" => "cluster",
90 "cluster-flushslots/" => "cluster",
91 "cluster-forget/" => "cluster",
92 "cluster-getkeysinslot/" => "cluster",
93 "cluster-info/" => "cluster",
94 "cluster-keyslot/" => "cluster",
95 "cluster-links/" => "cluster",
96 "cluster-meet/" => "cluster",
97 "cluster-myid/" => "cluster",
98 "cluster-nodes/" => "cluster",
99 "cluster-replicas/" => "cluster",
100 "cluster-replicate/" => "cluster",
101 "cluster-reset/" => "cluster",
102 "cluster-saveconfig/" => "cluster",
103 "cluster-set-config-epoch/" => "cluster",
104 "cluster-setslot/" => "cluster",
105 "cluster-shards/" => "cluster",
106 "cluster-slaves/" => "cluster",
107 "cluster-slots/" => "cluster",
108 "cms.incrby/" => "cms",
109 "cms.info/" => "cms",
110 "cms.initbydim/" => "cms",
111 "cms.initbyprob/" => "cms",
112 "cms.merge/" => "cms",
113 "cms.query/" => "cms",
114 "command/" => "server",
115 "command-count/" => "server",
116 "command-docs/" => "server",
117 "command-getkeys/" => "server",
118 "command-getkeysandflags/" => "server",
119 "command-info/" => "server",
120 "command-list/" => "server",
121 "config-get/" => "server",
122 "config-resetstat/" => "server",
123 "config-rewrite/" => "server",
124 "config-set/" => "server",
125 "copy/" => "generic",
126 "dbsize/" => "server",
127 "decr/" => "string",
128 "decrby/" => "string",
129 "del/" => "generic",
130 "discard/" => "transactions",
131 "dump/" => "generic",
132 "echo/" => "connection",
133 "eval/" => "scripting",
134 "eval_ro/" => "scripting",
135 "evalsha/" => "scripting",
136 "evalsha_ro/" => "scripting",
137 "exec/" => "transactions",
138 "exists/" => "generic",
139 "expire/" => "generic",
140 "expireat/" => "generic",
141 "expiretime/" => "generic",
142 "failover/" => "server",
143 "fcall/" => "scripting",
144 "fcall_ro/" => "scripting",
145 "flushall/" => "server",
146 "flushdb/" => "server",
147 "ft._list/" => "search",
148 "ft.aggregate/" => "search",
149 "ft.aliasadd/" => "search",
150 "ft.aliasdel/" => "search",
151 "ft.aliasupdate/" => "search",
152 "ft.alter/" => "search",
153 "ft.config-get/" => "search",
154 "ft.config-set/" => "search",
155 "ft.create/" => "search",
156 "ft.cursor-del/" => "search",
157 "ft.cursor-read/" => "search",
158 "ft.dictadd/" => "search",
159 "ft.dictdel/" => "search",
160 "ft.dictdump/" => "search",
161 "ft.dropindex/" => "search",
162 "ft.explain/" => "search",
163 "ft.explaincli/" => "search",
164 "ft.info/" => "search",
165 "ft.profile/" => "search",
166 "ft.search/" => "search",
167 "ft.spellcheck/" => "search",
168 "ft.sugadd/" => "suggestion",
169 "ft.sugdel/" => "suggestion",
170 "ft.sugget/" => "suggestion",
171 "ft.suglen/" => "suggestion",
172 "ft.syndump/" => "search",
173 "ft.synupdate/" => "search",
174 "ft.tagvals/" => "search",
175 "function-delete/" => "scripting",
176 "function-dump/" => "scripting",
177 "function-flush/" => "scripting",
178 "function-kill/" => "scripting",
179 "function-list/" => "scripting",
180 "function-load/" => "scripting",
181 "function-restore/" => "scripting",
182 "function-stats/" => "scripting",
183 "geoadd/" => "geo",
184 "geodist/" => "geo",
185 "geohash/" => "geo",
186 "geopos/" => "geo",
187 "georadius/" => "geo",
188 "georadius_ro/" => "geo",
189 "georadiusbymember/" => "geo",
190 "georadiusbymember_ro/" => "geo",
191 "geosearch/" => "geo",
192 "geosearchstore/" => "geo",
193 "get/" => "string",
194 "getbit/" => "bitmap",
195 "getdel/" => "string",
196 "getex/" => "string",
197 "getrange/" => "string",
198 "getset/" => "string",
199 "graph.config-get/" => "graph",
200 "graph.config-set/" => "graph",
201 "graph.delete/" => "graph",
202 "graph.explain/" => "graph",
203 "graph.list/" => "graph",
204 "graph.profile/" => "graph",
205 "graph.query/" => "graph",
206 "graph.ro_query/" => "graph",
207 "graph.slowlog/" => "graph",
208 "hdel/" => "hash",
209 "hello/" => "connection",
210 "hexists/" => "hash",
211 "hget/" => "hash",
212 "hgetall/" => "hash",
213 "hincrby/" => "hash",
214 "hincrbyfloat/" => "hash",
215 "hkeys/" => "hash",
216 "hlen/" => "hash",
217 "hmget/" => "hash",
218 "hmset/" => "hash",
219 "hrandfield/" => "hash",
220 "hscan/" => "hash",
221 "hset/" => "hash",
222 "hsetnx/" => "hash",
223 "hstrlen/" => "hash",
224 "hvals/" => "hash",
225 "incr/" => "string",
226 "incrby/" => "string",
227 "incrbyfloat/" => "string",
228 "info/" => "server",
229 "json.arrappend/" => "json",
230 "json.arrindex/" => "json",
231 "json.arrinsert/" => "json",
232 "json.arrlen/" => "json",
233 "json.arrpop/" => "json",
234 "json.arrtrim/" => "json",
235 "json.clear/" => "json",
236 "json.debug/" => "json",
237 "json.debug-memory/" => "json",
238 "json.del/" => "json",
239 "json.forget/" => "json",
240 "json.get/" => "json",
241 "json.mget/" => "json",
242 "json.numincrby/" => "json",
243 "json.nummultby/" => "json",
244 "json.objkeys/" => "json",
245 "json.objlen/" => "json",
246 "json.resp/" => "json",
247 "json.set/" => "json",
248 "json.strappend/" => "json",
249 "json.strlen/" => "json",
250 "json.toggle/" => "json",
251 "json.type/" => "json",
252 "keys/" => "generic",
253 "lastsave/" => "server",
254 "latency-doctor/" => "server",
255 "latency-graph/" => "server",
256 "latency-histogram/" => "server",
257 "latency-history/" => "server",
258 "latency-latest/" => "server",
259 "latency-reset/" => "server",
260 "lcs/" => "string",
261 "lindex/" => "list",
262 "linsert/" => "list",
263 "llen/" => "list",
264 "lmove/" => "list",
265 "lmpop/" => "list",
266 "lolwut/" => "server",
267 "lpop/" => "list",
268 "lpos/" => "list",
269 "lpush/" => "list",
270 "lpushx/" => "list",
271 "lrange/" => "list",
272 "lrem/" => "list",
273 "lset/" => "list",
274 "ltrim/" => "list",
275 "memory-doctor/" => "server",
276 "memory-malloc-stats/" => "server",
277 "memory-purge/" => "server",
278 "memory-stats/" => "server",
279 "memory-usage/" => "server",
280 "mget/" => "string",
281 "migrate/" => "generic",
282 "module-list/" => "server",
283 "module-load/" => "server",
284 "module-loadex/" => "server",
285 "module-unload/" => "server",
286 "monitor/" => "server",
287 "move/" => "generic",
288 "mset/" => "string",
289 "msetnx/" => "string",
290 "multi/" => "transactions",
291 "object-encoding/" => "generic",
292 "object-freq/" => "generic",
293 "object-idletime/" => "generic",
294 "object-refcount/" => "generic",
295 "persist/" => "generic",
296 "pexpire/" => "generic",
297 "pexpireat/" => "generic",
298 "pexpiretime/" => "generic",
299 "pfadd/" => "hyperloglog",
300 "pfcount/" => "hyperloglog",
301 "pfdebug/" => "hyperloglog",
302 "pfmerge/" => "hyperloglog",
303 "pfselftest/" => "hyperloglog",
304 "ping/" => "connection",
305 "psetex/" => "string",
306 "psubscribe/" => "pubsub",
307 "psync/" => "server",
308 "pttl/" => "generic",
309 "publish/" => "pubsub",
310 "pubsub-channels/" => "pubsub",
311 "pubsub-numpat/" => "pubsub",
312 "pubsub-numsub/" => "pubsub",
313 "pubsub-shardchannels/" => "pubsub",
314 "pubsub-shardnumsub/" => "pubsub",
315 "punsubscribe/" => "pubsub",
316 "quit/" => "connection",
317 "randomkey/" => "generic",
318 "readonly/" => "cluster",
319 "readwrite/" => "cluster",
320 "rename/" => "generic",
321 "renamenx/" => "generic",
322 "replconf/" => "server",
323 "replicaof/" => "server",
324 "reset/" => "connection",
325 "restore/" => "generic",
326 "restore-asking/" => "server",
327 "role/" => "server",
328 "rpop/" => "list",
329 "rpoplpush/" => "list",
330 "rpush/" => "list",
331 "rpushx/" => "list",
332 "sadd/" => "set",
333 "save/" => "server",
334 "scan/" => "generic",
335 "scard/" => "set",
336 "script-debug/" => "scripting",
337 "script-exists/" => "scripting",
338 "script-flush/" => "scripting",
339 "script-kill/" => "scripting",
340 "script-load/" => "scripting",
341 "sdiff/" => "set",
342 "sdiffstore/" => "set",
343 "select/" => "connection",
344 "set/" => "string",
345 "setbit/" => "bitmap",
346 "setex/" => "string",
347 "setnx/" => "string",
348 "setrange/" => "string",
349 "shutdown/" => "server",
350 "sinter/" => "set",
351 "sintercard/" => "set",
352 "sinterstore/" => "set",
353 "sismember/" => "set",
354 "slaveof/" => "server",
355 "slowlog-get/" => "server",
356 "slowlog-len/" => "server",
357 "slowlog-reset/" => "server",
358 "smembers/" => "set",
359 "smismember/" => "set",
360 "smove/" => "set",
361 "sort/" => "generic",
362 "sort_ro/" => "generic",
363 "spop/" => "set",
364 "spublish/" => "pubsub",
365 "srandmember/" => "set",
366 "srem/" => "set",
367 "sscan/" => "set",
368 "ssubscribe/" => "pubsub",
369 "strlen/" => "string",
370 "subscribe/" => "pubsub",
371 "substr/" => "string",
372 "sunion/" => "set",
373 "sunionstore/" => "set",
374 "sunsubscribe/" => "pubsub",
375 "swapdb/" => "server",
376 "sync/" => "server",
377 "tdigest.add/" => "tdigest",
378 "tdigest.byrank/" => "tdigest",
379 "tdigest.byrevrank/" => "tdigest",
380 "tdigest.cdf/" => "tdigest",
381 "tdigest.create/" => "tdigest",
382 "tdigest.info/" => "tdigest",
383 "tdigest.max/" => "tdigest",
384 "tdigest.merge/" => "tdigest",
385 "tdigest.min/" => "tdigest",
386 "tdigest.quantile/" => "tdigest",
387 "tdigest.rank/" => "tdigest",
388 "tdigest.reset/" => "tdigest",
389 "tdigest.revrank/" => "tdigest",
390 "tdigest.trimmed_mean/" => "tdigest",
391 "time/" => "server",
392 "topk.add/" => "topk",
393 "topk.count/" => "topk",
394 "topk.incrby/" => "topk",
395 "topk.info/" => "topk",
396 "topk.list/" => "topk",
397 "topk.query/" => "topk",
398 "topk.reserve/" => "topk",
399 "touch/" => "generic",
400 "ts.add/" => "timeseries",
401 "ts.alter/" => "timeseries",
402 "ts.create/" => "timeseries",
403 "ts.createrule/" => "timeseries",
404 "ts.decrby/" => "timeseries",
405 "ts.del/" => "timeseries",
406 "ts.deleterule/" => "timeseries",
407 "ts.get/" => "timeseries",
408 "ts.incrby/" => "timeseries",
409 "ts.info/" => "timeseries",
410 "ts.madd/" => "timeseries",
411 "ts.mget/" => "timeseries",
412 "ts.mrange/" => "timeseries",
413 "ts.mrevrange/" => "timeseries",
414 "ts.queryindex/" => "timeseries",
415 "ts.range/" => "timeseries",
416 "ts.revrange/" => "timeseries",
417 "ttl/" => "generic",
418 "type/" => "generic",
419 "unlink/" => "generic",
420 "unsubscribe/" => "pubsub",
421 "unwatch/" => "transactions",
422 "wait/" => "generic",
423 "watch/" => "transactions",
424 "xack/" => "stream",
425 "xadd/" => "stream",
426 "xautoclaim/" => "stream",
427 "xclaim/" => "stream",
428 "xdel/" => "stream",
429 "xgroup-create/" => "stream",
430 "xgroup-createconsumer/" => "stream",
431 "xgroup-delconsumer/" => "stream",
432 "xgroup-destroy/" => "stream",
433 "xgroup-setid/" => "stream",
434 "xinfo-consumers/" => "stream",
435 "xinfo-groups/" => "stream",
436 "xinfo-stream/" => "stream",
437 "xlen/" => "stream",
438 "xpending/" => "stream",
439 "xrange/" => "stream",
440 "xread/" => "stream",
441 "xreadgroup/" => "stream",
442 "xrevrange/" => "stream",
443 "xsetid/" => "stream",
444 "xtrim/" => "stream",
445 "zadd/" => "sorted-set",
446 "zcard/" => "sorted-set",
447 "zcount/" => "sorted-set",
448 "zdiff/" => "sorted-set",
449 "zdiffstore/" => "sorted-set",
450 "zincrby/" => "sorted-set",
451 "zinter/" => "sorted-set",
452 "zintercard/" => "sorted-set",
453 "zinterstore/" => "sorted-set",
454 "zlexcount/" => "sorted-set",
455 "zmpop/" => "sorted-set",
456 "zmscore/" => "sorted-set",
457 "zpopmax/" => "sorted-set",
458 "zpopmin/" => "sorted-set",
459 "zrandmember/" => "sorted-set",
460 "zrange/" => "sorted-set",
461 "zrangebylex/" => "sorted-set",
462 "zrangebyscore/" => "sorted-set",
463 "zrangestore/" => "sorted-set",
464 "zrank/" => "sorted-set",
465 "zrem/" => "sorted-set",
466 "zremrangebylex/" => "sorted-set",
467 "zremrangebyrank/" => "sorted-set",
468 "zremrangebyscore/" => "sorted-set",
469 "zrevrange/" => "sorted-set",
470 "zrevrangebylex/" => "sorted-set",
471 "zrevrangebyscore/" => "sorted-set",
472 "zrevrank/" => "sorted-set",
473 "zscan/" => "sorted-set",
474 "zscore/" => "sorted-set",
475 "zunion/" => "sorted-set",
476 "zunionstore/" => "sorted-set"
477 }
478
479 SLUG_NAMES = {
480 "bitmap" => "Core: Bitmap",
481 "cluster" => "Core: Cluster management",
482 "connection" => "Core: Connection management",
483 "generic" => "Core: Generic",
484 "geo" => "Core: Geospatial indices",
485 "hash" => "Core: Hash",
486 "hyperloglog" => "Core: HyperLogLog",
487 "list" => "Core: List",
488 "pubsub" => "Core: Pub/Sub",
489 "scripting" => "Core: Scripting and Functions",
490 "server" => "Core: Server managment",
491 "set" => "Core: Set",
492 "sorted-set:" => "Core: Sorted Set",
493 "stream" => "Core: Stream",
494 "string" => "Core: String",
495 "transactions" => "Core: Transactions",
496 "bf" => "Stack: Bloom Filter",
497 "cf" => "Stack: Cuckoo Filter",
498 "cms" => "Stack: Count-min Sketch",
499 "graph" => "Stack: Graph",
500 "json" => "Stack: JSON",
501 "search" => "Stack: Search",
502 "suggestion" => "Stack: Auto-Suggest",
503 "tdigest" => "Stack: T-Digest",
504 "timeseries" => "Stack: Time Series",
505 "topk" => "Stack: Top-K",
506 }
507
28 end508 end
29 end509 end
30end510end
lib/docs/scrapers/redis.rb+11−3
@@ -1,7 +1,7 @@
1module Docs1module Docs
2 class Redis < UrlScraper2 class Redis < UrlScraper
3 self.type = 'redis'3 self.type = 'redis'
4 self.release = '6.2.1'4 self.release = '7.0.8'
5 self.base_url = 'https://redis.io/commands'5 self.base_url = 'https://redis.io/commands'
6 self.links = {6 self.links = {
7 home: 'https://redis.io/',7 home: 'https://redis.io/',
@@ -10,13 +10,13 @@ module Docs · 2 unmodified lines
10 10
11 html_filters.push 'redis/entries', 'redis/clean_html', 'title'11 html_filters.push 'redis/entries', 'redis/clean_html', 'title'
12 12
13 options[:container] = ->(filter) { filter.root_page? ? '#commands' : '.text' }13 options[:container] = ->(filter) { filter.root_page? ? '#commands-grid' : 'section' }
14 options[:title] = false14 options[:title] = false
15 options[:root_title] = 'Redis'15 options[:root_title] = 'Redis'
16 options[:follow_links] = ->(filter) { filter.root_page? }16 options[:follow_links] = ->(filter) { filter.root_page? }
17 17
18 options[:attribution] = <<-HTML18 options[:attribution] = <<-HTML
19 &copy; 2009&ndash;2020 Salvatore Sanfilippo<br>19 &copy; 2009&ndash;2022 Salvatore Sanfilippo<br>
20 Licensed under the Creative Commons Attribution-ShareAlike License 4.0.20 Licensed under the Creative Commons Attribution-ShareAlike License 4.0.
21 HTML21 HTML
22 22
@@ -25,5 +25,13 @@ module Docs · 2 unmodified lines
25 body = body.lines[1..-1].join25 body = body.lines[1..-1].join
26 body.scan(/Redis ([0-9.]+)/)[0][0]26 body.scan(/Redis ([0-9.]+)/)[0][0]
27 end27 end
28
29 private
30
31 def parse(response)
32 response.body.gsub! '<form', '<pre'
33 response.body.gsub! '</form', '</pre'
34 super
35 end
28 end36 end
29end37end