Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions assets/stylesheets/application.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
22 changes: 22 additions & 0 deletions assets/stylesheets/pages/_opentofu.scss
Original file line number Diff line number Diff line change
@@ -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);
}
}
29 changes: 29 additions & 0 deletions lib/docs/filters/opentofu/clean_html.rb
Original file line number Diff line number Diff line change
@@ -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
21 changes: 21 additions & 0 deletions lib/docs/filters/opentofu/entries.rb
Original file line number Diff line number Diff line change
@@ -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
39 changes: 39 additions & 0 deletions lib/docs/scrapers/opentofu.rb
Original file line number Diff line number Diff line change
@@ -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 &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.
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
Binary file added public/icons/docs/opentofu/16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/icons/docs/opentofu/16@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions public/icons/docs/opentofu/SOURCE
Original file line number Diff line number Diff line change
@@ -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