diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-19 15:44:42 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-19 15:44:42 +0000 |
commit | 4555e1b21c365ed8303ffb7a3325d773c9b8bf31 (patch) | |
tree | 5423a1c7516cffe36384133ade12572cf709398d /haml_lint | |
parent | e570267f2f6b326480d284e0164a6464ba4081bc (diff) | |
download | gitlab-ce-4555e1b21c365ed8303ffb7a3325d773c9b8bf31.tar.gz |
Add latest changes from gitlab-org/gitlab@13-12-stable-eev13.12.0-rc42
Diffstat (limited to 'haml_lint')
-rw-r--r-- | haml_lint/linter/documentation_links.rb | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/haml_lint/linter/documentation_links.rb b/haml_lint/linter/documentation_links.rb index a36b095bc11..8c696b26b13 100644 --- a/haml_lint/linter/documentation_links.rb +++ b/haml_lint/linter/documentation_links.rb @@ -13,7 +13,7 @@ module HamlLint DOCS_DIRECTORY = File.join(File.expand_path('../..', __dir__), 'doc') HELP_PATH_LINK_PATTERN = <<~PATTERN - `(send nil? {:help_page_url :help_page_path} $...) + (send nil? {:help_page_url :help_page_path} $...) PATTERN MARKDOWN_HEADER = %r{\A\#{1,6}\s+(?<header>.+)\Z}.freeze @@ -33,8 +33,17 @@ module HamlLint private def check(node) - match = extract_link_and_anchor(node) + ast_tree = fetch_ast_tree(node) + + return unless ast_tree + + ast_tree.descendants.each do |child_node| + match = extract_link_and_anchor(child_node) + validate_node(node, match) + end + end + def validate_node(node, match) return if match.empty? path_to_file = detect_path_to_file(match[:link]) @@ -49,11 +58,7 @@ module HamlLint end end - def extract_link_and_anchor(node) - ast_tree = fetch_ast_tree(node) - - return {} unless ast_tree - + def extract_link_and_anchor(ast_tree) link_match, attributes_match = ::RuboCop::NodePattern.new(HELP_PATH_LINK_PATTERN).match(ast_tree) { link: fetch_link(link_match), anchor: fetch_anchor(attributes_match) }.compact |