History

Finish Jekyll scraper

Thibaut Courouble committed 8 years ago

Commit c349caf1 parent 2bd96af13 files · +33 −69Browse files

Unified · Split

13 files
  1. assets/images/docs-2.png +0 −0
  2. assets/images/docs-2@2x.png +0 −0
  3. assets/javascripts/news.json +1 −1
  4. assets/javascripts/templates/pages/about_tmpl.coffee +5 −0
  5. assets/stylesheets/application-dark.css.scss +1 −0
  6. assets/stylesheets/global/_icons.scss +1 −0
  7. assets/stylesheets/pages/_jekyll.scss +4 −32
  8. lib/docs/filters/jekyll/clean_html.rb +13 −25
  9. lib/docs/filters/jekyll/entries.rb +1 −2
  10. lib/docs/scrapers/jekyll.rb +10 −12
  11. public/icons/docs/jekyll/16.png +0 −0
  12. public/icons/docs/jekyll/16@2x.png +0 −0
  13. public/icons/docs/jekyll/SOURCE +1 −1
assets/images/docs-2.png+0−0

Binary file not shown.

assets/images/docs-2@2x.png+0−0

Binary file not shown.

assets/javascripts/news.json+1−1
@@ -1,7 +1,7 @@
1[1[
2 [2 [
3 "2018-2-4",3 "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>"
5 ], [5 ], [
6 "2017-11-26",6 "2017-11-26",
7 "New documentations: <a href=\"/bluebird/\">Bluebird</a>, <a href=\"/eslint/\">ESLint</a> and <a href=\"/homebrew/\">Homebrew</a>"7 "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+5−0
@@ -320,6 +320,11 @@ credits = [ · 319 unmodified lines
320 '2008-2017 Pivotal Labs',320 '2008-2017 Pivotal Labs',
321 'MIT',321 'MIT',
322 'https://raw.githubusercontent.com/jasmine/jasmine/master/MIT.LICENSE'322 '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'
323 ], [328 ], [
324 'Jest',329 'Jest',
325 '2014-present Facebook Inc.',330 '2014-present Facebook Inc.',
assets/stylesheets/application-dark.css.scss+1−0
@@ -55,6 +55,7 @@ · 54 unmodified lines
55 'pages/github',55 'pages/github',
56 'pages/go',56 'pages/go',
57 'pages/haskell',57 'pages/haskell',
58 'pages/jekyll',
58 'pages/jquery',59 'pages/jquery',
59 'pages/julia',60 'pages/julia',
60 'pages/knockout',61 'pages/knockout',
assets/stylesheets/global/_icons.scss+1−0
@@ -168,3 +168,4 @@ · 167 unmodified lines
168._icon-bluebird:before { background-position: -8rem -2rem; @extend %doc-icon-2; }168._icon-bluebird:before { background-position: -8rem -2rem; @extend %doc-icon-2; }
169._icon-eslint:before { background-position: -9rem -2rem; @extend %doc-icon-2; }169._icon-eslint:before { background-position: -9rem -2rem; @extend %doc-icon-2; }
170._icon-homebrew:before { background-position: 0 -3rem; @extend %doc-icon-2; }170._icon-homebrew:before { background-position: 0 -3rem; @extend %doc-icon-2; }
171._icon-jekyll:before { background-position: -1rem -3rem; @extend %doc-icon-2; }
assets/stylesheets/pages/_jekyll.scss+4−32
@@ -1,35 +1,7 @@
1._jekyll {1._jekyll {
2 h2, h3 { @extend %block-heading; }2 @extend %simple;
3 3
4 .note {4 .note.info { @extend %note-blue; }
5 @extend %note;5 .note.warning { @extend %note-red; }
6 6 .note.unreleased { @extend %note-orange; }
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 }
35}7}
lib/docs/filters/jekyll/clean_html.rb+13−25
@@ -2,50 +2,38 @@ module Docs · 1 unmodified line
2 class Jekyll2 class Jekyll
3 class CleanHtmlFilter < Filter3 class CleanHtmlFilter < Filter
4 def call4 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
6 10
7 css('div.highlighter-rouge').each do |node|11 css('div.highlighter-rouge').each do |node|
8 pre = node.at_css('pre')12 pre = node.at_css('pre')
9 13
10 # copy over the highlighting metadata14 lang = node['class'][/language-(\w+)/, 1]
11 match = /language-(\w+)/.match(node['class'])
12 # HACK: Prism shell highlighting highlights `|`,15 # HACK: Prism shell highlighting highlights `|`,
13 # which makes the tree on this page look terrible16 # which makes the tree on this page look terrible
14 if match && !(slug == /structure/ && match[1] == 'sh')17 unless slug.include?('structure') && lang == 'sh'
15 lang = match[1]18 lang = 'bash' if lang == 'sh'
16 if lang == 'sh'
17 lang = 'bash'
18 elsif lang == 'liquid'
19 lang = 'django' # Close enough.
20 end
21 pre['class'] = nil
22 pre['data-language'] = lang19 pre['data-language'] = lang
23 end20 end
24 21
25 # Remove the server-rendered syntax highlighting22 pre.remove_attribute('class')
26 code = pre.at_css('code')23 pre.content = pre.content
27 code.content = code.text24 node.replace(pre)
28
29 # Remove the div.highlighter-rouge and div.highlight wrapping the <pre>
30 node.add_next_sibling pre
31 node.remove
32 end25 end
33 26
34 css('code').each do |node|27 css('code').remove_attr('class')
35 node['class'] = ''
36 end
37 28
38 css('.note').each do |node|29 css('.note').each do |node|
39 node_type = /note ?(\w+)?/.match(node['class'])[1] || 'tip'30 node.name = 'blockquote'
40 31
41 # <div class="note">...<br>...</div> -> <div class="note">...</div>32 # <div class="note">...<br>...</div> -> <div class="note">...</div>
42 (node > 'br').each(&:remove)33 (node > 'br').each(&:remove)
43 # <div class="note">...<p>...<br><br>...</p>...</div> ->34 # <div class="note">...<p>...<br><br>...</p>...</div> ->
44 # <div class="note">...<p>...<br>...</p>...</div>35 # <div class="note">...<p>...<br>...</p>...</div>
45 node.css('br + br').each(&:remove)36 node.css('br + br').each(&:remove)
46
47 node['class'] = "note note-#{node_type}"
48 node['data-type'] = node_type
49 end37 end
50 38
51 doc39 doc
lib/docs/filters/jekyll/entries.rb+1−2
@@ -1,13 +1,12 @@
1module Docs1module Docs
2 class Jekyll2 class Jekyll
3 class EntriesFilter < Docs::EntriesFilter3 class EntriesFilter < Docs::EntriesFilter
4
5 def get_name4 def get_name
6 at_css('h1').content5 at_css('h1').content
7 end6 end
8 7
9 def get_type8 def get_type
10 if /continuous-integration/.match(slug)9 if slug.include?('continuous-integration')
11 'Deployment'10 'Deployment'
12 else11 else
13 nav_link = doc.document # document12 nav_link = doc.document # document
lib/docs/scrapers/jekyll.rb+10−12
@@ -1,7 +1,7 @@
1module Docs1module Docs
2 class Jekyll < UrlScraper2 class Jekyll < UrlScraper
3 self.type = 'jekyll'3 self.type = 'jekyll'
4 self.release = '3.6.2'4 self.release = '3.7.2'
5 self.base_url = 'https://jekyllrb.com/docs/'5 self.base_url = 'https://jekyllrb.com/docs/'
6 self.root_path = 'home/'6 self.root_path = 'home/'
7 self.links = {7 self.links = {
@@ -12,23 +12,21 @@ module Docs · 4 unmodified lines
12 html_filters.push 'jekyll/clean_html', 'jekyll/entries'12 html_filters.push 'jekyll/clean_html', 'jekyll/entries'
13 13
14 options[:trailing_slash] = true14 options[:trailing_slash] = true
15 options[:container] = 'article'15 options[:skip] = %w(sites/ upgrading/)
16 options[:skip] = [
17 '',
18 '/'
19 ]
20 options[:skip_patterns] = [16 options[:skip_patterns] = [
21 /conduct/,17 /conduct/,
22 /history/,18 /history/,
23 /maintaining/,19 /maintaining/,
24 /contributing/20 /contributing/,
25 ]21 ]
22 options[:replace_paths] = {
23 '' => 'home/',
24 '/' => 'home/'
25 }
26
26 options[:attribution] = <<-HTML27 options[:attribution] = <<-HTML
27 &copy; 2008&ndash;2017 Tom Preston-Werner and Jekyll contributors<br />28 &copy; 2008&ndash;2018 Tom Preston-Werner and Jekyll contributors<br>
28 Licensed under29 Licensed under the MIT license.
29 <a href="https://github.com/jekyll/jekyll/blob/master/LICENSE">
30 the MIT license
31 </a>
32 HTML30 HTML
33 end31 end
34end32end
public/icons/docs/jekyll/16.png+0−0

Binary file not shown.

public/icons/docs/jekyll/16@2x.png+0−0

Binary file not shown.

public/icons/docs/jekyll/SOURCE+1−1
@@ -1 +1 @@
1https://avatars3.githubusercontent.com/u/30836521https://raw.githubusercontent.com/jekyll/jekyll/master/docs/favicon.ico