Forráskód Böngészése

Finish Jekyll scraper

Thibaut Courouble 7 éve
szülő
commit
c349caf0f7

BIN
assets/images/docs-2.png


BIN
assets/images/docs-2@2x.png


+ 1 - 1
assets/javascripts/news.json

@@ -1,7 +1,7 @@
 [
   [
     "2018-2-4",
-    "New documentation: <a href=\"/jsdoc/\">JSDoc</a>"
+    "New documentations: <a href=\"/jekyll/\">Jekyll</a> and <a href=\"/jsdoc/\">JSDoc</a>"
   ], [
     "2017-11-26",
     "New documentations: <a href=\"/bluebird/\">Bluebird</a>, <a href=\"/eslint/\">ESLint</a> and <a href=\"/homebrew/\">Homebrew</a>"

+ 5 - 0
assets/javascripts/templates/pages/about_tmpl.coffee

@@ -320,6 +320,11 @@ credits = [
     '2008-2017 Pivotal Labs',
     'MIT',
     'https://raw.githubusercontent.com/jasmine/jasmine/master/MIT.LICENSE'
+  ], [
+    'Jekyll',
+    '2008-2018 Tom Preston-Werner and Jekyll contributors',
+    'MIT',
+    'https://raw.githubusercontent.com/jekyll/jekyll/master/LICENSE'
   ], [
     'Jest',
     '2014-present Facebook Inc.',

+ 1 - 0
assets/stylesheets/application-dark.css.scss

@@ -55,6 +55,7 @@
         'pages/github',
         'pages/go',
         'pages/haskell',
+        'pages/jekyll',
         'pages/jquery',
         'pages/julia',
         'pages/knockout',

+ 1 - 0
assets/stylesheets/global/_icons.scss

@@ -168,3 +168,4 @@
 ._icon-bluebird:before      { background-position: -8rem -2rem; @extend %doc-icon-2; }
 ._icon-eslint:before        { background-position: -9rem -2rem; @extend %doc-icon-2; }
 ._icon-homebrew:before      { background-position: 0 -3rem; @extend %doc-icon-2; }
+._icon-jekyll:before        { background-position: -1rem -3rem; @extend %doc-icon-2; }

+ 4 - 32
assets/stylesheets/pages/_jekyll.scss

@@ -1,35 +1,7 @@
 ._jekyll {
-  h2, h3 { @extend %block-heading; }
+  @extend %simple;
 
-  .note {
-    @extend %note;
-
-    h5 {
-      margin-top: 0.25em;
-    }
-
-    position: relative;
-    &::after {
-      content: attr(data-type);
-      opacity: 0.5;
-      text-transform: uppercase;
-      position: absolute;
-      top: 0.25em;
-      right: 0.5em;
-      font-size: 0.8em;
-      pointer-events: none;
-    }
-
-    // Other note types currently unstyled:
-    // plain
-    // tip
-    // feature
-    &.note-info { @extend %note-blue; }
-    &.note-warning { @extend %note-red; }
-    &.note-unreleased { @extend %note-orange; }
-  }
-
-  pre {
-    font-size: inherit;
-  }
+  .note.info { @extend %note-blue; }
+  .note.warning { @extend %note-red; }
+  .note.unreleased { @extend %note-orange; }
 }

+ 13 - 25
lib/docs/filters/jekyll/clean_html.rb

@@ -2,50 +2,38 @@ module Docs
   class Jekyll
     class CleanHtmlFilter < Filter
       def call
-        css('.improve, .section-nav').each(&:remove)
+        @doc = at_css('article')
+
+        at_css('h1').content = 'Jekyll' if root_page?
+
+        css('.improve, .section-nav').remove
 
         css('div.highlighter-rouge').each do |node|
           pre = node.at_css('pre')
 
-          # copy over the highlighting metadata
-          match = /language-(\w+)/.match(node['class'])
+          lang = node['class'][/language-(\w+)/, 1]
           # HACK: Prism shell highlighting highlights `|`,
           # which makes the tree on this page look terrible
-          if match && !(slug == /structure/ && match[1] == 'sh')
-            lang = match[1]
-            if lang == 'sh'
-              lang = 'bash'
-            elsif lang == 'liquid'
-              lang = 'django' # Close enough.
-            end
-            pre['class'] = nil
+          unless slug.include?('structure') && lang == 'sh'
+            lang = 'bash' if lang == 'sh'
             pre['data-language'] = lang
           end
 
-          # Remove the server-rendered syntax highlighting
-          code = pre.at_css('code')
-          code.content = code.text
-
-          # Remove the div.highlighter-rouge and div.highlight wrapping the <pre>
-          node.add_next_sibling pre
-          node.remove
+          pre.remove_attribute('class')
+          pre.content = pre.content
+          node.replace(pre)
         end
 
-        css('code').each do |node|
-          node['class'] = ''
-        end
+        css('code').remove_attr('class')
 
         css('.note').each do |node|
-          node_type = /note ?(\w+)?/.match(node['class'])[1] || 'tip'
+          node.name = 'blockquote'
 
           # <div class="note">...<br>...</div> -> <div class="note">...</div>
           (node > 'br').each(&:remove)
           # <div class="note">...<p>...<br><br>...</p>...</div> ->
           # <div class="note">...<p>...<br>...</p>...</div>
           node.css('br + br').each(&:remove)
-
-          node['class'] = "note note-#{node_type}"
-          node['data-type'] = node_type
         end
 
         doc

+ 1 - 2
lib/docs/filters/jekyll/entries.rb

@@ -1,13 +1,12 @@
 module Docs
   class Jekyll
     class EntriesFilter < Docs::EntriesFilter
-
       def get_name
         at_css('h1').content
       end
 
       def get_type
-        if /continuous-integration/.match(slug)
+        if slug.include?('continuous-integration')
           'Deployment'
         else
           nav_link = doc.document # document

+ 10 - 12
lib/docs/scrapers/jekyll.rb

@@ -1,7 +1,7 @@
 module Docs
   class Jekyll < UrlScraper
     self.type = 'jekyll'
-    self.release = '3.6.2'
+    self.release = '3.7.2'
     self.base_url = 'https://jekyllrb.com/docs/'
     self.root_path = 'home/'
     self.links = {
@@ -12,23 +12,21 @@ module Docs
     html_filters.push 'jekyll/clean_html', 'jekyll/entries'
 
     options[:trailing_slash] = true
-    options[:container] = 'article'
-    options[:skip] = [
-      '',
-      '/'
-    ]
+    options[:skip] = %w(sites/ upgrading/)
     options[:skip_patterns] = [
       /conduct/,
       /history/,
       /maintaining/,
-      /contributing/
+      /contributing/,
     ]
+    options[:replace_paths] = {
+      '' => 'home/',
+      '/' => 'home/'
+    }
+
     options[:attribution] = <<-HTML
-      &copy; 2008&ndash;2017 Tom Preston-Werner and Jekyll contributors<br />
-      Licensed under
-        <a href="https://github.com/jekyll/jekyll/blob/master/LICENSE">
-          the MIT license
-        </a>
+      &copy; 2008&ndash;2018 Tom Preston-Werner and Jekyll contributors<br>
+      Licensed under the MIT license.
     HTML
   end
 end

BIN
public/icons/docs/jekyll/16.png


BIN
public/icons/docs/jekyll/16@2x.png


+ 1 - 1
public/icons/docs/jekyll/SOURCE

@@ -1 +1 @@
-https://avatars3.githubusercontent.com/u/3083652
+https://raw.githubusercontent.com/jekyll/jekyll/master/docs/favicon.ico