Showing the changes to lib/docs (3 of 8 files). Show all
Unified · Split
| @@ -0,0 +1,11 @@ | ||
| 1 | +module Docs | |
| 2 | + class Kubectl | |
| 3 | + class CleanHtmlFilter < Filter | |
| 4 | + | |
| 5 | + def call | |
| 6 | + doc | |
| 7 | + end | |
| 8 | + | |
| 9 | + end | |
| 10 | + end | |
| 11 | +end | |
| @@ -0,0 +1,38 @@ | ||
| 1 | +module Docs | |
| 2 | + class Kubectl | |
| 3 | + class EntriesFilter < Docs::EntriesFilter | |
| 4 | + | |
| 5 | + def get_name | |
| 6 | + name | |
| 7 | + end | |
| 8 | + | |
| 9 | + def get_type | |
| 10 | + name | |
| 11 | + end | |
| 12 | + | |
| 13 | + def additional_entries | |
| 14 | + entries = [] | |
| 15 | + group = 'kubectl' | |
| 16 | + commands = css('h1').to_a() | |
| 17 | + commands.map do |node| | |
| 18 | + # handle titles differnetly by converting them into sidebar groups (types) | |
| 19 | + new_group = at_css("##{node['id']} > strong") | |
| 20 | + if new_group | |
| 21 | + group = new_group.content.titleize | |
| 22 | + else | |
| 23 | + # prepend kubectl before every command | |
| 24 | + command_name = 'kubectl ' + node.content | |
| 25 | + entries << [command_name, node['id'], group] | |
| 26 | + end | |
| 27 | + | |
| 28 | + end | |
| 29 | + | |
| 30 | + entries | |
| 31 | + end | |
| 32 | + | |
| 33 | + def include_default_entry? | |
| 34 | + false | |
| 35 | + end | |
| 36 | + end | |
| 37 | + end | |
| 38 | +end | |
| @@ -0,0 +1,45 @@ | ||
| 1 | +module Docs | |
| 2 | + class Kubectl < UrlScraper | |
| 3 | + self.name = 'Kubectl' | |
| 4 | + self.type = 'kubectl' | |
| 5 | + self.root_path = '' | |
| 6 | + self.links = { | |
| 7 | + home: 'https://kubernetes.io/docs/reference/kubectl/', | |
| 8 | + code: 'https://github.com/kubernetes/kubernetes' | |
| 9 | + } | |
| 10 | + self.release = "1.23" | |
| 11 | + self.base_url = "https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands" | |
| 12 | + | |
| 13 | + html_filters.push 'kubectl/entries', 'kubectl/clean_html' | |
| 14 | + | |
| 15 | + options[:container] = '#page-content-wrapper' | |
| 16 | + | |
| 17 | + options[:attribution] = <<-HTML | |
| 18 | + © 2022 The Kubernetes Authors | Documentation Distributed under CC BY 4.0 <br> | |
| 19 | + Copyright © 2022 The Linux Foundation ®. All rights reserved. | |
| 20 | + HTML | |
| 21 | + | |
| 22 | + # latest version has a special URL that does not include the version identifier | |
| 23 | + version '1.23' do | |
| 24 | + self.release = "#{version}" | |
| 25 | + self.base_url = "https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands" | |
| 26 | + end | |
| 27 | + | |
| 28 | + version '1.20' do | |
| 29 | + self.release = "#{version}" | |
| 30 | + verStr = version.sub('.', '-') | |
| 31 | + self.base_url = "https://v#{verStr}.docs.kubernetes.io/docs/reference/generated/kubectl/kubectl-commands" | |
| 32 | + end | |
| 33 | + | |
| 34 | + version '1.19' do | |
| 35 | + self.release = "#{version}" | |
| 36 | + verStr = version.sub('.', '-') | |
| 37 | + self.base_url = "https://v#{verStr}.docs.kubernetes.io/docs/reference/generated/kubectl/kubectl-commands" | |
| 38 | + end | |
| 39 | + | |
| 40 | + def get_latest_version(opts) | |
| 41 | + get_latest_github_release('kubernetes', 'kubernetes', opts) | |
| 42 | + end | |
| 43 | + | |
| 44 | + end | |
| 45 | +end | |