mirror of
https://github.com/freeCodeCamp/devdocs
synced 2024-11-16 19:48:10 +01:00
Merge pull request #1741 from mfouad/kubernetes
Kubernetes documentation
This commit is contained in:
commit
961d1276a8
16 changed files with 204 additions and 0 deletions
|
@ -482,6 +482,11 @@ credits = [
|
|||
'2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors',
|
||||
'Apache',
|
||||
'https://raw.githubusercontent.com/JetBrains/kotlin/master/license/LICENSE.txt'
|
||||
], [
|
||||
'Kubernetes',
|
||||
'2022 The Kubernetes Authors and The Linux Foundation',
|
||||
'Apache License 2.0',
|
||||
'https://github.com/kubernetes/kubernetes/blob/master/LICENSE'
|
||||
], [
|
||||
'Laravel',
|
||||
'Taylor Otwell',
|
||||
|
|
|
@ -74,6 +74,8 @@
|
|||
'pages/julia',
|
||||
'pages/knockout',
|
||||
'pages/kotlin',
|
||||
'pages/kubectl',
|
||||
'pages/kubernetes',
|
||||
'pages/laravel',
|
||||
'pages/liquid',
|
||||
'pages/love',
|
||||
|
|
4
assets/stylesheets/pages/_kubectl.scss
Normal file
4
assets/stylesheets/pages/_kubectl.scss
Normal file
|
@ -0,0 +1,4 @@
|
|||
._kubectl {
|
||||
@extend %simple;
|
||||
|
||||
}
|
4
assets/stylesheets/pages/_kubernetes.scss
Normal file
4
assets/stylesheets/pages/_kubernetes.scss
Normal file
|
@ -0,0 +1,4 @@
|
|||
._kubernetes {
|
||||
@extend %simple;
|
||||
|
||||
}
|
15
lib/docs/filters/kubectl/clean_html.rb
Normal file
15
lib/docs/filters/kubectl/clean_html.rb
Normal file
|
@ -0,0 +1,15 @@
|
|||
module Docs
|
||||
class Kubectl
|
||||
class CleanHtmlFilter < Filter
|
||||
|
||||
def call
|
||||
css('pre').each do |node|
|
||||
node.content = node.content.squish
|
||||
node['data-language'] = 'bash'
|
||||
end
|
||||
doc
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
38
lib/docs/filters/kubectl/entries.rb
Normal file
38
lib/docs/filters/kubectl/entries.rb
Normal file
|
@ -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
|
22
lib/docs/filters/kubernetes/clean_html.rb
Normal file
22
lib/docs/filters/kubernetes/clean_html.rb
Normal file
|
@ -0,0 +1,22 @@
|
|||
module Docs
|
||||
class Kubernetes
|
||||
class CleanHtmlFilter < Filter
|
||||
|
||||
def call
|
||||
|
||||
# remove the API Operations section from the docs
|
||||
# by removing the h2 of id=Opetations
|
||||
# and all the preceding elements
|
||||
css('#Operations ~ *').remove
|
||||
css('#Operations').remove
|
||||
# remove horizontal rules
|
||||
css('hr').remove
|
||||
# remove footer (1.20)
|
||||
css('.pre-footer').remove
|
||||
|
||||
doc
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
37
lib/docs/filters/kubernetes/entries.rb
Normal file
37
lib/docs/filters/kubernetes/entries.rb
Normal file
|
@ -0,0 +1,37 @@
|
|||
module Docs
|
||||
class Kubernetes
|
||||
class EntriesFilter < Docs::EntriesFilter
|
||||
|
||||
def get_name
|
||||
at_css('h1').content
|
||||
end
|
||||
|
||||
def get_type
|
||||
@doc.parent.css('nav .breadcrumb-item:not(.active)')[-1].content
|
||||
end
|
||||
|
||||
def additional_entries
|
||||
entries = css('h2').to_a()
|
||||
# remove the Feedback section
|
||||
entries.filter! {|node| node.content.strip != 'Feedback' }
|
||||
# remove the Operations section
|
||||
entries.filter! {|node| node['id'] != 'Operations' }
|
||||
# remove the ObjectList section
|
||||
entries.filter! {|node| node['id'] != name + 'List' }
|
||||
# remove the Object section, most of the documents start with (h1.Pod => h2.Pod h2.PodSpec ...)
|
||||
entries.filter! {|node| node['id'] != name }
|
||||
|
||||
entries.map do |node|
|
||||
# split all names into YAML object notation (ConfigMapSpec) ==> (ConfigMap.Spec)
|
||||
child_name = node.content
|
||||
if child_name.starts_with?(name) && child_name.length > name.length
|
||||
child_name = name + child_name.sub(name, '.')
|
||||
end
|
||||
|
||||
[child_name, node['id']]
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
38
lib/docs/scrapers/kubectl.rb
Normal file
38
lib/docs/scrapers/kubectl.rb
Normal file
|
@ -0,0 +1,38 @@
|
|||
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 <br>
|
||||
Copyright © 2022 The Linux Foundation ®. All rights reserved.
|
||||
HTML
|
||||
|
||||
# latest version has a special URL that does not include the version identifier
|
||||
version do
|
||||
self.release = "1.23"
|
||||
self.base_url = "https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands"
|
||||
end
|
||||
|
||||
version '1.20' do
|
||||
self.release = "#{version}"
|
||||
self.base_url = "https://v#{version.sub('.', '-')}.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
|
37
lib/docs/scrapers/kubernetes.rb
Normal file
37
lib/docs/scrapers/kubernetes.rb
Normal file
|
@ -0,0 +1,37 @@
|
|||
module Docs
|
||||
class Kubernetes < UrlScraper
|
||||
self.name = 'Kubernetes'
|
||||
self.type = 'kubernetes'
|
||||
self.root_path = '/'
|
||||
self.links = {
|
||||
home: 'https://kubernetes.io/',
|
||||
code: 'https://github.com/kubernetes/kubernetes'
|
||||
}
|
||||
|
||||
# https://kubernetes.io/docs/reference/kubernetes-api/
|
||||
html_filters.push 'kubernetes/entries', 'kubernetes/clean_html'
|
||||
|
||||
options[:container] = '.td-content'
|
||||
|
||||
options[:attribution] = <<-HTML
|
||||
© 2022 The Kubernetes Authors | Documentation Distributed under CC BY 4.0 <br>
|
||||
Copyright © 2022 The Linux Foundation ®. All rights reserved.
|
||||
HTML
|
||||
|
||||
# latest version has a special URL that does not include the version identifier
|
||||
version do
|
||||
self.release = "1.23"
|
||||
self.base_url = "https://kubernetes.io/docs/reference/kubernetes-api/"
|
||||
end
|
||||
|
||||
version '1.20' do
|
||||
self.release = "#{version}"
|
||||
self.base_url = "https://v#{version.sub('.', '-')}.docs.kubernetes.io/docs/reference/kubernetes-api/"
|
||||
end
|
||||
|
||||
def get_latest_version(opts)
|
||||
get_latest_github_release('kubernetes', 'kubernetes', opts)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
BIN
public/icons/docs/kubectl/16.png
Normal file
BIN
public/icons/docs/kubectl/16.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 593 B |
BIN
public/icons/docs/kubectl/16@2x.png
Normal file
BIN
public/icons/docs/kubectl/16@2x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
1
public/icons/docs/kubectl/SOURCE
Normal file
1
public/icons/docs/kubectl/SOURCE
Normal file
|
@ -0,0 +1 @@
|
|||
https://cncf-branding.netlify.app/projects/kubernetes/
|
BIN
public/icons/docs/kubernetes/16.png
Normal file
BIN
public/icons/docs/kubernetes/16.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 790 B |
BIN
public/icons/docs/kubernetes/16@2x.png
Normal file
BIN
public/icons/docs/kubernetes/16@2x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.8 KiB |
1
public/icons/docs/kubernetes/SOURCE
Normal file
1
public/icons/docs/kubernetes/SOURCE
Normal file
|
@ -0,0 +1 @@
|
|||
https://cncf-branding.netlify.app/projects/kubernetes/
|
Loading…
Reference in a new issue