Add Chef documentation

pull/344/merge
doertedev 9 years ago committed by Thibaut Courouble
parent 046d4c1d94
commit 0948b5882e

@ -35,6 +35,7 @@
'pages/c',
'pages/cakephp',
'pages/chai',
'pages/chef',
'pages/clojure',
'pages/coffeescript',
'pages/d3',

@ -35,6 +35,7 @@
'pages/c',
'pages/cakephp',
'pages/chai',
'pages/chef',
'pages/clojure',
'pages/coffeescript',
'pages/d3',

@ -0,0 +1,4 @@
._chef {
@extend %simple;
}

@ -0,0 +1,10 @@
module Docs
class Chef
class CleanHtmlFilter < Filter
def call
css('h1 a', 'h2 a', 'h3 a','div.footer').remove
doc
end
end
end
end

@ -0,0 +1,10 @@
module Docs
class Chef
class EntriesFilter < Docs::EntriesFilter
def get_name
at_css('div.body h1 a').remove
at_css('div.body h1').content
end
end
end
end

@ -0,0 +1,11 @@
module Docs
class Chefclient
class CleanHtmlFilter < Filter
def call
css('h1 a, h2 a, h3 a').remove
doc = at_css('div.body[role="main"]')
doc
end
end
end
end

@ -0,0 +1,63 @@
module Docs
class Chefclient
class EntriesFilter < Docs::EntriesFilter
ADDITIONAL_URLS = [
{
slug: 'knife_common_options',
type: 'Miscellaneous/Knife',
name: 'Common options'
},
{
slug: 'knife_using',
type: 'Miscellaneous/Knife',
name: 'Using knife'
},
{
slug: 'config_rb_knife_optional_settings',
type: 'Miscellaneous/Knife',
name: 'Optional settings'
},
{
slug: 'resource_common',
name: 'About resources'
}
]
def get_name
ADDITIONAL_URLS.each do |url|
next unless slug == url[:slug]
return url[:name]
end
css('.main-item a').map do |node|
next unless node.attributes['href'].to_s == slug
return node.attributes['title'].to_s
end
#css('h1').try(:content)
return 'adsf'
end
def get_type
ADDITIONAL_URLS.each do |url|
next unless slug == url[:slug]
next unless url[:type].nil?
return url[:type]
end
css('.main-item a').map do |node|
next unless node.attributes['href'].to_s == slug
if node.ancestors('.sub-items')[0].attributes['class'].to_s.include? 'level-2'
level2 = node.ancestors('.sub-items')[0].previous_element['title'].to_s
level1 = node.ancestors('.sub-items')[0].ancestors('.sub-items')[0].previous_element['title'].to_s
return "#{level1}/#{level2}"
end
return node.ancestors('.sub-items')[0].previous_element['title'].to_s
end
'Miscellaneous'
end
end
end
end

@ -0,0 +1,27 @@
module Docs
class Chef < UrlScraper
self.name = 'Chef'
self.slug = 'chef'
self.type = 'chef'
self.version = '12.5'
self.base_url = 'https://docs.chef.io/'
self.links = {
home: 'https://www.chef.io/',
docs: 'https://docs.chef.io/'
}
html_filters.push 'chef/entries', 'chef/clean_html'
options[:container] = '.bodywrapper'
options[:only_patterns] = [/resource_.*.html/]
options[:skip_patterns] = [/resource_common\.html/]
options[:trailing_slash] = false
options[:attribution] = <<-HTML
&copy; 2015 Chef Software, Inc.<br>
Creative Commons Attribution 3.0 Unported License.
HTML
end
end

@ -0,0 +1,28 @@
module Docs
class Chefclient < UrlScraper
self.name = 'Chef Client'
self.slug = 'chefclient'
self.type = 'chefclient'
self.version = '12.5'
self.base_url = "https://docs.chef.io/release/#{version.sub '.', '-'}/"
self.links = {
home: 'https://www.chef.io/',
docs: 'https://docs.chef.io/'
}
html_filters.push 'chefclient/entries', 'chefclient/clean_html'
options[:fix_urls] = ->(url) do
url.remove! %r{/release/[0-9\-+]/}
url
end
options[:skip_patterns] = [/_images\//]
options[:trailing_slash] = false
options[:attribution] = <<-HTML
&copy; 2015 Chef Software, Inc.<br>
Creative Commons Attribution 3.0 Unported License.
HTML
end
end

Binary file not shown.

After

Width:  |  Height:  |  Size: 749 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

@ -0,0 +1 @@
http://style.chef.io/assets/images/downloads/Chef_Regular.png
Loading…
Cancel
Save