def create_language_specific_doc_lists!(dir, language, software_name)
if File.exist?("#{dir}/index.docbook")
# When there is an index.docbook we mustn't copy the en_US version as
# we have to write our own CMakeLists in order to have things installed
# in the correct language directory! Also see kdoctools_create_handbook
# arguments.
write_handbook(dir, language, software_name)
elsif !Dir.glob("#{dir}/*").select { |f| File.directory?(f) }.empty?
# -- Recyle en_US' CMakeLists --
enusdir = "#{dir}/../en_US/"
enuscmake = "#{enusdir}/CMakeLists.txt"
if File.exist?(enuscmake)
# FIXME: naughty
FileUtils.cp(enuscmake, dir) unless File.basename(dir) == 'en_US'
Dir.glob("#{dir}/**/**").each do |current_dir|
next unless File.directory?(current_dir)
next if File.basename(dir) == 'en_US'
dir_pathname = Pathname.new(dir)
current_dir_pathname = Pathname.new(current_dir)
relative_path = current_dir_pathname.relative_path_from(dir_pathname)
# FIXME: this will fail if the cmakelists doesn't exist, which is
# possible but also a bit odd, not sure if we should just
# ignore that...
# FIXME: has no test backing I think
cmakefile = "#{enusdir}/#{relative_path}/CMakeLists.txt"
FileUtils.cp(cmakefile, current_dir) if File.exist?(cmakefile)
end
Dir.glob("#{dir}/**/index.docbook").each do |docbook|
# FIXME: subdir logic needs testing through documentation class
# FIXME: this is not tested via our tests
dirname = File.dirname(docbook)
dir_pathname = Pathname.new(dir)
current_dir_pathname = Pathname.new(dirname)
relative_path = current_dir_pathname.relative_path_from(dir_pathname)
subdir = File.join(relative_path)
subdir.chomp!(File::SEPARATOR)
# FIXME: no test backing
write_handbook(dirname, language, subdir)
end
else
fail 'there is no cmakelists in enUS and also no index.docbook'
end
else
fail 'There is no index.docbook but also no directories'
end
# en_US may already have a super cmakelists, do not twiddle with it!
log_debug "Writing main cmakelists #{dir}/../CMakeLists.txt"
File.open("#{dir}/../CMakeLists.txt", 'a') do |f|
f.write(add_subdirectory(dir))
end
end