Improve jQuery scraper

This commit is contained in:
Thibaut Courouble 2017-07-23 10:54:43 -04:00
parent bffabec8a6
commit bd7aec1311
4 changed files with 5 additions and 10 deletions

View file

@ -1,14 +1,8 @@
#= require views/pages/base
#= require views/pages/simple
class app.views.JqueryPage extends app.views.BasePage
class app.views.JqueryPage extends app.views.SimplePage
@demoClassName: '_jquery-demo'
prepare: ->
for el in @findAllByClass 'syntaxhighlighter'
language = if el.classList.contains('javascript') then 'javascript' else 'markup'
@highlightCode el, language
return
afterRender: ->
# Prevent jQuery Mobile's demo iframes from scrolling the page
for iframe in @findAllByTag 'iframe'

View file

@ -31,6 +31,7 @@ module Docs
css('div.syntaxhighlighter').each do |node|
node.name = 'pre'
node.content = node.at_css('td.code').css('div.line').map(&:content).join("\n")
node['data-language'] = node['class'].include?('javascript') ? 'javascript' : 'markup'
end
# jQueryMobile/jqmData, etc.

View file

@ -6,7 +6,7 @@ module Docs
def get_name
name = at_css('h1').content.strip
name.remove! ' Widget'
name.remove! ' Widget' unless name.start_with?('Category')
name.prepend '.' if name.start_with? 'jqm'
name << ' event' if type == 'Events' && !name.end_with?(' event')
name

View file

@ -6,7 +6,7 @@ module Docs
def get_name
name = at_css('h1').content.strip
name.remove! ' Widget'
name.remove! ' Widget' unless name.start_with?('Category')
name.gsub!(/ [A-Z]/) { |str| str.downcase! }
name
end