From 883352c3d8c5f64bf01e16249ac5601663afebd0 Mon Sep 17 00:00:00 2001 From: Sebastian Spier Date: Sat, 15 Feb 2025 13:46:46 +0100 Subject: [PATCH 1/3] Upgrade to lates version of commonmarker. Output links so that they can be rendered as markdown in a GitHub issue. --- meta/scripts/Gemfile | 1 + meta/scripts/find_upgradeable_patterns.rb | 14 ++++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/meta/scripts/Gemfile b/meta/scripts/Gemfile index 1cd3261e2..8ed9d9969 100644 --- a/meta/scripts/Gemfile +++ b/meta/scripts/Gemfile @@ -4,4 +4,5 @@ source "https://rubygems.org" git_source(:github) {|repo_name| "https://github.com/#{repo_name}" } +# gem 'commonmarker' , '0.14.2' gem 'commonmarker' diff --git a/meta/scripts/find_upgradeable_patterns.rb b/meta/scripts/find_upgradeable_patterns.rb index 2ac5710a6..2d6cbba2c 100644 --- a/meta/scripts/find_upgradeable_patterns.rb +++ b/meta/scripts/find_upgradeable_patterns.rb @@ -34,13 +34,13 @@ def count_known_instances(file) def collect_section_nodes(file, section_title) markdown = open(file).readlines().join - doc = CommonMarker.render_doc(markdown) + doc = Commonmarker.parse(markdown) title_found = false section_nodes = [] doc.walk do |node| - if node.type == :header + if node.type == :heading if title_found == false node.each do |subnode| if subnode.type == :text and subnode.string_content == section_title @@ -70,7 +70,10 @@ def collect_section_nodes(file, section_title) l1_patterns.each do |file| known_instances_count = count_known_instances(file) - puts "#{known_instances_count} | #{file}" if known_instances_count >= 1 + file_display = file.gsub("../../patterns/1-initial/","") + file_link = file.gsub("../../","https://github.com/InnerSourceCommons/InnerSourcePatterns/blob/main/") + + puts "#{known_instances_count} | [#{file_display}](#{file_link})" end puts "\n" @@ -80,5 +83,8 @@ def collect_section_nodes(file, section_title) l2_patterns.each do |file| known_instances_count = count_known_instances(file) - puts "#{known_instances_count} | #{file}" if known_instances_count >= 3 + file_display = file.gsub("../../patterns/2-structured/","") + file_link = file.gsub("../../","https://github.com/InnerSourceCommons/InnerSourcePatterns/blob/main/") + + puts "#{known_instances_count} | [#{file_display}](#{file_link})" end From 7d340e6cc1e65e52edb2ff3dec4d22eab9c4beae Mon Sep 17 00:00:00 2001 From: Sebastian Spier Date: Sat, 15 Feb 2025 18:01:09 +0100 Subject: [PATCH 2/3] Fix formatting. Add docs. --- meta/scripts/find_upgradeable_patterns.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/meta/scripts/find_upgradeable_patterns.rb b/meta/scripts/find_upgradeable_patterns.rb index 2d6cbba2c..face61c65 100644 --- a/meta/scripts/find_upgradeable_patterns.rb +++ b/meta/scripts/find_upgradeable_patterns.rb @@ -22,6 +22,7 @@ def count_known_instances(file) section_nodes = collect_section_nodes(file, "Known Instances") list_nodes = [] + # pick the first list in the "Known Instances" section, and return the number of elements in that list. # CAUTION: this assumes a certain structure across all patterns. Therefore fairly brittle. list_nodes = section_nodes.select {|n| n.type == :list} @@ -32,6 +33,7 @@ def count_known_instances(file) return known_instances_count end +# Extract all nodes below a given headline def collect_section_nodes(file, section_title) markdown = open(file).readlines().join doc = Commonmarker.parse(markdown) From 050245bd11da7a23befe686dc9c3dc6d278f7393 Mon Sep 17 00:00:00 2001 From: Sebastian Spier Date: Sat, 15 Feb 2025 18:05:32 +0100 Subject: [PATCH 3/3] Cleanup --- meta/scripts/Gemfile | 1 - 1 file changed, 1 deletion(-) diff --git a/meta/scripts/Gemfile b/meta/scripts/Gemfile index 8ed9d9969..1cd3261e2 100644 --- a/meta/scripts/Gemfile +++ b/meta/scripts/Gemfile @@ -4,5 +4,4 @@ source "https://rubygems.org" git_source(:github) {|repo_name| "https://github.com/#{repo_name}" } -# gem 'commonmarker' , '0.14.2' gem 'commonmarker'