| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
require "find" |
| 20 |
|
| 21 |
IGNORE_PATHS = [ |
| 22 |
".buildinfo", |
| 23 |
".buildinfo.bak", |
| 24 |
|
| 25 |
|
| 26 |
"_static/base-stemmer.js", |
| 27 |
"_static/english-stemmer.js", |
| 28 |
] |
| 29 |
|
| 30 |
def list_paths(variable_name, paths, output) |
| 31 |
output.puts("#{variable_name} = \\") |
| 32 |
paths.each do |path| |
| 33 |
output.puts("\t#{path} \\") |
| 34 |
end |
| 35 |
output.puts("\t$(NULL)") |
| 36 |
output.puts |
| 37 |
end |
| 38 |
|
| 39 |
source_dir = File.expand_path(__dir__) |
| 40 |
|
| 41 |
|
| 42 |
File.open(File.join(source_dir, "files.am"), "w") do |output| |
| 43 |
|
| 44 |
Dir.chdir(source_dir) do |
| 45 |
files = [] |
| 46 |
Find.find("source") do |path| |
| 47 |
next unless File.file?(path) |
| 48 |
next if path.end_with?(".pyc") |
| 49 |
files << path |
| 50 |
end |
| 51 |
files.sort! |
| 52 |
|
| 53 |
list_paths("absolute_source_files", |
| 54 |
files.collect {|file| "$(top_srcdir)/doc/#{file}"}, |
| 55 |
output) |
| 56 |
|
| 57 |
list_paths("source_files_relative_from_doc_dir", |
| 58 |
files, |
| 59 |
output) |
| 60 |
end |
| 61 |
|
| 62 |
|
| 63 |
pot_files = Dir.chdir("en/gettext") do |
| 64 |
Dir.glob("**/*.pot").sort |
| 65 |
end |
| 66 |
["po", "edit_po", "mo"].each do |type| |
| 67 |
if type == "edit_po" |
| 68 |
extension = ".edit" |
| 69 |
else |
| 70 |
extension = ".#{type}" |
| 71 |
end |
| 72 |
target_files = pot_files.collect {|pot| pot.gsub(/\.pot\z/, extension)} |
| 73 |
list_paths("#{type}_files", target_files, output) |
| 74 |
list_paths("#{type}_files_relative_from_locale_dir", |
| 75 |
target_files.collect {|path| "LC_MESSAGES/#{path}"}, |
| 76 |
output) |
| 77 |
end |
| 78 |
|
| 79 |
|
| 80 |
Dir.chdir("en") do |
| 81 |
|
| 82 |
html_files = [] |
| 83 |
Find.find("html") do |path| |
| 84 |
next unless File.file?(path) |
| 85 |
next if IGNORE_PATHS.include?(path.delete_prefix("html/")) |
| 86 |
if path.start_with?("html/reference/api/") |
| 87 |
base_name = File.basename(path, ".html") |
| 88 |
source = File.join(source_dir, |
| 89 |
"source", |
| 90 |
"reference", |
| 91 |
"api", |
| 92 |
"#{base_name}.rst") |
| 93 |
|
| 94 |
next unless File.exist?(source) |
| 95 |
end |
| 96 |
html_files << path |
| 97 |
end |
| 98 |
html_files.sort! |
| 99 |
list_paths("html_files_relative_from_locale_dir", html_files, output) |
| 100 |
end |
| 101 |
end |
| 102 |
|
| 103 |
|
| 104 |
File.open(File.join(source_dir, "files.cmake"), "w") do |output| |
| 105 |
|
| 106 |
Dir.chdir(File.join(source_dir, "source")) do |
| 107 |
files = [] |
| 108 |
Find.find(".") do |path| |
| 109 |
path = path.delete_prefix("./") |
| 110 |
next unless File.file?(path) |
| 111 |
next if path.end_with?(".pyc") |
| 112 |
files << path |
| 113 |
end |
| 114 |
files.sort! |
| 115 |
output.print("set(GRN_DOC_SOURCES") |
| 116 |
files.each do |file| |
| 117 |
output.puts |
| 118 |
output.print(" #{file}") |
| 119 |
end |
| 120 |
output.puts(")") |
| 121 |
output.puts |
| 122 |
end |
| 123 |
|
| 124 |
|
| 125 |
Dir.chdir("en/html") do |
| 126 |
|
| 127 |
html_files = [] |
| 128 |
Find.find(".") do |path| |
| 129 |
path = path.delete_prefix("./") |
| 130 |
next unless File.file?(path) |
| 131 |
next if IGNORE_PATHS.include?(path) |
| 132 |
if path.start_with?("reference/api/") |
| 133 |
base_name = File.basename(path, ".html") |
| 134 |
source = File.join(source_dir, |
| 135 |
"source", |
| 136 |
"reference", |
| 137 |
"api", |
| 138 |
"#{base_name}.rst") |
| 139 |
|
| 140 |
next unless File.exist?(source) |
| 141 |
end |
| 142 |
html_files << path |
| 143 |
end |
| 144 |
html_files.sort! |
| 145 |
output.print("set(GRN_DOC_HTML_FILES") |
| 146 |
html_files.each do |html_file| |
| 147 |
output.puts |
| 148 |
output.print(" #{html_file}") |
| 149 |
end |
| 150 |
output.puts(")") |
| 151 |
end |
| 152 |
end |