History

Add Liquid documentation

Phil Scherer committed 9 years ago

Commit dfee92d1 parent 41278b88 files · +101 −-1Browse files

Showing the changes to lib/docs (3 of 8 files). Show all

Unified · Split

3 files
  1. lib/docs/filters/liquid/clean_html.rb +34 −0
  2. lib/docs/filters/liquid/entries.rb +28 −0
  3. lib/docs/scrapers/liquid.rb +19 −0
lib/docs/filters/liquid/clean_html.rb+34−0
@@ -0,0 +1,34 @@
1module Docs
2 class Liquid
3 class CleanHtmlFilter < Filter
4 def call
5 root_page? ? root : other
6 end
7
8 def root
9 doc = at_css('.home-banner')
10
11 css('.btn-row').remove
12
13 doc
14 end
15
16 def other
17 doc = at_css('.content__area > .content')
18
19 css('button.menu-button').remove
20
21 css('code').each do |node|
22 node.remove_attribute('class')
23 node.content = node.content
24 end
25
26 css('pre', '.highlighter-rouge').each do |node|
27 node.remove_attribute('class')
28 end
29
30 doc
31 end
32 end
33 end
34end
lib/docs/filters/liquid/entries.rb+28−0
@@ -0,0 +1,28 @@
1module Docs
2 class Liquid
3 class EntriesFilter < Docs::EntriesFilter
4 def get_name
5 at_css('h1').content
6 end
7
8 def get_type
9 if not root_page?
10 slug.split('/').first.capitalize
11 end
12 end
13
14 def additional_entries
15 entries = []
16
17 if get_type == 'Tags'
18 css('h2').each do |node|
19 entries << [node.content, node['id']]
20 end
21 end
22
23 entries
24 end
25
26 end
27 end
28end
lib/docs/scrapers/liquid.rb+19−0
@@ -0,0 +1,19 @@
1module Docs
2 class Liquid < UrlScraper
3 self.name = 'Liquid'
4 self.type = 'liquid'
5 self.base_url = "https://shopify.github.io/liquid/"
6 self.links = {
7 home: 'http://liquidmarkup.org/',
8 code: 'https://github.com/shopify/liquid'
9 }
10
11 html_filters.push 'liquid/entries', 'liquid/clean_html'
12
13 options[:attribution] = <<-HTML
14 &copy; 2005, 2006 Tobias Luetke<br>
15 Licensed under the MIT License.
16 HTML
17
18 end
19end

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t