History

Add XSLT to XPath doc

Thibaut Courouble committed 10 years ago

Commit 9b4f4c21 parent a5ed2719 files · +56 −43Browse files

Showing the changes to lib/docs (6 of 9 files). Show all

Unified · Split

6 files
  1. lib/docs/filters/mdn/clean_html.rb +2 −1
  2. lib/docs/filters/xpath/entries.rb +0 −22
  3. lib/docs/filters/xslt_xpath/clean_html.rb +2 −2
  4. lib/docs/filters/xslt_xpath/entries.rb +27 −0
  5. lib/docs/scrapers/mdn/xpath.rb +0 −16
  6. lib/docs/scrapers/mdn/xslt_xpath.rb +21 −0
lib/docs/filters/mdn/clean_html.rb+2−1
@@ -9,7 +9,8 @@ module Docs · 8 unmodified lines
99 '.todo',
1010 '.draftHeader',
1111 '.hidden',
12− '.button.section-edit']
12+ '.button.section-edit',
13+ 'hr']
1314
1415 def call
1516 css(*REMOVE_NODES).remove
lib/docs/filters/xpath/entries.rb+0−22
@@ -1,22 +0,0 @@
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.gsub!('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/filters/xslt_xpath/clean_html.rbrenamed from lib/docs/filters/xpath/clean_html.rb+2−2
@@ -1,8 +1,8 @@
11 module Docs
2− class Xpath
2+ class XsltXpath
33 class CleanHtmlFilter < Filter
44 def call
5− root_page? ? root : other
5+ initial_page? ? root : other
66 doc
77 end
88
lib/docs/filters/xslt_xpath/entries.rb+27−0
@@ -0,0 +1,27 @@
1+module Docs
2+ class XsltXpath
3+ class EntriesFilter < Docs::EntriesFilter
4+ def get_name
5+ name = super
6+ name.remove! 'XPath.'
7+ name.remove! 'XSLT.'
8+ name.remove! 'Axes.'
9+ name.prepend 'xsl:' if slug =~ /\AXSLT\/[a-z]/
10+ name << '()' if name.gsub!('Functions.', '')
11+ name
12+ end
13+
14+ def get_type
15+ if slug =~ /\AXSLT\/[a-z]/
16+ 'XSLT Elements'
17+ elsif slug.start_with?('XPath/Axes')
18+ 'XPath Axes'
19+ elsif slug.start_with?('XPath/Functions')
20+ 'XPath Functions'
21+ else
22+ 'Miscellaneous'
23+ end
24+ end
25+ end
26+ end
27+end
lib/docs/scrapers/mdn/xpath.rb+0−16
@@ -1,16 +0,0 @@
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
lib/docs/scrapers/mdn/xslt_xpath.rb+21−0
@@ -0,0 +1,21 @@
1+module Docs
2+ class XsltXpath < Mdn
3+ self.name = 'XSLT & XPath'
4+ self.slug = 'xslt_xpath'
5+ self.base_url = 'https://developer.mozilla.org/en-US/docs/Web'
6+ self.root_path = '/XSLT'
7+ self.initial_paths = %w(/XPath)
8+
9+ html_filters.push 'xslt_xpath/clean_html', 'xslt_xpath/entries', 'title'
10+
11+ options[:only_patterns] = [/\A\/XSLT/, /\A\/XPath/]
12+
13+ options[:fix_urls] = ->(url) do
14+ url.sub! 'https://developer.mozilla.org/en/XPath', "#{XsltXpath.base_url}/XPath"
15+ url.sub! 'https://developer.mozilla.org/en/XSLT', "#{XsltXpath.base_url}/XSLT"
16+ url.sub! 'https://developer.mozilla.org/en-US/docs/XPath', "#{XsltXpath.base_url}/XPath"
17+ url.sub! 'https://developer.mozilla.org/en-US/docs/XSLT', "#{XsltXpath.base_url}/XSLT"
18+ url
19+ end
20+ end
21+end