From aaf28e581b5c32285617198d9bef17256fcf1a5b Mon Sep 17 00:00:00 2001 From: Whyme Lyu Date: Wed, 1 Apr 2026 15:30:47 +0800 Subject: [PATCH 1/4] New docs: Opentofu --- assets/stylesheets/application.css.scss | 1 + assets/stylesheets/pages/_opentofu.scss | 22 +++++++++++++ lib/docs/filters/opentofu/clean_html.rb | 29 ++++++++++++++++++ lib/docs/filters/opentofu/entries.rb | 21 +++++++++++++ lib/docs/scrapers/opentofu.rb | 39 ++++++++++++++++++++++++ public/icons/docs/opentofu/16.png | Bin 0 -> 632 bytes public/icons/docs/opentofu/16@2x.png | Bin 0 -> 1125 bytes public/icons/docs/opentofu/SOURCE | 2 ++ 8 files changed, 114 insertions(+) create mode 100644 assets/stylesheets/pages/_opentofu.scss create mode 100644 lib/docs/filters/opentofu/clean_html.rb create mode 100644 lib/docs/filters/opentofu/entries.rb create mode 100644 lib/docs/scrapers/opentofu.rb create mode 100644 public/icons/docs/opentofu/16.png create mode 100644 public/icons/docs/opentofu/16@2x.png create mode 100644 public/icons/docs/opentofu/SOURCE diff --git a/assets/stylesheets/application.css.scss b/assets/stylesheets/application.css.scss index 98e59c73a3..95a1b3a9a6 100644 --- a/assets/stylesheets/application.css.scss +++ b/assets/stylesheets/application.css.scss @@ -88,6 +88,7 @@ @use 'pages/octave'; @use 'pages/openjdk'; @use 'pages/openlayers'; +@use 'pages/opentofu'; @use 'pages/perl'; @use 'pages/phalcon'; @use 'pages/phaser'; diff --git a/assets/stylesheets/pages/_opentofu.scss b/assets/stylesheets/pages/_opentofu.scss new file mode 100644 index 0000000000..c8c9106c0f --- /dev/null +++ b/assets/stylesheets/pages/_opentofu.scss @@ -0,0 +1,22 @@ +@use 'pages/simple'; + +._opentofu { + .theme-code-block figure { + margin-inline-start: 0; + } + + // "sr" means screen reader + .sr-only { + clip: rect(0,0,0,0); + border-width: 0; + height: 1px; + margin: -1px; + padding: 0; + position: absolute; + width: 1px + } + + .font-bold { + font-weight: var(--boldFontWeight); + } +} diff --git a/lib/docs/filters/opentofu/clean_html.rb b/lib/docs/filters/opentofu/clean_html.rb new file mode 100644 index 0000000000..7854d401f4 --- /dev/null +++ b/lib/docs/filters/opentofu/clean_html.rb @@ -0,0 +1,29 @@ +module Docs + class Opentofu + class CleanHtmlFilter < Filter + def fix_syntax_highlight + css('pre').each do |node| + node.remove_attribute('class') + node.remove_attribute('style') + node.css('.token-line').remove_attribute('style') + end + + css('[class*="buttonGroup_"]').remove + end + + # Some SVG icons are just too big and not needed. + def remove_svg_icons + css('[role="alert"] svg').remove + end + + def call + @doc = at_css("main article > .prose") + + remove_svg_icons + fix_syntax_highlight + + doc + end + end + end +end diff --git a/lib/docs/filters/opentofu/entries.rb b/lib/docs/filters/opentofu/entries.rb new file mode 100644 index 0000000000..88f2c1146a --- /dev/null +++ b/lib/docs/filters/opentofu/entries.rb @@ -0,0 +1,21 @@ +module Docs + class Opentofu + class EntriesFilter < Docs::EntriesFilter + def get_name + at_css('main article h1').content + end + + def get_type + segments = slug.split('/') + if segments[0..1] == ['language', 'functions'] + # We have too many functions (120+ out of ~300 pages) + "Function" + elsif segments.first == 'cli' + "CLI" + else + segments.first.titlecase + end + end + end + end +end diff --git a/lib/docs/scrapers/opentofu.rb b/lib/docs/scrapers/opentofu.rb new file mode 100644 index 0000000000..7719fc5879 --- /dev/null +++ b/lib/docs/scrapers/opentofu.rb @@ -0,0 +1,39 @@ +module Docs + class Opentofu < UrlScraper + self.name = 'Opentofu' + self.type = 'opentofu' + self.links = { + home: 'https://opentofu.org/', + } + + html_filters.push 'opentofu/entries', 'opentofu/clean_html' + + # Empty spans are used by Prism for code highlighting. + # Don't clean them + options[:clean_text] = false + options[:trailing_slash] = true + options[:attribution] = <<-HTML + Copyright © OpenTofu a Series of LF Projects, LLC and its contributors. Documentation materials incorporate content licensed under the MPL-2.0 license from other authors. + HTML + + def get_latest_version(opts) + contents = get_latest_github_release('opentofu', 'opentofu', opts) + contents.sub("v", "") + end + + version '1.11' do + self.release = '1.11.5' + self.base_url = "https://opentofu.org/docs/v#{self.version}/" + end + + version '1.10' do + self.release = '1.10.9' + self.base_url = "https://opentofu.org/docs/v#{self.version}/" + end + + version '1.9' do + self.release = '1.9.4' + self.base_url = "https://opentofu.org/docs/v#{self.version}/" + end + end +end diff --git a/public/icons/docs/opentofu/16.png b/public/icons/docs/opentofu/16.png new file mode 100644 index 0000000000000000000000000000000000000000..2c18bbedefe1e1df4a8734a707ba8271360132e4 GIT binary patch literal 632 zcmV-;0*C#HP)?##~W`mxS+X2fA#cUS*#VCJ54e&;{Kxj+RG8Xyl<8aj*#hfNUe0N(v?As3)E{O-AIPYTU<0rIUj9O58;eFTDeL z!z6ElELTB4DrpVCurIio2`Yqa0>DXKNvA&DW&&0~TFC|_qoViuOMQXZ*qVf~WsxHd zsRwbIW2RWHx-f#Q0oi8r88N~p5LS`{0~D&Istb>+3;u0HyAz@T~7h4i1*1@3o~J9?OefG>M9cbj5AFi zla>CEzq$_!^Ak`Pm0&IlUwAHFfof*(rDpsBGQP8~l8h0cO8 z$4i;W$jJEv-NH(J z$JCGztqs)`kD;euhCL0lgaO6j0Kcya)~{OwMq$W6s*&H_gJ>ihYeX4I2?=l8vRVk| zIqYUA%^4t2TDE!n(aa0*Y{~;>n+Oho0q8qkrK%f+HZnCwVM zDOX~5(nFpOeRZT?t7yG;Q~b*OwbmO3WLa)u41%-=P`GK)nJlzjy$P;g7eU?rqqq~X zmRR)mxlsmae~w2we#8yC@?n=0qI@sLS)flxtHO&bD#ZpA?u^EWyC>3Ko;qe!Lg~a3 zk9N$#bD*y+XbZVkDx&zz7zsa&Le=K&Lb&z%tr&61w%$3WkL^l+k!CL_31H*Ywr-fq zA6!v6zn?Ff$MYTcEcbF9vFwn#Nn^3(VH_&)8qZs51S zmyZ&*tFBA*j1g{AA0|0!i5n~UEFD;BYSQ{Z$ivO3J02GW#_{0U+u7b?l+)6uS?bAo rxGTgZR%u3fQa}e;yE@McA2VJ7Dap0=$VUF#00000NkvXXu0mjfO>Y0* literal 0 HcmV?d00001 diff --git a/public/icons/docs/opentofu/SOURCE b/public/icons/docs/opentofu/SOURCE new file mode 100644 index 0000000000..893b013fe2 --- /dev/null +++ b/public/icons/docs/opentofu/SOURCE @@ -0,0 +1,2 @@ +https://github.com/opentofu/opentofu.org/blob/main/static/favicons/favicon-16x16.png +https://github.com/opentofu/opentofu.org/blob/main/static/favicons/favicon-32x32.png From 6fd52b08a6547c3991da2b0b7ee477c2ab14cf85 Mon Sep 17 00:00:00 2001 From: Simon Legner Date: Tue, 26 May 2026 18:35:11 +0200 Subject: [PATCH 2/4] Update OpenTofu documentation (1.12.0) --- lib/docs/scrapers/opentofu.rb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/docs/scrapers/opentofu.rb b/lib/docs/scrapers/opentofu.rb index 7719fc5879..52b2757157 100644 --- a/lib/docs/scrapers/opentofu.rb +++ b/lib/docs/scrapers/opentofu.rb @@ -1,6 +1,6 @@ module Docs class Opentofu < UrlScraper - self.name = 'Opentofu' + self.name = 'OpenTofu' self.type = 'opentofu' self.links = { home: 'https://opentofu.org/', @@ -12,8 +12,11 @@ class Opentofu < UrlScraper # Don't clean them options[:clean_text] = false options[:trailing_slash] = true + # https://github.com/opentofu/opentofu/blob/main/LICENSE options[:attribution] = <<-HTML - Copyright © OpenTofu a Series of LF Projects, LLC and its contributors. Documentation materials incorporate content licensed under the MPL-2.0 license from other authors. + Copyright (c) The OpenTofu Authors
+ Copyright (c) 2014 HashiCorp, Inc.
+ Mozilla Public License, version 2.0 HTML def get_latest_version(opts) @@ -21,6 +24,11 @@ def get_latest_version(opts) contents.sub("v", "") end + version '1.12' do + self.release = '1.12.0' + self.base_url = "https://opentofu.org/docs/v#{self.version}/" + end + version '1.11' do self.release = '1.11.5' self.base_url = "https://opentofu.org/docs/v#{self.version}/" From 56879c3217ac46dfcae320b55289a34e76cb5a18 Mon Sep 17 00:00:00 2001 From: Simon Legner Date: Tue, 26 May 2026 18:36:50 +0200 Subject: [PATCH 3/4] opentofu: add news entry --- assets/javascripts/news.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/assets/javascripts/news.json b/assets/javascripts/news.json index 8db945d488..390c412297 100644 --- a/assets/javascripts/news.json +++ b/assets/javascripts/news.json @@ -1,4 +1,8 @@ [ + [ + "2026-05-26", + "New documentation: OpenTofu" + ], [ "2026-02-14", "New documentation: CouchDB" From 3f6c4d4133c0cd99eb396eb1086c8864b054a97c Mon Sep 17 00:00:00 2001 From: Simon Legner Date: Tue, 26 May 2026 18:41:01 +0200 Subject: [PATCH 4/4] Update OpenTofu documentation (1.12.0) --- lib/docs/filters/opentofu/clean_html.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/docs/filters/opentofu/clean_html.rb b/lib/docs/filters/opentofu/clean_html.rb index 7854d401f4..dd85d23579 100644 --- a/lib/docs/filters/opentofu/clean_html.rb +++ b/lib/docs/filters/opentofu/clean_html.rb @@ -3,9 +3,10 @@ class Opentofu class CleanHtmlFilter < Filter def fix_syntax_highlight css('pre').each do |node| + node['data-language'] = node['class'][/language-(\w+)/, 1] if node['class'] + node.content = node.css('.token-line').map(&:content).join("\n") node.remove_attribute('class') node.remove_attribute('style') - node.css('.token-line').remove_attribute('style') end css('[class*="buttonGroup_"]').remove