History

Add XSLT to XPath doc

Thibaut Courouble committed 10 years ago

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

Unified · Split

9 files
  1. assets/javascripts/app/app.coffee +1 −0
  2. assets/stylesheets/global/_icons.scss +1 −1
  3. lib/app.rb +2 −1
  4. lib/docs/filters/mdn/clean_html.rb +2 −1
  5. lib/docs/filters/xpath/entries.rb +0 −22
  6. lib/docs/filters/xslt_xpath/clean_html.rb +2 −2
  7. lib/docs/filters/xslt_xpath/entries.rb +27 −0
  8. lib/docs/scrapers/mdn/xpath.rb +0 −16
  9. lib/docs/scrapers/mdn/xslt_xpath.rb +21 −0
assets/javascripts/app/app.coffee+1−0
@@ -101,6 +101,7 @@ · 100 unmodified lines
101101 for slug in @settings.getDocs() when not @docs.findBy('slug', slug)
102102 needsSaving = true
103103 doc = @disabledDocs.findBy('slug', 'node~4_lts') if slug == 'node~4.2_lts'
104+ doc = @disabledDocs.findBy('slug', 'xslt_xpath') if slug == 'xpath'
104105 doc ||= @disabledDocs.findBy('slug_without_version', slug)
105106 if doc
106107 @disabledDocs.remove(doc)
assets/stylesheets/global/_icons.scss+1−1
@@ -75,7 +75,7 @@ · 74 unmodified lines
7575 ._icon-cordova:before { background-position: 0 -5rem; }
7676 ._icon-markdown:before { background-position: -1rem -5rem; @extend %darkIconFix !optional; }
7777 ._icon-django:before { background-position: -2rem -5rem; }
78−._icon-xpath:before { background-position: -3rem -5rem; }
78+._icon-xslt_xpath:before { background-position: -3rem -5rem; }
7979 ._icon-nginx:before,
8080 ._icon-nginx_lua_module:before { background-position: -4rem -5rem; }
8181 ._icon-svg:before { background-position: -5rem -5rem; }
lib/app.rb+2−1
@@ -273,7 +273,8 @@ class App < Sinatra::Application · 272 unmodified lines
273273 DOC_REDIRECTS = {
274274 'iojs' => 'node',
275275 'yii1' => 'yii~1.1',
276− 'python2' => 'python~2.7'
276+ 'python2' => 'python~2.7',
277+ 'xpath' => 'xslt_xpath'
277278 }
278279
279280 get %r{\A/([\w~\.]+)(\-[\w\-]+)?(/.*)?\z} do |doc, type, rest|
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