# frozen_string_literal: true require "yard" def yard_replace(dir, version) sha = `git rev-parse HEAD`.strip tag = `git describe --exact-match #{sha}` tag = tag.empty? ? "(main)" : tag.strip Dir.glob("#{dir}/**/*.html") do |file| next if (m = file.match(/[0-9]+\.[0-9]+\.[0-9]+(-[a-z]+)?/)) && m[0] != version contents = File.read(file) contents.gsub!(Regexp.new(<<-'HTML1'), <<-HTML2)
HTML1 HTML2 contents.gsub!(<<-'HTML3', <<-HTML4)