Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-docs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAchilleas Pipinellis <axil@gitlab.com>2020-11-12 13:50:58 +0300
committerAchilleas Pipinellis <axil@gitlab.com>2020-11-12 13:50:58 +0300
commite3c8536ce70f1248b107b1a966c6813452893009 (patch)
tree39841e4204f78260c81ddfb1ff3c253af735ae0b
parent6d249b461169aae4e66c584fa9b1e1621603332f (diff)
parentb4de291fbf9660dbfe92371bdddaf59cb3b568c6 (diff)
Merge branch 'eread/fix-more-rubocop-problems' into 'master'
Fix more Rubocop problems See merge request gitlab-org/gitlab-docs!1301
-rw-r--r--Rules38
-rw-r--r--lib/filters/admonition.rb33
-rw-r--r--lib/filters/badges.rb4
-rw-r--r--lib/filters/convert_mermaid_html.rb2
-rw-r--r--lib/filters/gitlab_kramdown.rb2
-rw-r--r--lib/filters/introduced_in.rb24
-rw-r--r--lib/helpers/child_parent_better.rb2
-rw-r--r--lib/helpers/edit_on_gitlab.rb1
-rw-r--r--lib/helpers/icons_helper.rb4
-rw-r--r--lib/helpers/versions.rb3
-rw-r--r--lib/task_helpers.rb6
-rw-r--r--spec/gitlab/docs/page_spec.rb2
12 files changed, 56 insertions, 65 deletions
diff --git a/Rules b/Rules
index 77998113..5e50fa7e 100644
--- a/Rules
+++ b/Rules
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-TITLE_FILTER_REGEXP = /(#\s|#{BadgesFilter::BADGES_MARKDOWN_PATTERN})/
+TITLE_FILTER_REGEXP = /(#\s|#{BadgesFilter::BADGES_MARKDOWN_PATTERN})/.freeze
preprocess do
badges_filter = BadgesFilter.new
@@ -66,26 +66,26 @@ compile '/**/*.md' do
# Use GitlabKramdown with Rouge.
# https://gitlab.com/brodock/gitlab_kramdown
filter :gitlab_kramdown,
- input: 'GitlabKramdown',
- syntax_highlighter: 'rouge',
- syntax_highlighter_opts: {
- # In kramdown 2.0, the plaintext parser was removed and replaced by the
- # :guess_lang option:
- #
- # - https://github.com/gettalong/kramdown/blob/master/doc/news/release_2_0_0.page
- # - https://github.com/gettalong/kramdown/pull/573
- guess_lang: true
- },
- default_lang: 'Plain Text',
- hard_wrap: false,
- auto_ids: true,
- toc_levels: 2..5,
- with_toc: include_toc
+ input: 'GitlabKramdown',
+ syntax_highlighter: 'rouge',
+ syntax_highlighter_opts: {
+ # In kramdown 2.0, the plaintext parser was removed and replaced by the
+ # :guess_lang option:
+ #
+ # - https://github.com/gettalong/kramdown/blob/master/doc/news/release_2_0_0.page
+ # - https://github.com/gettalong/kramdown/pull/573
+ guess_lang: true
+ },
+ default_lang: 'Plain Text',
+ hard_wrap: false,
+ auto_ids: true,
+ toc_levels: 2..5,
+ with_toc: include_toc
filter :convert_mermaid_html
filter :colorize_syntax,
- default_colorizer: :rouge
+ default_colorizer: :rouge
# GitLab price / tiers specific badges
filter :badges
@@ -108,8 +108,8 @@ end
compile '/**/*.scss' do
filter :erb
filter :sass,
- syntax: :scss,
- style: :compressed
+ syntax: :scss,
+ style: :compressed
write item.identifier.without_ext + '-v' + rep.item[:version].to_s + '.css'
end
diff --git a/lib/filters/admonition.rb b/lib/filters/admonition.rb
index 141b93d7..d15eb774 100644
--- a/lib/filters/admonition.rb
+++ b/lib/filters/admonition.rb
@@ -1,23 +1,20 @@
-# encoding: utf-8
-
# Adapted from the admonition code on http://nanoc.ws/
class AdmonitionFilter < Nanoc::Filter
-
identifier :admonition
BOOTSTRAP_MAPPING = {
- 'tip' => 'success',
- 'note' => 'info',
+ 'tip' => 'success',
+ 'note' => 'info',
'caution' => 'warning',
- 'danger' => 'danger',
- }
+ 'danger' => 'danger'
+ }.freeze
FONT_AWESOME_MAPPING = {
- 'note' => 'info-circle',
- 'tip' => 'pencil',
- 'caution' => 'exclamation-triangle',
- 'danger' => 'bolt',
- }
+ 'note' => 'info-circle',
+ 'tip' => 'pencil',
+ 'caution' => 'exclamation-triangle',
+ 'danger' => 'bolt'
+ }.freeze
def run(content, params = {})
# `#dup` is necessary because `.fragment` modifies the incoming string. Ew!
@@ -26,6 +23,7 @@ class AdmonitionFilter < Nanoc::Filter
doc.css('p').each do |para|
content = para.inner_html
next if content !~ /\A(TIP|NOTE|CAUTION|DANGER): (.*)\Z/m
+
new_content = generate($1.downcase, $2)
para.replace(new_content)
end
@@ -33,11 +31,10 @@ class AdmonitionFilter < Nanoc::Filter
end
def generate(kind, content)
- %[<div class="admonition-wrapper #{kind}">] +
- %[<div class="admonition alert alert-#{BOOTSTRAP_MAPPING[kind]}">] +
- %[<i class="fa fa-#{FONT_AWESOME_MAPPING[kind]} fa-fw" aria-hidden="true"></i>] +
- content +
- %[</div></div>]
+ %(<div class="admonition-wrapper #{kind}">) +
+ %(<div class="admonition alert alert-#{BOOTSTRAP_MAPPING[kind]}">) +
+ %(<i class="fa fa-#{FONT_AWESOME_MAPPING[kind]} fa-fw" aria-hidden="true"></i>) +
+ content +
+ %(</div></div>)
end
-
end
diff --git a/lib/filters/badges.rb b/lib/filters/badges.rb
index a5f4ad0b..05257d89 100644
--- a/lib/filters/badges.rb
+++ b/lib/filters/badges.rb
@@ -23,7 +23,7 @@ class BadgesFilter < Nanoc::Filter
(?<badge_type>CORE|STARTER|PREMIUM|ULTIMATE|FREE|BRONZE|SILVER|GOLD)(?:\s+(?<only>ONLY))?
[\]|\)]
</strong>
- }x
+ }x.freeze
BADGES_MARKDOWN_PATTERN = %r{
(?:^|[^`]) # must be start of the line or anything except backtick
@@ -31,7 +31,7 @@ class BadgesFilter < Nanoc::Filter
(?<badge_type>CORE|STARTER|PREMIUM|ULTIMATE|FREE|BRONZE|SILVER|GOLD)(?:\s+(?<only>ONLY))
?(\]|\))\*\*
(?:$|[^`]) # must end of line or anything except backtick
- }x
+ }x.freeze
def run(content, params = {})
content.gsub(BADGES_HTML_PATTERN) { generate(Regexp.last_match[:badge_type].downcase, !Regexp.last_match[:only].nil?) }
diff --git a/lib/filters/convert_mermaid_html.rb b/lib/filters/convert_mermaid_html.rb
index 770502b1..fb21778a 100644
--- a/lib/filters/convert_mermaid_html.rb
+++ b/lib/filters/convert_mermaid_html.rb
@@ -3,7 +3,7 @@
class ConvertMermaidHtml < Nanoc::Filter
identifier :convert_mermaid_html
- MERMAID_HTML_PATTERN = %r{<div\ class="mermaid">(?<mermaid_content>.*?)</div>}mx
+ MERMAID_HTML_PATTERN = %r{<div\ class="mermaid">(?<mermaid_content>.*?)</div>}mx.freeze
def run(content, params = {})
content.gsub(MERMAID_HTML_PATTERN) { generate(Regexp.last_match[:mermaid_content]) }
diff --git a/lib/filters/gitlab_kramdown.rb b/lib/filters/gitlab_kramdown.rb
index a7ba987d..bbe5174f 100644
--- a/lib/filters/gitlab_kramdown.rb
+++ b/lib/filters/gitlab_kramdown.rb
@@ -26,7 +26,7 @@ module Nanoc::Filters
warning_filters = params.delete(:warning_filters)
with_toc = params.delete(:with_toc)
- content = with_toc ? TOC_PATCH+raw_content : raw_content
+ content = with_toc ? TOC_PATCH + raw_content : raw_content
document = ::Kramdown::Document.new(content, params)
update_anchors_with_product_suffixes!(document.root.children)
diff --git a/lib/filters/introduced_in.rb b/lib/filters/introduced_in.rb
index 9e367ca3..dd64ebf2 100644
--- a/lib/filters/introduced_in.rb
+++ b/lib/filters/introduced_in.rb
@@ -1,8 +1,5 @@
-# encoding: utf-8
-
# Adapted from the admonition code on http://nanoc.ws/
class IntroducedInFilter < Nanoc::Filter
-
identifier :introduced_in
def run(content, params = {})
@@ -23,18 +20,17 @@ class IntroducedInFilter < Nanoc::Filter
@incremental_id += 1
# If the content is a list of items, collapse the content.
if content =~ /<ul>/i
- %[<div class="introduced-in mb-3">Version history] +
- %[<button class="text-expander" data-toggle="collapse" href="#release_version_notes_#{@incremental_id}" role="button" aria-expanded="false">] +
- %[</button>] +
- %[<div class="introduced-in-content collapse" id="release_version_notes_#{@incremental_id}">] +
- content +
- %[</div>] +
- %[</div>]
+ %(<div class="introduced-in mb-3">Version history) +
+ %(<button class="text-expander" data-toggle="collapse" href="#release_version_notes_#{@incremental_id}" role="button" aria-expanded="false">) +
+ %(</button>) +
+ %(<div class="introduced-in-content collapse" id="release_version_notes_#{@incremental_id}">) +
+ content +
+ %(</div>) +
+ %(</div>)
else
- %[<div class="introduced-in">] +
- content +
- %[</div>]
+ %(<div class="introduced-in">) +
+ content +
+ %(</div>)
end
end
-
end
diff --git a/lib/helpers/child_parent_better.rb b/lib/helpers/child_parent_better.rb
index 3ddd8386..86dd6565 100644
--- a/lib/helpers/child_parent_better.rb
+++ b/lib/helpers/child_parent_better.rb
@@ -5,7 +5,7 @@ module Nanoc::Helpers
if @config[:debug]
puts item
end
- parent_array = Array.new
+ parent_array = []
current_item = item
# Until the current item has no parent, keep running.
until (get_nearest_parent(current_item.identifier.to_s).nil?) do
diff --git a/lib/helpers/edit_on_gitlab.rb b/lib/helpers/edit_on_gitlab.rb
index 35c59c21..7ca37957 100644
--- a/lib/helpers/edit_on_gitlab.rb
+++ b/lib/helpers/edit_on_gitlab.rb
@@ -9,7 +9,6 @@ module Nanoc::Helpers
product = content_filename_array.shift
# This should be the path from the doc/ directory for a given file.
docs_content_filename = content_filename_array.join("/")
- root_dir = File.expand_path('../../', __dir__)
if product == "omnibus"
# omnibus-gitlab repo
diff --git a/lib/helpers/icons_helper.rb b/lib/helpers/icons_helper.rb
index 631fc9ae..473b1d6f 100644
--- a/lib/helpers/icons_helper.rb
+++ b/lib/helpers/icons_helper.rb
@@ -9,7 +9,7 @@ module Nanoc::Helpers
def icons_sprite
sprite_path = "node_modules/@gitlab/svgs/dist/icons.svg"
- %[<div class="d-none">#{read_file(sprite_path)}</div>]
+ %(<div class="d-none">#{read_file(sprite_path)}</div>)
end
def icon(icon_name, size = nil, css_class = nil)
@@ -26,7 +26,7 @@ module Nanoc::Helpers
*css_class
].join(' ')
- %[<svg class="#{svg_class}"><use href="##{icon_name}" /></svg>]
+ %(<svg class="#{svg_class}"><use href="##{icon_name}" /></svg>)
end
private
diff --git a/lib/helpers/versions.rb b/lib/helpers/versions.rb
index 363fdef7..d54bb2ac 100644
--- a/lib/helpers/versions.rb
+++ b/lib/helpers/versions.rb
@@ -2,8 +2,7 @@
module Nanoc::Helpers
module VersionsDropdown
-
- STABLE_VERSIONS_REGEX=/^\d{1,2}\.\d{1,2}$/
+ STABLE_VERSIONS_REGEX = /^\d{1,2}\.\d{1,2}$/.freeze
#
# Set the active class based on CI_COMMIT_REF_NAME and exclude if on
diff --git a/lib/task_helpers.rb b/lib/task_helpers.rb
index be79af49..8a8735f5 100644
--- a/lib/task_helpers.rb
+++ b/lib/task_helpers.rb
@@ -1,7 +1,7 @@
require 'yaml'
-PRODUCTS = %W[ee omnibus runner charts].freeze
-VERSION_FORMAT = /^(?<major>\d{1,2})\.(?<minor>\d{1,2})$/
+PRODUCTS = %w[ee omnibus runner charts].freeze
+VERSION_FORMAT = /^(?<major>\d{1,2})\.(?<minor>\d{1,2})$/.freeze
def config
# Parse the config file and create a hash.
@@ -13,7 +13,7 @@ def products
# Pull products data from the config.
@products = PRODUCTS.each_with_object({}) do |key, result|
- result[key] = config['products'][key]
+ result[key] = config['products'][key]
end
end
diff --git a/spec/gitlab/docs/page_spec.rb b/spec/gitlab/docs/page_spec.rb
index a9ee3264..948f6310 100644
--- a/spec/gitlab/docs/page_spec.rb
+++ b/spec/gitlab/docs/page_spec.rb
@@ -30,7 +30,7 @@ describe Gitlab::Docs::Page do
<h1 id="internal-anchor">Some section</h1>
<h1 id="utf-8-id-✔">Some section 2</h1>
- </body
+ </body>
</html>
HTML
end