@@ -36,45 +36,70 @@ class QtDocs
36
36
include SonicPi ::Util
37
37
include GetText
38
38
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
+
39
60
def run
40
- # _generate_lang_docs
41
- _generate_synth_docs
61
+ _generate_docs
42
62
end
43
63
44
64
def t_ ( arg )
45
65
"<%= _(\" #{ arg } \" ) %>"
46
66
end
47
67
48
68
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
+
51
84
end
52
85
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"
62
91
)
63
92
end
64
93
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
72
102
end
73
-
74
- GetText ::Tools ::XGetText . run (
75
- interpolated_path ,
76
- "-o ../../../../../../etc/doc/generated/toml/synths/test.pot"
77
- )
78
103
end
79
104
end
80
105
end
0 commit comments