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 @@
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+5−0
@@ -320,6 +320,11 @@ credits = [ · 319 unmodified lines
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+1−0
@@ -55,6 +55,7 @@ · 54 unmodified lines
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+1−0
@@ -168,3 +168,4 @@ · 167 unmodified lines
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; }
assets/stylesheets/pages/_jekyll.scss+4−32
@@ -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+13−25
@@ -2,50 +2,38 @@ module Docs · 1 unmodified line
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+1−2
@@ -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+10−12
@@ -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 @@ module Docs · 4 unmodified lines
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
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 @@
1−https://avatars3.githubusercontent.com/u/3083652
1+https://raw.githubusercontent.com/jekyll/jekyll/master/docs/favicon.ico