mirror of https://github.com/freeCodeCamp/devdocs
parent
1ec9140e78
commit
12c5fde792
@ -0,0 +1,14 @@
|
||||
._selenium {
|
||||
h1 {
|
||||
margin-top: 0;
|
||||
@extend %lined-heading;
|
||||
}
|
||||
|
||||
h2 { @extend %block-heading; }
|
||||
|
||||
h3 { @extend %note, %note-green; }
|
||||
|
||||
code { @extend %label; }
|
||||
|
||||
.synopsis { @extend %note, %note-blue; }
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
module Docs
|
||||
class Selenium
|
||||
class CleanHtmlFilter < Filter
|
||||
def call
|
||||
|
||||
# remove nodes before Actions documentation
|
||||
node = css('h2:contains("Selenium Actions")')
|
||||
node.xpath('preceding-sibling::*').remove
|
||||
|
||||
# remove nodes after Accessors documentation
|
||||
node = css('h2:contains("Selenium Accessors")').xpath('following-sibling::h2')
|
||||
node.xpath('following-sibling::*').remove
|
||||
node.remove
|
||||
|
||||
# remove body node and untagged text
|
||||
css('body').children.each do |node|
|
||||
node.parent = node.parent.parent unless node.name == 'text'
|
||||
end
|
||||
css('body').remove
|
||||
|
||||
# set anchor for internal references
|
||||
css('dt > strong').each do |node|
|
||||
anchor = Nokogiri::XML::Node.new "a", @doc
|
||||
anchor.content = node.content
|
||||
anchor['id'] = anchor.content[/\w+/].downcase
|
||||
node.content = ''
|
||||
node.name = 'h3'
|
||||
anchor.parent = node
|
||||
end
|
||||
|
||||
# include arguments into colored note
|
||||
css('p:contains("Arguments")').each do |node|
|
||||
node.name = "div"
|
||||
node['class'] = "synopsis"
|
||||
node.next_element.parent = node
|
||||
end
|
||||
|
||||
# fix external links
|
||||
css('a').each do |node|
|
||||
if node['href']
|
||||
unless ['actions', 'accessors'].include? node['href'][/#(.*)/, 1]
|
||||
node['href'] = Selenium.base_url + node['href']
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
doc
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,21 @@
|
||||
module Docs
|
||||
class Selenium
|
||||
class EntriesFilter < Docs::EntriesFilter
|
||||
def additional_entries
|
||||
entries = []
|
||||
|
||||
types = ['actions', 'accessors']
|
||||
|
||||
types.each do |type|
|
||||
node = doc.css("a[name='#{type}'] + h2 + dl")
|
||||
node.css('strong > a').each do |node|
|
||||
name = node['name']
|
||||
id = name.downcase
|
||||
entries << [name, id, type]
|
||||
end
|
||||
end
|
||||
entries
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,19 @@
|
||||
module Docs
|
||||
class Selenium < UrlScraper
|
||||
self.name = 'Selenium'
|
||||
self.type = 'selenium'
|
||||
self.slug = 'selenium'
|
||||
self.version = '1.0.1'
|
||||
self.base_url = 'http://release.seleniumhq.org/selenium-core/1.0.1/reference.html'
|
||||
|
||||
html_filters.push 'selenium/entries', 'selenium/clean_html', 'title'
|
||||
|
||||
options[:skip_links] = true
|
||||
options[:title] = self.name
|
||||
|
||||
options[:attribution] = <<-HTML
|
||||
© 2006–2014 Selenium Project
|
||||
Licensed under the Apache 2.0 License
|
||||
HTML
|
||||
end
|
||||
end
|
After Width: | Height: | Size: 894 B |
After Width: | Height: | Size: 2.2 KiB |
Loading…
Reference in new issue