Skip to content

Commit c4b95a3

Browse files
authored
Merge pull request #2517 from gurgeous/es-toolkit
es-toolkit scraper
2 parents 092fde1 + 58c4ef9 commit c4b95a3

File tree

6 files changed

+99
-0
lines changed

6 files changed

+99
-0
lines changed

assets/javascripts/news.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
[
2+
[
3+
"2025-06-04",
4+
"New documentation: <a href=\"/es_toolkit/\">es-toolkit</a>"
5+
],
26
[
37
"2025-05-28",
48
"New documentation: <a href=\"/vertx/\">Vert.x</a>"

docs/file-scrapers.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ curl -L https://github.com/erlang/otp/releases/download/OTP-$RELEASE/otp_doc_htm
5959
bsdtar --extract --file - --directory=docs/erlang\~$VERSION/
6060
```
6161

62+
## es-toolkit
63+
64+
```sh
65+
git clone https://github.com/toss/es-toolkit docs/es_toolkit
66+
```
67+
6268
## Gnu
6369

6470
### Bash

lib/docs/scrapers/es_toolkit.rb

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
module Docs
2+
class EsToolkit < FileScraper
3+
self.name = "es-toolkit"
4+
self.slug = "es_toolkit"
5+
self.type = "simple"
6+
self.links = {
7+
code: "https://github.com/toss/es-toolkit",
8+
home: "https://es-toolkit.slash.page",
9+
}
10+
11+
options[:attribution] = <<-HTML
12+
&copy; 2024-2025, Viva Republica<br>
13+
Licensed under the MIT License.
14+
HTML
15+
16+
def get_latest_version(opts)
17+
get_github_tags("toss", "es-toolkit", opts).first["name"]
18+
end
19+
20+
def build_pages(&block)
21+
internal("docs/intro.md", path: "index", &block)
22+
Dir.chdir(source_directory) do
23+
Dir["docs/reference/**/*.md"]
24+
end.each { internal(_1, &block) }
25+
end
26+
27+
protected
28+
29+
def internal(filename, path: nil, &block)
30+
path ||= filename[%r{docs/reference/(.*/.*).md$}, 1]
31+
32+
# calculate name/type
33+
if path != "index"
34+
name = filename[%r{([^/]+).md$}, 1]
35+
type = path.split("/")[0..-2]
36+
type = type.map(&:capitalize).join(" ")
37+
# really bad way to sort
38+
type = type.gsub(/^(Compat|Error)\b/, "\u2063\\1") # U+2063 INVISIBLE SEPARATOR
39+
else
40+
name = type = nil
41+
end
42+
43+
# now yield
44+
entries = [Entry.new(name, path, type)]
45+
output = render(filename)
46+
store_path = "#{path}.html"
47+
yield({entries:, output:, path:, store_path:})
48+
end
49+
50+
# render/style HTML
51+
def render(filename)
52+
s = md.render(request_one(filename).body)
53+
54+
# kill all links, they don't work
55+
s.gsub!(%r{<a href="[^"]+">(.*?)</a>}, "<span>\\1</span>")
56+
57+
# syntax highlighting
58+
s.gsub!(%r{<pre><code class="typescript">}, "<pre data-language='typescript'><code class='typescript'>")
59+
60+
# h3 => h4
61+
s.gsub!(%r{(</?h)3>}, "\\14>")
62+
63+
# manually add attribution
64+
link = "#{self.class.links[:home]}#{filename.gsub(/^docs/,'').gsub(/md$/,'html')}"
65+
s += <<~HTML
66+
<div class="_attribution">
67+
<p class="_attribution-p">
68+
#{options[:attribution]}
69+
<br>
70+
<a href="#{link}" class="_attribution-link">
71+
#{link}
72+
</a>
73+
</p>
74+
</div>
75+
HTML
76+
s
77+
end
78+
79+
def md
80+
@md ||= Redcarpet::Markdown.new(
81+
Redcarpet::Render::HTML,
82+
autolink: true,
83+
fenced_code_blocks: true,
84+
tables: true
85+
)
86+
end
87+
end
88+
end

public/icons/docs/es_toolkit/16.png

450 Bytes
Loading
752 Bytes
Loading

public/icons/docs/es_toolkit/SOURCE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
https://es-toolkit.slash.page/favicon-100x100.png

0 commit comments

Comments
 (0)