diff --git a/assets/stylesheets/application.css.scss b/assets/stylesheets/application.css.scss index dbaf152a..d00ce225 100644 --- a/assets/stylesheets/application.css.scss +++ b/assets/stylesheets/application.css.scss @@ -74,6 +74,7 @@ 'pages/julia', 'pages/knockout', 'pages/kotlin', + 'pages/kubectl', 'pages/kubernetes', 'pages/laravel', 'pages/liquid', diff --git a/assets/stylesheets/pages/_kubectl.scss b/assets/stylesheets/pages/_kubectl.scss new file mode 100644 index 00000000..afd3090d --- /dev/null +++ b/assets/stylesheets/pages/_kubectl.scss @@ -0,0 +1,4 @@ +._kubectl { + @extend %simple; + +} diff --git a/lib/docs/filters/kubectl/clean_html.rb b/lib/docs/filters/kubectl/clean_html.rb new file mode 100644 index 00000000..e7daf0ab --- /dev/null +++ b/lib/docs/filters/kubectl/clean_html.rb @@ -0,0 +1,11 @@ +module Docs + class Kubectl + class CleanHtmlFilter < Filter + + def call + doc + end + + end + end +end diff --git a/lib/docs/filters/kubectl/entries.rb b/lib/docs/filters/kubectl/entries.rb new file mode 100644 index 00000000..2a15d508 --- /dev/null +++ b/lib/docs/filters/kubectl/entries.rb @@ -0,0 +1,38 @@ +module Docs + class Kubectl + class EntriesFilter < Docs::EntriesFilter + + def get_name + name + end + + def get_type + name + end + + def additional_entries + entries = [] + group = 'kubectl' + commands = css('h1').to_a() + commands.map do |node| + # handle titles differnetly by converting them into sidebar groups (types) + new_group = at_css("##{node['id']} > strong") + if new_group + group = new_group.content.titleize + else + # prepend kubectl before every command + command_name = 'kubectl ' + node.content + entries << [command_name, node['id'], group] + end + + end + + entries + end + + def include_default_entry? + false + end + end + end +end diff --git a/lib/docs/scrapers/kubectl.rb b/lib/docs/scrapers/kubectl.rb new file mode 100644 index 00000000..33f0381f --- /dev/null +++ b/lib/docs/scrapers/kubectl.rb @@ -0,0 +1,45 @@ +module Docs + class Kubectl < UrlScraper + self.name = 'Kubectl' + self.type = 'kubectl' + self.root_path = '' + self.links = { + home: 'https://kubernetes.io/docs/reference/kubectl/', + code: 'https://github.com/kubernetes/kubernetes' + } + self.release = "1.23" + self.base_url = "https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands" + + html_filters.push 'kubectl/entries', 'kubectl/clean_html' + + options[:container] = '#page-content-wrapper' + + options[:attribution] = <<-HTML + © 2022 The Kubernetes Authors | Documentation Distributed under CC BY 4.0
+ Copyright © 2022 The Linux Foundation ®. All rights reserved. + HTML + + # latest version has a special URL that does not include the version identifier + version '1.23' do + self.release = "#{version}" + self.base_url = "https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands" + end + + version '1.20' do + self.release = "#{version}" + verStr = version.sub('.', '-') + self.base_url = "https://v#{verStr}.docs.kubernetes.io/docs/reference/generated/kubectl/kubectl-commands" + end + + version '1.19' do + self.release = "#{version}" + verStr = version.sub('.', '-') + self.base_url = "https://v#{verStr}.docs.kubernetes.io/docs/reference/generated/kubectl/kubectl-commands" + end + + def get_latest_version(opts) + get_latest_github_release('kubernetes', 'kubernetes', opts) + end + + end +end diff --git a/public/icons/docs/kubectl/16.png b/public/icons/docs/kubectl/16.png new file mode 100644 index 00000000..0dccf912 Binary files /dev/null and b/public/icons/docs/kubectl/16.png differ diff --git a/public/icons/docs/kubectl/16@2x.png b/public/icons/docs/kubectl/16@2x.png new file mode 100644 index 00000000..2261e8ec Binary files /dev/null and b/public/icons/docs/kubectl/16@2x.png differ diff --git a/public/icons/docs/kubectl/SOURCE b/public/icons/docs/kubectl/SOURCE new file mode 100644 index 00000000..cedbe271 --- /dev/null +++ b/public/icons/docs/kubectl/SOURCE @@ -0,0 +1 @@ +https://cncf-branding.netlify.app/projects/kubernetes/ \ No newline at end of file