Skip to content

Commit be34ddd

Browse files
committed
Server - update doc generating script & templates
The translation pot file needs to contain references to files from *all* of the different documentation sections, to reduce duplication. To achieve this, we now process all of the collections of documentation data (synths/fx/lang/etc) as a single group. Several minor updates to the base templates have also been made.
1 parent 35645f2 commit be34ddd

File tree

6 files changed

+129
-501
lines changed

6 files changed

+129
-501
lines changed

app/server/ruby/bin/qt-doc2.rb

Lines changed: 50 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -36,45 +36,70 @@ class QtDocs
3636
include SonicPi::Util
3737
include GetText
3838

39+
def doc_collections
40+
synths = SonicPi::Synths::SynthInfo.get_all.select do |k, v|
41+
v.is_a?(SonicPi::Synths::SynthInfo) && v.user_facing?
42+
end
43+
[
44+
{
45+
items: synths,
46+
template_path: synth_and_fx_template_path,
47+
interpolated_path: synths_interpolated_path,
48+
output_path: synths_toml_path,
49+
klass: SonicPi::Synths::SynthInfo
50+
},
51+
{
52+
items: @@docs,
53+
template_path: lang_template_path,
54+
interpolated_path: lang_interpolated_path,
55+
output_path: lang_toml_path
56+
}
57+
]
58+
end
59+
3960
def run
40-
# _generate_lang_docs
41-
_generate_synth_docs
61+
_generate_docs
4262
end
4363

4464
def t_(arg)
4565
"<%= _(\"#{arg}\") %>"
4666
end
4767

4868
private
49-
def _generate_lang_docs
50-
_generate_docs(@@docs, lang_template_path, lang_toml_path)
69+
def _generate_docs
70+
interpolated_file_paths = doc_collections.each_with_object([]) do |collection, paths|
71+
original_template = File.read(collection[:template_path])
72+
collection[:items].to_a.take(2).each do |key, item|
73+
interpolated_file_path = "#{collection[:interpolated_path]}/#{key}.toml.erb"
74+
template = ERB.new(original_template).result(binding)
75+
File.open(interpolated_file_path, 'w') do |f|
76+
f.write template
77+
end
78+
paths << interpolated_file_path
79+
end
80+
end
81+
_generate_pot_file(interpolated_file_paths)
82+
_generate_toml_files
83+
5184
end
5285

53-
def _generate_synth_docs
54-
collection = SonicPi::Synths::SynthInfo.get_all.select do |k, v|
55-
v.is_a?(SonicPi::Synths::SynthInfo) && v.user_facing?
56-
end
57-
_generate_docs(
58-
collection,
59-
synth_and_fx_template_path,
60-
synth_toml_path,
61-
SonicPi::Synths::SynthInfo
86+
87+
def _generate_pot_file(interpolated_file_paths)
88+
GetText::Tools::XGetText.run(
89+
*interpolated_file_paths,
90+
"-o ../../../../../../etc/doc/generated/toml/synths/test.pot"
6291
)
6392
end
6493

65-
def _generate_docs(collection, template_path, output_path, klass = nil)
66-
original_template = File.read(template_path)
67-
collection.to_a.take(2).map do |key, item|
68-
template = ERB.new(original_template).result(binding)
69-
interpolated_path = "#{interpolated_template_path}/#{key}.toml.erb"
70-
File.open(interpolated_path, 'w') do |f|
71-
f.write template
94+
def _generate_toml_files
95+
doc_collections.each do |collection|
96+
collection[:items].to_a.take(2).each do |key, item|
97+
interpolated_file = File.read("#{collection[:interpolated_path]}/#{key}.toml.erb")
98+
output = ERB.new(interpolated_file).result(binding)
99+
File.open("#{collection[:output_path]}/#{key}.toml", 'w') do |f|
100+
f.write output
101+
end
72102
end
73-
74-
GetText::Tools::XGetText.run(
75-
interpolated_path,
76-
"-o ../../../../../../etc/doc/generated/toml/synths/test.pot"
77-
)
78103
end
79104
end
80105
end

etc/doc/templates/interpolated/dull_bell.toml.erb

Lines changed: 0 additions & 221 deletions
This file was deleted.

0 commit comments

Comments
 (0)