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
108108 'Apache',
109109 'https://raw.githubusercontent.com/apache/cordova-docs/master/LICENSE'
110110 ], [
111− 'CSS<br>DOM<br>HTML<br>JavaScript',
111+ 'CSS<br>DOM<br>HTML<br>JavaScript<br>XPath',
112112 '2005-2014 Mozilla Developer Network and individual contributors',
113113 'CC BY-SA',
114114 '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
3232 result
3333
3434 app.news = [
35− [ 1410048000000, # September 7, 2014
35+ [ 1413158400000, # October 13, 2014
36+ """ New <a href="/xpath/">XPath</a> documentation """,
37+ ], [
38+ 1410048000000, # September 7, 2014
3639 """ Updated the HTML, CSS, JavaScript, and DOM documentations with additional content. """,
3740 ], [
3841 1407110400000, # August 4, 2014
assets/stylesheets/global/_icons.scss+1−0
@@ -64,3 +64,4 @@ · 63 unmodified lines
6464 ._icon-cordova:before { background-position: 0 -10rem; }
6565 ._icon-markdown:before { background-position: -1rem -10rem; }
6666 ._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 @@
1+module 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
30+end
lib/docs/filters/xpath/entries.rb+22−0
@@ -0,0 +1,22 @@
1+module 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
22+end
lib/docs/scrapers/mdn/xpath.rb+16−0
@@ -0,0 +1,16 @@
1+module 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
16+end
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