浏览代码

Add Liquid documentation

Phil Scherer 8 年之前
父节点
当前提交
dfee92d4f4

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

@@ -57,6 +57,7 @@
         'pages/knockout',
         'pages/kotlin',
         'pages/laravel',
+        'pages/liquid',
         'pages/love',
         'pages/lua',
         'pages/mdn',

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

@@ -57,6 +57,7 @@
         'pages/knockout',
         'pages/kotlin',
         'pages/laravel',
+        'pages/liquid',
         'pages/love',
         'pages/lua',
         'pages/mdn',

+ 18 - 0
assets/stylesheets/pages/_liquid.scss

@@ -0,0 +1,18 @@
+._liquid {
+  @extend %simple;
+
+  .code-label {
+    @extend %block-label, %label-green;
+    border-bottom-left-radius: 0;
+    border-bottom-right-radius: 0;
+    margin-left: 0;
+    margin-right: 0;
+    margin-bottom: -1px;
+  }
+
+  .code-label ~ div > pre {
+    margin-top: 0;
+    border-top-left-radius: 0;
+    border-top-right-radius: 0;
+  }
+}

+ 34 - 0
lib/docs/filters/liquid/clean_html.rb

@@ -0,0 +1,34 @@
+module Docs
+  class Liquid
+    class CleanHtmlFilter < Filter
+      def call
+        root_page? ? root : other
+      end
+
+      def root
+        doc = at_css('.home-banner')
+
+        css('.btn-row').remove
+
+        doc
+      end
+
+      def other
+        doc = at_css('.content__area > .content')
+
+        css('button.menu-button').remove
+
+        css('code').each do |node|
+          node.remove_attribute('class')
+          node.content = node.content
+        end
+
+        css('pre', '.highlighter-rouge').each do |node|
+          node.remove_attribute('class')
+        end
+
+        doc
+      end
+    end
+  end
+end

+ 28 - 0
lib/docs/filters/liquid/entries.rb

@@ -0,0 +1,28 @@
+module Docs
+  class Liquid
+    class EntriesFilter < Docs::EntriesFilter
+      def get_name
+        at_css('h1').content
+      end
+
+      def get_type
+        if not root_page?
+          slug.split('/').first.capitalize
+        end
+      end
+
+      def additional_entries
+        entries = []
+
+        if get_type == 'Tags'
+          css('h2').each do |node|
+            entries << [node.content, node['id']]
+          end
+        end
+
+        entries
+      end
+
+    end
+  end
+end

+ 19 - 0
lib/docs/scrapers/liquid.rb

@@ -0,0 +1,19 @@
+module Docs
+  class Liquid < UrlScraper
+    self.name = 'Liquid'
+    self.type = 'liquid'
+    self.base_url = "https://shopify.github.io/liquid/"
+    self.links = {
+      home: 'http://liquidmarkup.org/',
+      code: 'https://github.com/shopify/liquid'
+    }
+
+    html_filters.push 'liquid/entries', 'liquid/clean_html'
+
+    options[:attribution] = <<-HTML
+      &copy; 2005, 2006 Tobias Luetke<br>
+      Licensed under the MIT License.
+    HTML
+
+  end
+end

+ 1 - 0
public/icons/docs/liquid/SOURCE

@@ -0,0 +1 @@
+https://shopify.github.io/liquid/images/icons/water-drop-64x.png

二进制
public/icons/docs/liquid/water-drop-64x.png