Insert sequential links for series in analyze.rb

Signed-off-by: Danila Fedorin <danila.fedorin@gmail.com>
This commit is contained in:
Danila Fedorin 2024-05-30 20:52:14 -07:00
parent 71c030b947
commit d2807917d2

View File

@ -35,6 +35,7 @@ end
data = {} data = {}
id = 0 id = 0
series = {}
files.each do |file| files.each do |file|
id += 1 id += 1
name = file name = file
@ -49,6 +50,12 @@ files.each do |file|
name = $~[1].delete_prefix('"').delete_suffix('"') name = $~[1].delete_prefix('"').delete_suffix('"')
elsif l =~ /^draft: true$/ elsif l =~ /^draft: true$/
draft = true draft = true
elsif l =~ /^series: (.+)$/
this_series = $~[1]
series_list = series.fetch(this_series) do
series[this_series] = []
end
series_list << file
elsif l =~ /^tags: (.+)$/ elsif l =~ /^tags: (.+)$/
tags = $~[1].delete_prefix("[").delete_suffix("]").split(/,\s?/).map { |it| it.gsub('"', '') } tags = $~[1].delete_prefix("[").delete_suffix("]").split(/,\s?/).map { |it| it.gsub('"', '') }
if tags.include? "Compilers" if tags.include? "Compilers"
@ -86,6 +93,14 @@ files.each do |file1|
edges << { :from => data[file1][:id], :to => data[ref][:id] } edges << { :from => data[file1][:id], :to => data[ref][:id] }
end end
end end
series.each do |series, files|
files.sort.each_cons(2) do |file1, file2|
next unless data[file1]
next unless data[file2]
edges << { :from => data[file1][:id], :to => data[file2][:id] }
edges << { :from => data[file2][:id], :to => data[file1][:id] }
end
end
edges.uniq edges.uniq
# edges.filter! { |e| e[:from] < e[:to] } # edges.filter! { |e| e[:from] < e[:to] }