Add Chef version 16
Unified · Split
| @@ -2,33 +2,24 @@ module Docs · 1 unmodified line | ||
| 2 | 2 | class Chef |
| 3 | 3 | class CleanHtmlFilter < Filter |
| 4 | 4 | def call |
| 5 | − @doc = at_css('div[role="main"]') | |
| 5 | + @doc = at_css('#main-content-col') | |
| 6 | 6 | |
| 7 | − css('.headerlink').remove | |
| 8 | − | |
| 9 | − css('em', 'div.align-center', 'a[href$=".svg"]').each do |node| | |
| 10 | − node.before(node.children).remove | |
| 7 | + if root_page? | |
| 8 | + css('img').remove | |
| 11 | 9 | end |
| 12 | 10 | |
| 13 | − css('.section').each do |node| | |
| 14 | − node.first_element_child['id'] = node['id'] if node['id'] | |
| 15 | − node.before(node.children).remove | |
| 16 | − end | |
| 11 | + css('pre').each do |node| | |
| 12 | + node.remove_attribute('style') | |
| 17 | 13 | |
| 18 | − css('tt').each do |node| | |
| 19 | − node.content = node.content.strip | |
| 20 | − node.name = 'code' | |
| 14 | + if !(node.classes.include?('highlight')) | |
| 15 | + node.add_class('highlight') | |
| 16 | + node['data-language'] = 'ruby' | |
| 17 | + end | |
| 21 | 18 | end |
| 22 | 19 | |
| 23 | − css('table[border]').each do |node| | |
| 24 | − node.remove_attribute('border') | |
| 25 | − end | |
| 20 | + css('#feedback').remove | |
| 26 | 21 | |
| 27 | − css('div[class*="highlight-"]').each do |node| | |
| 28 | − node.content = node.content.strip | |
| 29 | − node.name = 'pre' | |
| 30 | − node['data-language'] = node['class'][/highlight\-(\w+)/, 1] | |
| 31 | − end | |
| 22 | + css('.mini-toc-header', '.TOC-button').remove | |
| 32 | 23 | |
| 33 | 24 | doc |
| 34 | 25 | end |
| @@ -0,0 +1,37 @@ | ||
| 1 | +module Docs | |
| 2 | + class Chef | |
| 3 | + class CleanHtmlOldFilter < Filter | |
| 4 | + def call | |
| 5 | + @doc = at_css('div[role="main"]') | |
| 6 | + | |
| 7 | + css('.headerlink').remove | |
| 8 | + | |
| 9 | + css('em', 'div.align-center', 'a[href$=".svg"]').each do |node| | |
| 10 | + node.before(node.children).remove | |
| 11 | + end | |
| 12 | + | |
| 13 | + css('.section').each do |node| | |
| 14 | + node.first_element_child['id'] = node['id'] if node['id'] | |
| 15 | + node.before(node.children).remove | |
| 16 | + end | |
| 17 | + | |
| 18 | + css('tt').each do |node| | |
| 19 | + node.content = node.content.strip | |
| 20 | + node.name = 'code' | |
| 21 | + end | |
| 22 | + | |
| 23 | + css('table[border]').each do |node| | |
| 24 | + node.remove_attribute('border') | |
| 25 | + end | |
| 26 | + | |
| 27 | + css('div[class*="highlight-"]').each do |node| | |
| 28 | + node.content = node.content.strip | |
| 29 | + node.name = 'pre' | |
| 30 | + node['data-language'] = node['class'][/highlight\-(\w+)/, 1] | |
| 31 | + end | |
| 32 | + | |
| 33 | + doc | |
| 34 | + end | |
| 35 | + end | |
| 36 | + end | |
| 37 | +end | |
| @@ -1,68 +1,34 @@ | ||
| 1 | 1 | module Docs |
| 2 | 2 | class Chef |
| 3 | 3 | class EntriesFilter < Docs::EntriesFilter |
| 4 | + | |
| 4 | 5 | def get_name |
| 5 | − name = at_css('.body h1').content | |
| 6 | − name.remove! "\u{00b6}" | |
| 7 | − name.remove! 'About the ' | |
| 8 | − name.remove! 'About ' | |
| 9 | − name | |
| 6 | + at_css('h1').content | |
| 10 | 7 | end |
| 11 | 8 | |
| 12 | − CLIENT_TYPE_BY_SLUG_END_WITH = { | |
| 13 | − 'knife_common_options' => 'Workflow Tools', | |
| 14 | − 'knife_using' => 'Workflow Tools', | |
| 15 | − 'resource_common' => 'Cookbooks', | |
| 16 | − 'config_rb_knife_optional_settings' => 'Workflow Tools', | |
| 17 | − 'knife_index_rebuild' => 'Workflow Tools', | |
| 18 | − 'handlers' => 'Extend Chef', | |
| 19 | − 'dsl_recipe' => 'Extend Chef', | |
| 20 | − 'resource' => 'Extend Chef' | |
| 21 | − } | |
| 22 | − | |
| 23 | − SERVER_TYPE_BY_SLUG_END_WITH = { | |
| 24 | − 'auth' => 'Theory & Concepts', | |
| 25 | − 'install_server' => 'Setup & Config', | |
| 26 | − 'install_server_pre' => 'Setup & Config', | |
| 27 | − 'config_rb_server_optional_settings' => 'Manage the Server', | |
| 28 | − 'ctl_chef_server' => 'Manage the Server' | |
| 29 | − } | |
| 30 | − | |
| 31 | 9 | def get_type |
| 32 | − if server_page? | |
| 33 | − SERVER_TYPE_BY_SLUG_END_WITH.each do |key, value| | |
| 34 | − return "Chef Server / #{value}" if slug.end_with?(key) | |
| 35 | − end | |
| 10 | + | |
| 11 | + case slug | |
| 12 | + when /automate/ | |
| 13 | + 'Chef Automate' | |
| 14 | + when /compliance/ | |
| 15 | + 'Chef Compliance' | |
| 16 | + when /desktop/ | |
| 17 | + 'Chef Desktop' | |
| 18 | + when /habitat/ | |
| 19 | + 'Chef Habitat' | |
| 20 | + when /inspec/ | |
| 21 | + 'Chef InSpec' | |
| 22 | + when /workstation/ | |
| 23 | + 'Chef Workstation' | |
| 24 | + when /effortless/ | |
| 25 | + 'Effortless Pattern' | |
| 36 | 26 | else |
| 37 | − CLIENT_TYPE_BY_SLUG_END_WITH.each do |key, value| | |
| 38 | − return value if slug.end_with?(key) | |
| 39 | − end | |
| 27 | + 'Chef Infra' | |
| 40 | 28 | end |
| 41 | 29 | |
| 42 | − path = nav_path | |
| 43 | − path.delete('Reference') | |
| 44 | − path = path[0..0] | |
| 45 | − path.unshift('Chef Server') if server_page? | |
| 46 | − | |
| 47 | − type = path.join(' / ') | |
| 48 | − type.sub 'Cookbooks / Cookbook', 'Cookbooks /' | |
| 49 | − type | |
| 50 | 30 | end |
| 51 | 31 | |
| 52 | − def server_page? | |
| 53 | − slug.start_with?(context[:server_path]) | |
| 54 | − end | |
| 55 | − | |
| 56 | − def nav_path | |
| 57 | − node = at_css(".nav-docs a[href='#{result[:path].split('/').last}']") | |
| 58 | − path = [] | |
| 59 | − until node['class'] && node['class'].include?('main-item') | |
| 60 | − path.unshift(node.first_element_child.content.strip) if node['class'] && node['class'].include?('has-sub-items') | |
| 61 | − node = node.parent | |
| 62 | − end | |
| 63 | − path.unshift(node.first_element_child.content.strip) | |
| 64 | − path | |
| 65 | − end | |
| 66 | 32 | end |
| 67 | 33 | end |
| 68 | 34 | end |
| @@ -0,0 +1,68 @@ | ||
| 1 | +module Docs | |
| 2 | + class Chef | |
| 3 | + class EntriesOldFilter < Docs::EntriesFilter | |
| 4 | + def get_name | |
| 5 | + name = at_css('.body h1').content | |
| 6 | + name.remove! "\u{00b6}" | |
| 7 | + name.remove! 'About the ' | |
| 8 | + name.remove! 'About ' | |
| 9 | + name | |
| 10 | + end | |
| 11 | + | |
| 12 | + CLIENT_TYPE_BY_SLUG_END_WITH = { | |
| 13 | + 'knife_common_options' => 'Workflow Tools', | |
| 14 | + 'knife_using' => 'Workflow Tools', | |
| 15 | + 'resource_common' => 'Cookbooks', | |
| 16 | + 'config_rb_knife_optional_settings' => 'Workflow Tools', | |
| 17 | + 'knife_index_rebuild' => 'Workflow Tools', | |
| 18 | + 'handlers' => 'Extend Chef', | |
| 19 | + 'dsl_recipe' => 'Extend Chef', | |
| 20 | + 'resource' => 'Extend Chef' | |
| 21 | + } | |
| 22 | + | |
| 23 | + SERVER_TYPE_BY_SLUG_END_WITH = { | |
| 24 | + 'auth' => 'Theory & Concepts', | |
| 25 | + 'install_server' => 'Setup & Config', | |
| 26 | + 'install_server_pre' => 'Setup & Config', | |
| 27 | + 'config_rb_server_optional_settings' => 'Manage the Server', | |
| 28 | + 'ctl_chef_server' => 'Manage the Server' | |
| 29 | + } | |
| 30 | + | |
| 31 | + def get_type | |
| 32 | + if server_page? | |
| 33 | + SERVER_TYPE_BY_SLUG_END_WITH.each do |key, value| | |
| 34 | + return "Chef Server / #{value}" if slug.end_with?(key) | |
| 35 | + end | |
| 36 | + else | |
| 37 | + CLIENT_TYPE_BY_SLUG_END_WITH.each do |key, value| | |
| 38 | + return value if slug.end_with?(key) | |
| 39 | + end | |
| 40 | + end | |
| 41 | + | |
| 42 | + path = nav_path | |
| 43 | + path.delete('Reference') | |
| 44 | + path = path[0..0] | |
| 45 | + path.unshift('Chef Server') if server_page? | |
| 46 | + | |
| 47 | + type = path.join(' / ') | |
| 48 | + type.sub 'Cookbooks / Cookbook', 'Cookbooks /' | |
| 49 | + type | |
| 50 | + end | |
| 51 | + | |
| 52 | + def server_page? | |
| 53 | + slug.start_with?(context[:server_path]) | |
| 54 | + end | |
| 55 | + | |
| 56 | + def nav_path | |
| 57 | + node = at_css(".nav-docs a[href='#{result[:path].split('/').last}']") | |
| 58 | + path = [] | |
| 59 | + until node['class'] && node['class'].include?('main-item') | |
| 60 | + path.unshift(node.first_element_child.content.strip) if node['class'] && node['class'].include?('has-sub-items') | |
| 61 | + node = node.parent | |
| 62 | + end | |
| 63 | + path.unshift(node.first_element_child.content.strip) | |
| 64 | + path | |
| 65 | + end | |
| 66 | + end | |
| 67 | + end | |
| 68 | +end | |
| @@ -1,20 +1,16 @@ | ||
| 1 | 1 | module Docs |
| 2 | 2 | class Chef < UrlScraper |
| 3 | 3 | self.type = 'sphinx_simple' |
| 4 | − self.base_url = 'https://docs-archive.chef.io/release/' | |
| 4 | + self.base_url = 'https://docs.chef.io' | |
| 5 | 5 | self.links = { |
| 6 | 6 | home: 'https://www.chef.io/', |
| 7 | 7 | code: 'https://github.com/chef/chef' |
| 8 | 8 | } |
| 9 | 9 | |
| 10 | − html_filters.push 'chef/entries', 'chef/clean_html' | |
| 11 | − | |
| 12 | 10 | options[:skip_patterns] = [ |
| 13 | − /\A[^\/]+\/\z/, | |
| 14 | − /\A[^\/]+\/index\.html\z/, | |
| 15 | − /\A[^\/]+\/release_notes\.html\z/, | |
| 16 | − /\Aserver[^\/]+\/chef_overview\.html\z/, | |
| 17 | − /\A[\d\-]+\/server_components\.html\z/ ] | |
| 11 | + /release_notes/, | |
| 12 | + /feedback/ | |
| 13 | + ] | |
| 18 | 14 | |
| 19 | 15 | options[:attribution] = <<-HTML |
| 20 | 16 | © Chef Software, Inc.<br> |
| @@ -24,12 +20,38 @@ module Docs · 3 unmodified lines | ||
| 24 | 20 | We are not affiliated with, endorsed or sponsored by Chef Inc. |
| 25 | 21 | HTML |
| 26 | 22 | |
| 23 | + version '16' do | |
| 24 | + self.release = '16.7.61' | |
| 25 | + | |
| 26 | + options[:container] = '.off-canvas-wrapper' | |
| 27 | + | |
| 28 | + options[:skip] = [ | |
| 29 | + '/automate/api/', | |
| 30 | + '/habitat/supervisor_api/', | |
| 31 | + '/habitat/builder_api/' | |
| 32 | + ] | |
| 33 | + | |
| 34 | + html_filters.push 'chef/entries', 'chef/clean_html' | |
| 35 | + | |
| 36 | + end | |
| 37 | + | |
| 27 | 38 | version '12' do |
| 28 | 39 | self.release = '12.13' |
| 40 | + self.base_url = 'https://docs-archive.chef.io/release/' | |
| 41 | + | |
| 42 | + html_filters.push 'chef/entries_old', 'chef/clean_html_old' | |
| 29 | 43 | |
| 30 | 44 | options[:client_path] = client_path = '12-13' |
| 31 | 45 | options[:server_path] = server_path = 'server_12-8' |
| 32 | 46 | |
| 47 | + options[:skip_patterns] = [ | |
| 48 | + /\A[^\/]+\/\z/, | |
| 49 | + /\A[^\/]+\/index\.html\z/, | |
| 50 | + /\A[^\/]+\/release_notes\.html\z/, | |
| 51 | + /\Aserver[^\/]+\/chef_overview\.html\z/, | |
| 52 | + /\A[\d\-]+\/server_components\.html\z/ | |
| 53 | + ] | |
| 54 | + | |
| 33 | 55 | self.root_path = "#{client_path}/chef_overview.html" |
| 34 | 56 | self.initial_paths = ["#{server_path}/server_components.html"] |
| 35 | 57 | |
| @@ -38,10 +60,21 @@ module Docs · 2 unmodified lines | ||
| 38 | 60 | |
| 39 | 61 | version '11' do |
| 40 | 62 | self.release = '11.18' |
| 63 | + self.base_url = 'https://docs-archive.chef.io/release/' | |
| 64 | + | |
| 65 | + html_filters.push 'chef/entries_old', 'chef/clean_html_old' | |
| 41 | 66 | |
| 42 | 67 | options[:client_path] = client_path = '11-18' |
| 43 | 68 | options[:server_path] = server_path = 'server_12-8' |
| 44 | 69 | |
| 70 | + options[:skip_patterns] = [ | |
| 71 | + /\A[^\/]+\/\z/, | |
| 72 | + /\A[^\/]+\/index\.html\z/, | |
| 73 | + /\A[^\/]+\/release_notes\.html\z/, | |
| 74 | + /\Aserver[^\/]+\/chef_overview\.html\z/, | |
| 75 | + /\A[\d\-]+\/server_components\.html\z/ | |
| 76 | + ] | |
| 77 | + | |
| 45 | 78 | self.root_path = "#{client_path}/chef_overview.html" |
| 46 | 79 | self.initial_paths = ["#{server_path}/server_components.html"] |
| 47 | 80 | |
| @@ -52,5 +85,6 @@ module Docs · 4 unmodified lines | ||
| 52 | 85 | doc = fetch_doc('https://downloads.chef.io/products/infra', opts) |
| 53 | 86 | doc.at_css('#versions > option').content.strip |
| 54 | 87 | end |
| 88 | + | |
| 55 | 89 | end |
| 56 | 90 | end |