History

Add Kubernetes docs

Fouad committed 4 years ago

Commit 216a9d81 parent b3e58499 files · +108 −-2Browse files

Unified · Split

9 files
  1. assets/javascripts/templates/pages/about_tmpl.coffee +5 −0
  2. assets/stylesheets/application.css.scss +1 −0
  3. assets/stylesheets/pages/_kubernetes.scss +4 −0
  4. lib/docs/filters/kubernetes/clean_html.rb +18 −0
  5. lib/docs/filters/kubernetes/entries.rb +35 −0
  6. lib/docs/scrapers/kubernetes.rb +46 −0
  7. public/icons/docs/kubernetes/16.png +0 −0
  8. public/icons/docs/kubernetes/16@2x.png +0 −0
  9. public/icons/docs/kubernetes/SOURCE +1 −0
assets/javascripts/templates/pages/about_tmpl.coffee+5−0
@@ -482,6 +482,11 @@ credits = [ · 481 unmodified lines
482482 '2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors',
483483 'Apache',
484484 'https://raw.githubusercontent.com/JetBrains/kotlin/master/license/LICENSE.txt'
485+ ], [
486+ 'Kubernetes',
487+ '2022 The Kubernetes Authors and The Linux Foundation',
488+ 'Apache License 2.0',
489+ 'https://github.com/kubernetes/kubernetes/blob/master/LICENSE'
485490 ], [
486491 'Laravel',
487492 'Taylor Otwell',
assets/stylesheets/application.css.scss+1−0
@@ -74,6 +74,7 @@ · 73 unmodified lines
7474 'pages/julia',
7575 'pages/knockout',
7676 'pages/kotlin',
77+ 'pages/kubernetes',
7778 'pages/laravel',
7879 'pages/liquid',
7980 'pages/love',
assets/stylesheets/pages/_kubernetes.scss+4−0
@@ -0,0 +1,4 @@
1+._kubernetes {
2+ @extend %simple;
3+
4+}
lib/docs/filters/kubernetes/clean_html.rb+18−0
@@ -0,0 +1,18 @@
1+module Docs
2+ class Kubernetes
3+ class CleanHtmlFilter < Filter
4+
5+ def call
6+
7+ # remove the API Operations section from the docs
8+ # by removing the h2 of id=Opetations
9+ # and all the preceding elements
10+ css('#Operations ~ *').remove
11+ css('#Operations').remove
12+
13+ doc
14+ end
15+
16+ end
17+ end
18+end
lib/docs/filters/kubernetes/entries.rb+35−0
@@ -0,0 +1,35 @@
1+module Docs
2+ class Kubernetes
3+ class EntriesFilter < Docs::EntriesFilter
4+
5+ def get_name
6+ at_css('h1').content
7+ end
8+
9+ def get_type
10+ name
11+ end
12+
13+ def additional_entries
14+ entries = css('h2').to_a()
15+ # remove the Operations section
16+ entries.filter! {|node| node['id'] != 'Operations' }
17+ # remove the ObjectList section
18+ entries.filter! {|node| node['id'] != name + 'List' }
19+ # remove the Object section, most of the documents start with (h1.Pod => h2.Pod h2.PodSpec ...)
20+ entries.filter! {|node| node['id'] != name }
21+
22+ entries.map do |node|
23+ # split all names into YAML object notation (ConfigMapSpec) ==> (ConfigMap.Spec)
24+ child_name = node.content
25+ if child_name.starts_with?(name) && child_name.length > name.length
26+ child_name = name + child_name.sub(name, '.')
27+ end
28+
29+ [child_name, node['id']]
30+ end
31+ end
32+
33+ end
34+ end
35+end
lib/docs/scrapers/kubernetes.rb+46−0
@@ -0,0 +1,46 @@
1+module Docs
2+ class Kubernetes < UrlScraper
3+ self.name = 'Kubernetes'
4+ self.type = 'kubernetes'
5+ self.root_path = '/'
6+ self.links = {
7+ home: 'https://kubernetes.io/',
8+ code: 'https://github.com/kubernetes/kubernetes'
9+ }
10+ self.release = "1.23"
11+
12+ # https://kubernetes.io/docs/reference/kubernetes-api/
13+ html_filters.push 'kubernetes/entries', 'kubernetes/clean_html'
14+
15+ # options[:max_image_size] = 300_000
16+ options[:container] = '.td-content'
17+
18+ options[:attribution] = <<-HTML
19+ &copy; 2022 The Kubernetes Authors | Documentation Distributed under CC BY 4.0 <br>
20+ Copyright &copy; 2022 The Linux Foundation ®. All rights reserved.
21+ HTML
22+
23+ # latest version has a special URL that does not include the version identifier
24+ version '1.23' do
25+ self.release = "#{version}"
26+ self.base_url = "https://kubernetes.io/docs/reference/kubernetes-api/"
27+ end
28+
29+ version '1.20' do
30+ self.release = "#{version}"
31+ verStr = version.sub('.', '-')
32+ self.base_url = "https://v#{verStr}.docs.kubernetes.io/docs/reference/kubernetes-api/"
33+ end
34+
35+ version '1.19' do
36+ self.release = "#{version}"
37+ verStr = version.sub('.', '-')
38+ self.base_url = "https://v#{verStr}.docs.kubernetes.io/docs/reference/kubernetes-api/"
39+ end
40+
41+ def get_latest_version(opts)
42+ get_latest_github_release('kubernetes', 'kubernetes', opts)
43+ end
44+
45+ end
46+end
public/icons/docs/kubernetes/16.png+0−0

Binary file not shown.

public/icons/docs/kubernetes/16@2x.png+0−0

Binary file not shown.

public/icons/docs/kubernetes/SOURCE+1−0
@@ -0,0 +1 @@
1+https://cncf-branding.netlify.app/projects/kubernetes/