From 216a9d8f8eee154c322f1bf9e3ffba07c413c21e Mon Sep 17 00:00:00 2001 From: Fouad Date: Sat, 23 Apr 2022 04:19:56 +0200 Subject: [PATCH] Add Kubernetes docs --- .../templates/pages/about_tmpl.coffee | 5 ++ assets/stylesheets/application.css.scss | 1 + assets/stylesheets/pages/_kubernetes.scss | 4 ++ lib/docs/filters/kubernetes/clean_html.rb | 18 +++++++ lib/docs/filters/kubernetes/entries.rb | 35 +++++++++++++ lib/docs/scrapers/kubernetes.rb | 46 ++++++++++++++++++ public/icons/docs/kubernetes/16.png | Bin 0 -> 790 bytes public/icons/docs/kubernetes/16@2x.png | Bin 0 -> 1887 bytes public/icons/docs/kubernetes/SOURCE | 1 + 9 files changed, 110 insertions(+) create mode 100644 assets/stylesheets/pages/_kubernetes.scss create mode 100644 lib/docs/filters/kubernetes/clean_html.rb create mode 100644 lib/docs/filters/kubernetes/entries.rb create mode 100644 lib/docs/scrapers/kubernetes.rb create mode 100644 public/icons/docs/kubernetes/16.png create mode 100644 public/icons/docs/kubernetes/16@2x.png create mode 100644 public/icons/docs/kubernetes/SOURCE diff --git a/assets/javascripts/templates/pages/about_tmpl.coffee b/assets/javascripts/templates/pages/about_tmpl.coffee index e4914dc7..b9e4fd9a 100644 --- a/assets/javascripts/templates/pages/about_tmpl.coffee +++ b/assets/javascripts/templates/pages/about_tmpl.coffee @@ -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', diff --git a/assets/stylesheets/application.css.scss b/assets/stylesheets/application.css.scss index 1d5da325..dbaf152a 100644 --- a/assets/stylesheets/application.css.scss +++ b/assets/stylesheets/application.css.scss @@ -74,6 +74,7 @@ 'pages/julia', 'pages/knockout', 'pages/kotlin', + 'pages/kubernetes', 'pages/laravel', 'pages/liquid', 'pages/love', diff --git a/assets/stylesheets/pages/_kubernetes.scss b/assets/stylesheets/pages/_kubernetes.scss new file mode 100644 index 00000000..52791ba3 --- /dev/null +++ b/assets/stylesheets/pages/_kubernetes.scss @@ -0,0 +1,4 @@ +._kubernetes { + @extend %simple; + +} diff --git a/lib/docs/filters/kubernetes/clean_html.rb b/lib/docs/filters/kubernetes/clean_html.rb new file mode 100644 index 00000000..3f38ae78 --- /dev/null +++ b/lib/docs/filters/kubernetes/clean_html.rb @@ -0,0 +1,18 @@ +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 + + doc + end + + end + end +end diff --git a/lib/docs/filters/kubernetes/entries.rb b/lib/docs/filters/kubernetes/entries.rb new file mode 100644 index 00000000..85e240a9 --- /dev/null +++ b/lib/docs/filters/kubernetes/entries.rb @@ -0,0 +1,35 @@ +module Docs + class Kubernetes + class EntriesFilter < Docs::EntriesFilter + + def get_name + at_css('h1').content + end + + def get_type + name + end + + def additional_entries + entries = css('h2').to_a() + # 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 diff --git a/lib/docs/scrapers/kubernetes.rb b/lib/docs/scrapers/kubernetes.rb new file mode 100644 index 00000000..eb910846 --- /dev/null +++ b/lib/docs/scrapers/kubernetes.rb @@ -0,0 +1,46 @@ +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' + } + self.release = "1.23" + + # https://kubernetes.io/docs/reference/kubernetes-api/ + html_filters.push 'kubernetes/entries', 'kubernetes/clean_html' + + # options[:max_image_size] = 300_000 + options[:container] = '.td-content' + + 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/kubernetes-api/" + end + + version '1.20' do + self.release = "#{version}" + verStr = version.sub('.', '-') + self.base_url = "https://v#{verStr}.docs.kubernetes.io/docs/reference/kubernetes-api/" + end + + version '1.19' do + self.release = "#{version}" + verStr = version.sub('.', '-') + self.base_url = "https://v#{verStr}.docs.kubernetes.io/docs/reference/kubernetes-api/" + end + + def get_latest_version(opts) + get_latest_github_release('kubernetes', 'kubernetes', opts) + end + + end +end diff --git a/public/icons/docs/kubernetes/16.png b/public/icons/docs/kubernetes/16.png new file mode 100644 index 0000000000000000000000000000000000000000..79abeb07e0eb88ca82756364c8fe38de7f574b4f GIT binary patch literal 790 zcmV+x1L^#UP)m5MnoPP@A!`HYo+*$S2f(2sUo6V zS30_PQv>@qH?V2BqaZrB(bW8ePxg8#0c;1b0P+PtGd58pYzzC^8(1>W;{G#_2csUf zKuIsK+0_=|QQqUi&n2Ec_nCNI%K$wFz`YS~EvQtyK*ozcZp@@HYG9dQnL=aKpebQ8 z^3td3t0*di!(JPJp{l6|qn`W!jvLcqI=TxO0-KjRY+LD2eybeJ7Wi_RQ@{Shzq}Sz zU1$Mqcb`@P(Wbfe(A{ZFd^83S0I%X>H> zVM991z;Kn`feMGt6=_MDG$&0uvjzI@Rp@_GWnDT<$c9|r16U=hy6wAPNOQ*^~ozIMT#L&yf+`9`~?2L$% z-!ph;vgo&ml|QckUQTMD@8!fWbk|y^uxd$YwTO(=`Rp#L+6tsTGyyOqB4abbztUwk UZ>6PrEdT%j07*qoM6N<$g8Tq+;s5{u literal 0 HcmV?d00001 diff --git a/public/icons/docs/kubernetes/16@2x.png b/public/icons/docs/kubernetes/16@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..9291009d43bfd2e737e2cecf58d77a83893424d3 GIT binary patch literal 1887 zcmV-l2cYln)IkOUK@_Xh zX#*&S*eMK18Op$vX{oIhTM?&44zYk}I|E{^#extHfwovj29S!aL&Ir68jci*IS9Mi z-6VUwU;o%#E=D$&8E&NTj_30P&ma2wTb-k+gzMYtIi@-yG=PhN*Uyjw;Hhmc6 z{MG19z5{a{I(wXlhljXghVUM+TtrIlh=8i*1B;_^zP0bOu)O_IkbhOiy7bA-vg}?e0LQHtAlQ&Uhr5 z$)l5TJLLc{MMP?v^hO)|7rwj_8#(@^uXuBBK)M14s0_rZ3|L*6P#uWNnq2{z_)-Oz zE8}B@P>?{lYhV%4zIWSoU@tp)Id*dHG8II-^0^+2OVKAGfQMVZH=7<* zH5C~2kJ3o9GTUeB1N|NBJsK7OhbcP!5f9VGB-1_BXeRmiuq3Wj$9408pl&}LCT^*K z=u>0dd|X^lRUpwn#fjL%RMjCOk+vBa=?`1R#qxOb3zt(^Q0QfTp;vPE#OYdfVCg^GtelxACKm*O|MnnxZ2iiCYkjDeoT&$;{PN zEcyKn9hl=_&(ciNy*8%)vVyBsEn^#ttDL?Z1t{oeS^BW6cJT{V@%9#6Hx^RM*+$>Xe9}R1&+t8;UN@mmkpoSZ6Zs$4C#PgcGk^H6Nia-l0<$rH%)T0Og8>G zs4s8!^ZwxwNe+<_1Dx&RohXfLS0su_vH_9y=f5*ZXP#l~aii(SF%x+i(QJmRu~4HJ72uVpK=z2XNShSX{{;2aXAuF*rZPqvLLpUHy46bAHaj-)q&7J)j8oD5Sc{g&DcNJ}xKv^=IhkAcr) zK;w!(aUr4`_XoLlJx=Mh7)=vaIKr(4rZAsR>%#lVzjmg-kM1TZU-<`f4iu7Cw(KztF3b3fyw)Qk04LZbs)h znYO%=vWgf0jnmd&RnttM4?r~DvPnzIqEfKvnp&FJX!rMV=$OGSUjHCbI;p^o+iB>^IX==;3|=krH>bQc zIEXHM!V7Q~IBAGT2$=NbD0ltj(e4hL=JRt6@@kQv(RogGzL<&6W5~MQ0W4LC##Pqu z36SNp$*vbO8Q$N?@@;-jltw!2z?qLGGj3>7Eig$$T8vb6Ml8-dbJtaIyc6e#hPZUa z>@@5)L=5 z?K03Ls(L^0$*S#s_m+d9TRPo4lka{bMduf$1b`7Da<;9$?MaqkB~lE``QejZhTiM! z^3>`|3i4b!@0%V4rgsG1DS<{3TTGj*S~=TCkM8DelgQ1o>#~_X3`3TP$lgwIx(cGI z2JpvlgN{3PK0-8RiQGa#9Cky8_I2QL$PQp?+q&N}fkqNZ!1sWj{~7uwxd3cvIzInz Z<=@oVG+p(lK5zg4002ovPDHLkV1mOkoQ41Z literal 0 HcmV?d00001 diff --git a/public/icons/docs/kubernetes/SOURCE b/public/icons/docs/kubernetes/SOURCE new file mode 100644 index 00000000..cedbe271 --- /dev/null +++ b/public/icons/docs/kubernetes/SOURCE @@ -0,0 +1 @@ +https://cncf-branding.netlify.app/projects/kubernetes/ \ No newline at end of file