Skip to content

Commit c349caf

Browse files
committed
Finish Jekyll scraper
1 parent 2bd96af commit c349caf

13 files changed

Lines changed: 37 additions & 73 deletions

File tree

assets/images/docs-2.png

331 Bytes
Loading

assets/images/[email protected]

912 Bytes
Loading

assets/javascripts/news.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[
22
[
33
"2018-2-4",
4-
"New documentation: <a href=\"/jsdoc/\">JSDoc</a>"
4+
"New documentations: <a href=\"/jekyll/\">Jekyll</a> and <a href=\"/jsdoc/\">JSDoc</a>"
55
], [
66
"2017-11-26",
77
"New documentations: <a href=\"/bluebird/\">Bluebird</a>, <a href=\"/eslint/\">ESLint</a> and <a href=\"/homebrew/\">Homebrew</a>"

assets/javascripts/templates/pages/about_tmpl.coffee

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,11 @@ credits = [
320320
'2008-2017 Pivotal Labs',
321321
'MIT',
322322
'https://raw.githubusercontent.com/jasmine/jasmine/master/MIT.LICENSE'
323+
], [
324+
'Jekyll',
325+
'2008-2018 Tom Preston-Werner and Jekyll contributors',
326+
'MIT',
327+
'https://raw.githubusercontent.com/jekyll/jekyll/master/LICENSE'
323328
], [
324329
'Jest',
325330
'2014-present Facebook Inc.',

assets/stylesheets/application-dark.css.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
'pages/github',
5656
'pages/go',
5757
'pages/haskell',
58+
'pages/jekyll',
5859
'pages/jquery',
5960
'pages/julia',
6061
'pages/knockout',

assets/stylesheets/global/_icons.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,3 +168,4 @@
168168
._icon-bluebird:before { background-position: -8rem -2rem; @extend %doc-icon-2; }
169169
._icon-eslint:before { background-position: -9rem -2rem; @extend %doc-icon-2; }
170170
._icon-homebrew:before { background-position: 0 -3rem; @extend %doc-icon-2; }
171+
._icon-jekyll:before { background-position: -1rem -3rem; @extend %doc-icon-2; }
Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,7 @@
11
._jekyll {
2-
h2, h3 { @extend %block-heading; }
2+
@extend %simple;
33

4-
.note {
5-
@extend %note;
6-
7-
h5 {
8-
margin-top: 0.25em;
9-
}
10-
11-
position: relative;
12-
&::after {
13-
content: attr(data-type);
14-
opacity: 0.5;
15-
text-transform: uppercase;
16-
position: absolute;
17-
top: 0.25em;
18-
right: 0.5em;
19-
font-size: 0.8em;
20-
pointer-events: none;
21-
}
22-
23-
// Other note types currently unstyled:
24-
// plain
25-
// tip
26-
// feature
27-
&.note-info { @extend %note-blue; }
28-
&.note-warning { @extend %note-red; }
29-
&.note-unreleased { @extend %note-orange; }
30-
}
31-
32-
pre {
33-
font-size: inherit;
34-
}
4+
.note.info { @extend %note-blue; }
5+
.note.warning { @extend %note-red; }
6+
.note.unreleased { @extend %note-orange; }
357
}

lib/docs/filters/jekyll/clean_html.rb

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,50 +2,38 @@ module Docs
22
class Jekyll
33
class CleanHtmlFilter < Filter
44
def call
5-
css('.improve, .section-nav').each(&:remove)
5+
@doc = at_css('article')
6+
7+
at_css('h1').content = 'Jekyll' if root_page?
8+
9+
css('.improve, .section-nav').remove
610

711
css('div.highlighter-rouge').each do |node|
812
pre = node.at_css('pre')
913

10-
# copy over the highlighting metadata
11-
match = /language-(\w+)/.match(node['class'])
14+
lang = node['class'][/language-(\w+)/, 1]
1215
# HACK: Prism shell highlighting highlights `|`,
1316
# which makes the tree on this page look terrible
14-
if match && !(slug == /structure/ && match[1] == 'sh')
15-
lang = match[1]
16-
if lang == 'sh'
17-
lang = 'bash'
18-
elsif lang == 'liquid'
19-
lang = 'django' # Close enough.
20-
end
21-
pre['class'] = nil
17+
unless slug.include?('structure') && lang == 'sh'
18+
lang = 'bash' if lang == 'sh'
2219
pre['data-language'] = lang
2320
end
2421

25-
# Remove the server-rendered syntax highlighting
26-
code = pre.at_css('code')
27-
code.content = code.text
28-
29-
# Remove the div.highlighter-rouge and div.highlight wrapping the <pre>
30-
node.add_next_sibling pre
31-
node.remove
22+
pre.remove_attribute('class')
23+
pre.content = pre.content
24+
node.replace(pre)
3225
end
3326

34-
css('code').each do |node|
35-
node['class'] = ''
36-
end
27+
css('code').remove_attr('class')
3728

3829
css('.note').each do |node|
39-
node_type = /note ?(\w+)?/.match(node['class'])[1] || 'tip'
30+
node.name = 'blockquote'
4031

4132
# <div class="note">...<br>...</div> -> <div class="note">...</div>
4233
(node > 'br').each(&:remove)
4334
# <div class="note">...<p>...<br><br>...</p>...</div> ->
4435
# <div class="note">...<p>...<br>...</p>...</div>
4536
node.css('br + br').each(&:remove)
46-
47-
node['class'] = "note note-#{node_type}"
48-
node['data-type'] = node_type
4937
end
5038

5139
doc

lib/docs/filters/jekyll/entries.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
module Docs
22
class Jekyll
33
class EntriesFilter < Docs::EntriesFilter
4-
54
def get_name
65
at_css('h1').content
76
end
87

98
def get_type
10-
if /continuous-integration/.match(slug)
9+
if slug.include?('continuous-integration')
1110
'Deployment'
1211
else
1312
nav_link = doc.document # document

lib/docs/scrapers/jekyll.rb

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module Docs
22
class Jekyll < UrlScraper
33
self.type = 'jekyll'
4-
self.release = '3.6.2'
4+
self.release = '3.7.2'
55
self.base_url = 'https://jekyllrb.com/docs/'
66
self.root_path = 'home/'
77
self.links = {
@@ -12,23 +12,21 @@ class Jekyll < UrlScraper
1212
html_filters.push 'jekyll/clean_html', 'jekyll/entries'
1313

1414
options[:trailing_slash] = true
15-
options[:container] = 'article'
16-
options[:skip] = [
17-
'',
18-
'/'
19-
]
15+
options[:skip] = %w(sites/ upgrading/)
2016
options[:skip_patterns] = [
2117
/conduct/,
2218
/history/,
2319
/maintaining/,
24-
/contributing/
20+
/contributing/,
2521
]
22+
options[:replace_paths] = {
23+
'' => 'home/',
24+
'/' => 'home/'
25+
}
26+
2627
options[:attribution] = <<-HTML
27-
&copy; 2008&ndash;2017 Tom Preston-Werner and Jekyll contributors<br />
28-
Licensed under
29-
<a href="https://github.com/jekyll/jekyll/blob/master/LICENSE">
30-
the MIT license
31-
</a>
28+
&copy; 2008&ndash;2018 Tom Preston-Werner and Jekyll contributors<br>
29+
Licensed under the MIT license.
3230
HTML
3331
end
3432
end

0 commit comments

Comments
 (0)