History

Add XPath documentation

Thibaut committed 12 years ago

Commit 7cade1d1 parent eabd27010 files · +70 −-2Browse files

Unified · Split

10 files
  1. assets/images/icons.png +0 −0
  2. assets/images/icons@2x.png +0 −0
  3. assets/javascripts/templates/pages/about_tmpl.coffee +1 −1
  4. assets/javascripts/templates/pages/news_tmpl.coffee +4 −1
  5. assets/stylesheets/global/_icons.scss +1 −0
  6. lib/docs/filters/xpath/clean_html.rb +30 −0
  7. lib/docs/filters/xpath/entries.rb +22 −0
  8. lib/docs/scrapers/mdn/xpath.rb +16 −0
  9. public/icons/docs/xpath/16.png +0 −0
  10. public/icons/docs/xpath/16@2x.png +0 −0
assets/images/icons.png+0−0

Binary file not shown.

assets/images/icons@2x.png+0−0

Binary file not shown.

assets/javascripts/templates/pages/about_tmpl.coffee+1−1
@@ -108,7 +108,7 @@ credits = [ · 107 unmodified lines
108 'Apache',108 'Apache',
109 'https://raw.githubusercontent.com/apache/cordova-docs/master/LICENSE'109 'https://raw.githubusercontent.com/apache/cordova-docs/master/LICENSE'
110 ], [110 ], [
111 'CSS<br>DOM<br>HTML<br>JavaScript',111 'CSS<br>DOM<br>HTML<br>JavaScript<br>XPath',
112 '2005-2014 Mozilla Developer Network and individual contributors',112 '2005-2014 Mozilla Developer Network and individual contributors',
113 'CC BY-SA',113 'CC BY-SA',
114 'http://creativecommons.org/licenses/by-sa/2.5/'114 'http://creativecommons.org/licenses/by-sa/2.5/'
assets/javascripts/templates/pages/news_tmpl.coffee+4−1
@@ -32,7 +32,10 @@ newsItem = (date, news) -> · 31 unmodified lines
32 result32 result
33 33
34app.news = [34app.news = [
35 [ 1410048000000, # September 7, 201435 [ 1413158400000, # October 13, 2014
36 """ New <a href="/xpath/">XPath</a> documentation """,
37 ], [
38 1410048000000, # September 7, 2014
36 """ Updated the HTML, CSS, JavaScript, and DOM documentations with additional content. """,39 """ Updated the HTML, CSS, JavaScript, and DOM documentations with additional content. """,
37 ], [40 ], [
38 1407110400000, # August 4, 201441 1407110400000, # August 4, 2014
assets/stylesheets/global/_icons.scss+1−0
@@ -64,3 +64,4 @@ · 63 unmodified lines
64._icon-cordova:before { background-position: 0 -10rem; }64._icon-cordova:before { background-position: 0 -10rem; }
65._icon-markdown:before { background-position: -1rem -10rem; }65._icon-markdown:before { background-position: -1rem -10rem; }
66._icon-django:before { background-position: -2rem -10rem; }66._icon-django:before { background-position: -2rem -10rem; }
67._icon-xpath:before { background-position: -3rem -10rem; }
lib/docs/filters/xpath/clean_html.rb+30−0
@@ -0,0 +1,30 @@
1module Docs
2 class Xpath
3 class CleanHtmlFilter < Filter
4 def call
5 root_page? ? root : other
6 doc
7 end
8
9 def root
10 if table = at_css('.topicpage-table')
11 table.after(table.css('td').children).remove
12 end
13 end
14
15 def other
16 css('div[style*="background: #f5f5f5;"]').remove
17
18 css('h3[id]').each do |node|
19 node.name = 'h2'
20 end
21
22 css('p').each do |node|
23 child = node.child
24 child = child.next while child && child.text? && child.content.blank?
25 child.remove if child.try(:name) == 'br'
26 end
27 end
28 end
29 end
30end
lib/docs/filters/xpath/entries.rb+22−0
@@ -0,0 +1,22 @@
1module Docs
2 class Xpath
3 class EntriesFilter < Docs::EntriesFilter
4 def get_name
5 name = super
6 name.remove!('Axes.')
7 name << '()' if name.remove!('Functions.')
8 name
9 end
10
11 def get_type
12 if slug.start_with?('Axes')
13 'Axes'
14 elsif slug.start_with?('Functions')
15 'Functions'
16 else
17 'Miscellaneous'
18 end
19 end
20 end
21 end
22end
lib/docs/scrapers/mdn/xpath.rb+16−0
@@ -0,0 +1,16 @@
1module Docs
2 class Xpath < Mdn
3 self.name = 'XPath'
4 self.base_url = 'https://developer.mozilla.org/en-US/docs/Web/XPath'
5
6 html_filters.push 'xpath/clean_html', 'xpath/entries', 'title'
7
8 options[:root_title] = 'XPath'
9
10 options[:fix_urls] = ->(url) do
11 url.sub! 'https://developer.mozilla.org/en/XPath', Xpath.base_url
12 url.sub! 'https://developer.mozilla.org/en-US/docs/XPath', Xpath.base_url
13 url
14 end
15 end
16end
public/icons/docs/xpath/16.png+0−0

Binary file not shown.

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

Binary file not shown.

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