Skip to content

Commit 1c5e5f1

Browse files
authored
Merge pull request #2675 from 5long/opentofu
New docs: Opentofu
2 parents 005d76d + 3f6c4d4 commit 1c5e5f1

9 files changed

Lines changed: 127 additions & 0 deletions

File tree

assets/javascripts/news.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
[
2+
[
3+
"2026-05-26",
4+
"New documentation: <a href=\"/opentofu/\">OpenTofu</a>"
5+
],
26
[
37
"2026-02-14",
48
"New documentation: <a href=\"/couchdb/\">CouchDB</a>"

assets/stylesheets/application.css.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@
8888
@use 'pages/octave';
8989
@use 'pages/openjdk';
9090
@use 'pages/openlayers';
91+
@use 'pages/opentofu';
9192
@use 'pages/perl';
9293
@use 'pages/phalcon';
9394
@use 'pages/phaser';
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
@use 'pages/simple';
2+
3+
._opentofu {
4+
.theme-code-block figure {
5+
margin-inline-start: 0;
6+
}
7+
8+
// "sr" means screen reader
9+
.sr-only {
10+
clip: rect(0,0,0,0);
11+
border-width: 0;
12+
height: 1px;
13+
margin: -1px;
14+
padding: 0;
15+
position: absolute;
16+
width: 1px
17+
}
18+
19+
.font-bold {
20+
font-weight: var(--boldFontWeight);
21+
}
22+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
module Docs
2+
class Opentofu
3+
class CleanHtmlFilter < Filter
4+
def fix_syntax_highlight
5+
css('pre').each do |node|
6+
node['data-language'] = node['class'][/language-(\w+)/, 1] if node['class']
7+
node.content = node.css('.token-line').map(&:content).join("\n")
8+
node.remove_attribute('class')
9+
node.remove_attribute('style')
10+
end
11+
12+
css('[class*="buttonGroup_"]').remove
13+
end
14+
15+
# Some SVG icons are just too big and not needed.
16+
def remove_svg_icons
17+
css('[role="alert"] svg').remove
18+
end
19+
20+
def call
21+
@doc = at_css("main article > .prose")
22+
23+
remove_svg_icons
24+
fix_syntax_highlight
25+
26+
doc
27+
end
28+
end
29+
end
30+
end
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
module Docs
2+
class Opentofu
3+
class EntriesFilter < Docs::EntriesFilter
4+
def get_name
5+
at_css('main article h1').content
6+
end
7+
8+
def get_type
9+
segments = slug.split('/')
10+
if segments[0..1] == ['language', 'functions']
11+
# We have too many functions (120+ out of ~300 pages)
12+
"Function"
13+
elsif segments.first == 'cli'
14+
"CLI"
15+
else
16+
segments.first.titlecase
17+
end
18+
end
19+
end
20+
end
21+
end

lib/docs/scrapers/opentofu.rb

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
module Docs
2+
class Opentofu < UrlScraper
3+
self.name = 'OpenTofu'
4+
self.type = 'opentofu'
5+
self.links = {
6+
home: 'https://opentofu.org/',
7+
}
8+
9+
html_filters.push 'opentofu/entries', 'opentofu/clean_html'
10+
11+
# Empty spans are used by Prism for code highlighting.
12+
# Don't clean them
13+
options[:clean_text] = false
14+
options[:trailing_slash] = true
15+
# https://github.com/opentofu/opentofu/blob/main/LICENSE
16+
options[:attribution] = <<-HTML
17+
Copyright (c) The OpenTofu Authors<br>
18+
Copyright (c) 2014 HashiCorp, Inc.<br>
19+
Mozilla Public License, version 2.0
20+
HTML
21+
22+
def get_latest_version(opts)
23+
contents = get_latest_github_release('opentofu', 'opentofu', opts)
24+
contents.sub("v", "")
25+
end
26+
27+
version '1.12' do
28+
self.release = '1.12.0'
29+
self.base_url = "https://opentofu.org/docs/v#{self.version}/"
30+
end
31+
32+
version '1.11' do
33+
self.release = '1.11.5'
34+
self.base_url = "https://opentofu.org/docs/v#{self.version}/"
35+
end
36+
37+
version '1.10' do
38+
self.release = '1.10.9'
39+
self.base_url = "https://opentofu.org/docs/v#{self.version}/"
40+
end
41+
42+
version '1.9' do
43+
self.release = '1.9.4'
44+
self.base_url = "https://opentofu.org/docs/v#{self.version}/"
45+
end
46+
end
47+
end

public/icons/docs/opentofu/16.png

632 Bytes
Loading
1.1 KB
Loading

public/icons/docs/opentofu/SOURCE

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
https://github.com/opentofu/opentofu.org/blob/main/static/favicons/favicon-16x16.png
2+
https://github.com/opentofu/opentofu.org/blob/main/static/favicons/favicon-32x32.png

0 commit comments

Comments
 (0)