From f7c8c8a6f8fca33dfc3be34e4feb2bc569d45b45 Mon Sep 17 00:00:00 2001 From: Fouad Date: Sat, 30 Apr 2022 08:33:55 +0200 Subject: [PATCH] added Kubectl documentation --- assets/stylesheets/application.css.scss | 1 + assets/stylesheets/pages/_kubectl.scss | 4 +++ lib/docs/filters/kubectl/clean_html.rb | 11 ++++++ lib/docs/filters/kubectl/entries.rb | 38 ++++++++++++++++++++ lib/docs/scrapers/kubectl.rb | 45 ++++++++++++++++++++++++ public/icons/docs/kubectl/16.png | Bin 0 -> 593 bytes public/icons/docs/kubectl/16@2x.png | Bin 0 -> 1214 bytes public/icons/docs/kubectl/SOURCE | 1 + 8 files changed, 100 insertions(+) create mode 100644 assets/stylesheets/pages/_kubectl.scss create mode 100644 lib/docs/filters/kubectl/clean_html.rb create mode 100644 lib/docs/filters/kubectl/entries.rb create mode 100644 lib/docs/scrapers/kubectl.rb create mode 100644 public/icons/docs/kubectl/16.png create mode 100644 public/icons/docs/kubectl/16@2x.png create mode 100644 public/icons/docs/kubectl/SOURCE 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 0000000000000000000000000000000000000000..0dccf912cbcb267cfc17a2612d9b7c3962a3374f GIT binary patch literal 593 zcmV-X0!kw6wI;9asAa78VvZ)$8>iVvJo3G0d{8Gchr7 zVQy}2ek`%kXl$$1YL~Mtdp9ED?-0U2qkRaWSFKimnV+BE`U!bvX69fB;r%M&D1M7E z-dvjxA@uV+-~UmdQmK5O4zJ+_?&2GKiCG-PeLRmbUQe~>KMLe|{vgfzswj#h*n-D6 zhl^-oJ_Y{w?lkfVavDDgaX67UXRWbJl)Pa?yA zsqO3N;t?Jo;wtJPgqNvy9d>0aD=T|bqC^}2Vjq4-1DkOJU*l<(W&fv6;j6qX%bidZ z#g(Ecx}8qvEq=lhj$(knP@A2d{cd@A`C(a>?Ov~U47&r4 zpj)rk4|O`7Q^|dpxFpBXJD1gJ^-K~xi4zFZ)6-|un4`KMja<`B|C#25pC>0Ln`K${ zF&qpA`u+YBjNEVITlB5M20X*CD2jV)+{#L&azCw~V!bigjkiAk(xd2N=W0UmId-5q f#-N3Vs}mmpX*RBn=dU<;00000NkvXXu0mjfAyErC literal 0 HcmV?d00001 diff --git a/public/icons/docs/kubectl/16@2x.png b/public/icons/docs/kubectl/16@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..2261e8ecb6d36ff4d333318b6f517c01a3b06e94 GIT binary patch literal 1214 zcmV;v1VQ_WP)-d)@4wd2^vancxL5+$*sph7Bw0#yp4 zh*TVMsNzDPhJcDopn@DCsD!`;1P4A2ly8n8E9jA#Du{olNq_jatZK`~9!H8nMLT~kxjrhGpC(?;#oEt8Xz zYEMtkNH`q+3Mc`khK7bOlF8&w(==WGC9$Wgt7}g%7@P*oO3m;0pNz-jnOrWXT{Plc zE@!m2w~q$`fghcS?ak-&&9t<%jE#Ki5=A0H1TlgUR7!QP`AIBavK1blCs`vY*Vb08j%-)JRsxm?qL0=y~b&H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