Skip to content

Commit aaf28e5

Browse files
committed
New docs: Opentofu
1 parent e894da2 commit aaf28e5

File tree

8 files changed

+114
-0
lines changed

8 files changed

+114
-0
lines changed

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: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
module Docs
2+
class Opentofu
3+
class CleanHtmlFilter < Filter
4+
def fix_syntax_highlight
5+
css('pre').each do |node|
6+
node.remove_attribute('class')
7+
node.remove_attribute('style')
8+
node.css('.token-line').remove_attribute('style')
9+
end
10+
11+
css('[class*="buttonGroup_"]').remove
12+
end
13+
14+
# Some SVG icons are just too big and not needed.
15+
def remove_svg_icons
16+
css('[role="alert"] svg').remove
17+
end
18+
19+
def call
20+
@doc = at_css("main article > .prose")
21+
22+
remove_svg_icons
23+
fix_syntax_highlight
24+
25+
doc
26+
end
27+
end
28+
end
29+
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: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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+
options[:attribution] = <<-HTML
16+
Copyright &copy; OpenTofu a Series of LF Projects, LLC and its contributors. Documentation materials incorporate content licensed under the MPL-2.0 license from other authors.
17+
HTML
18+
19+
def get_latest_version(opts)
20+
contents = get_latest_github_release('opentofu', 'opentofu', opts)
21+
contents.sub("v", "")
22+
end
23+
24+
version '1.11' do
25+
self.release = '1.11.5'
26+
self.base_url = "https://opentofu.org/docs/v#{self.version}/"
27+
end
28+
29+
version '1.10' do
30+
self.release = '1.10.9'
31+
self.base_url = "https://opentofu.org/docs/v#{self.version}/"
32+
end
33+
34+
version '1.9' do
35+
self.release = '1.9.4'
36+
self.base_url = "https://opentofu.org/docs/v#{self.version}/"
37+
end
38+
end
39+
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)