Skip to content

Commit

Permalink
Merge pull request #4584 from galaxyproject/bicolor-gamma
Browse files Browse the repository at this point in the history
Add linting for an unknown icon
  • Loading branch information
nomadscientist authored Dec 19, 2023
2 parents 21f60d3 + b704deb commit e8eb1b0
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
29 changes: 29 additions & 0 deletions bin/lint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,16 @@ def self.citation_library
@CITATION_LIBRARY
end

@JEKYLL_CONFIG = nil

def self.jekyll_config
if @JEKYLL_CONFIG.nil?
# Load
@JEKYLL_CONFIG = YAML.load_file('_config.yml')
end
@JEKYLL_CONFIG
end

def self.check_bad_cite(contents)
find_matching_texts(contents, /{%\s*cite\s+([^%]*)\s*%}/i)
.map do |idx, _text, selected|
Expand All @@ -332,6 +342,24 @@ def self.check_bad_cite(contents)
end
end

def self.check_bad_icon(contents)
find_matching_texts(contents, /{%\s*icon\s+([^%]*)\s*%}/i)
.map do |idx, _text, selected|
icon_key = selected[1].strip
if jekyll_config['icon-tag'][icon_key].nil?
ReviewDogEmitter.error(
path: @path,
idx: idx,
match_start: selected.begin(0),
match_end: selected.end(0),
replacement: nil,
message: "The icon (#{icon_key}) could not be found, please add it to _config.yml.",
code: 'GTN:033'
)
end
end
end

def self.non_existent_snippet(contents)
find_matching_texts(contents, /{%\s*snippet\s+([^ ]*)/i)
.reject do |_idx, _text, selected|
Expand Down Expand Up @@ -719,6 +747,7 @@ def self.fix_md(contents)
*new_more_accessible_boxes_agenda(contents),
*no_target_blank(contents),
*check_bad_link(contents),
*check_bad_icon(contents),
*check_looks_like_heading(contents),
*check_bad_tag(contents),
*check_useless_box_prefix(contents),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1251,7 +1251,7 @@ To use this system, you need to take care of a few things:
- Do **not** use hands-on boxes for segments that should be executed (code needs to be left aligned!)
- Do **not** use snippets
- Do **not** use icons `{% raw %}{% icon X %}{% endraw %}`
- Do **not** use icons `{% raw %}{% icon galaxy-eye %}{% endraw %}`
- Do not use a terminal or prompt character (that would be included in the execution.)
- Avoid including output when you can, it doesn't render nicely especially when the cells will become runnable.
Expand Down

0 comments on commit e8eb1b0

Please sign in to comment.