Skip to content

Commit 1260147

Browse files
committed
Spider - fix paths
The utility functions were previously moved to a dedicated Paths module. This caused a conflict with the documentation rebuild code, but it has now been resolved.
1 parent 4393c08 commit 1260147

File tree

4 files changed

+88
-18
lines changed

4 files changed

+88
-18
lines changed

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

+18-16
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@
2525
require_relative "../lib/sonicpi/lang/sound"
2626
require_relative "../lib/sonicpi/lang/minecraftpi"
2727
require_relative "../lib/sonicpi/lang/midi"
28+
require_relative '../paths'
2829
require 'active_support/inflector'
2930
require 'erb'
3031
require 'gettext'
3132
require "gettext/tools/xgettext"
3233

33-
3434
class QtDocs
3535
include SonicPi::Lang::Support::DocSystem
3636
include SonicPi::Util
@@ -72,9 +72,10 @@ def generate_docs
7272

7373
def generate_pot_file(interpolated_file_paths)
7474
puts 'Extracting the translatable text into pot file...'
75-
FileUtils.mkdir_p(interpolated_template_path) unless File.exist?(interpolated_template_path)
75+
FileUtils.mkdir_p(::SonicPi::Paths.interpolated_template_path) unless File.exist?(::SonicPi::Paths.interpolated_template_path)
7676
cwd = Dir.pwd
77-
Dir.chdir(generated_path)
77+
FileUtils.mkdir_p(::SonicPi::Paths.generated_path) unless File.exist?(::SonicPi::Paths.generated_path)
78+
Dir.chdir(::SonicPi::Paths.generated_path)
7879
GetText::Tools::XGetText.run(
7980
*interpolated_file_paths,
8081
'-otest.pot'
@@ -89,6 +90,7 @@ def generate_toml_files
8990
key = key.to_s[3..-1] if collection[:klass] == SonicPi::Synths::FXInfo
9091
interpolated_file = File.read("#{collection[:interpolated_path]}/#{key}.toml.erb")
9192
output = ERB.new(interpolated_file, nil, '-').result(binding)
93+
FileUtils.mkdir_p(collection[:output_path]) unless File.exist?(collection[:output_path])
9294
File.open("#{collection[:output_path]}/#{key}.toml", 'w') do |f|
9395
f.write output
9496
end
@@ -98,7 +100,7 @@ def generate_toml_files
98100

99101
def sync_to_documentation_app
100102
puts 'Syncing the TOML files to the documentation web app...'
101-
FileUtils.cp_r(doc_toml_path, documentation_app_priv_path, remove_destination: true)
103+
FileUtils.cp_r(::SonicPi::Paths.doc_toml_path, ::SonicPi::Paths.documentation_app_priv_path, remove_destination: true)
102104
end
103105

104106
def synths
@@ -107,9 +109,9 @@ def synths
107109
end
108110
{
109111
items: items,
110-
template_path: synth_and_fx_template_path,
111-
interpolated_path: synths_interpolated_path,
112-
output_path: synths_toml_path,
112+
template_path: ::SonicPi::Paths.synth_and_fx_template_path,
113+
interpolated_path: ::SonicPi::Paths.synths_interpolated_path,
114+
output_path: ::SonicPi::Paths.synths_toml_path,
113115
klass: SonicPi::Synths::SynthInfo
114116
}
115117
end
@@ -120,29 +122,29 @@ def fx
120122
end
121123
{
122124
items: items,
123-
template_path: synth_and_fx_template_path,
124-
interpolated_path: fx_interpolated_path,
125-
output_path: fx_toml_path,
125+
template_path: ::SonicPi::Paths.synth_and_fx_template_path,
126+
interpolated_path: ::SonicPi::Paths.fx_interpolated_path,
127+
output_path: ::SonicPi::Paths.fx_toml_path,
126128
klass: SonicPi::Synths::FXInfo
127129
}
128130
end
129131

130132
def samples
131133
{
132134
items: SonicPi::Synths::SynthInfo.grouped_samples,
133-
template_path: samples_template_path,
134-
interpolated_path: samples_interpolated_path,
135-
output_path: samples_toml_path,
135+
template_path: ::SonicPi::Paths.samples_template_path,
136+
interpolated_path: ::SonicPi::Paths.samples_interpolated_path,
137+
output_path: ::SonicPi::Paths.samples_toml_path,
136138
data_object: SonicPi::Synths::StereoPlayer.new
137139
}
138140
end
139141

140142
def lang
141143
{
142144
items: @@docs,
143-
template_path: lang_template_path,
144-
interpolated_path: lang_interpolated_path,
145-
output_path: lang_toml_path
145+
template_path: ::SonicPi::Paths.lang_template_path,
146+
interpolated_path: ::SonicPi::Paths.lang_interpolated_path,
147+
output_path: ::SonicPi::Paths.lang_toml_path
146148
}
147149
end
148150
end

app/server/ruby/paths.rb

+68
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ def self.doc_path
6161
File.absolute_path("#{etc_path}/doc")
6262
end
6363

64+
def self.generated_path
65+
File.absolute_path("#{doc_path}/generated")
66+
end
67+
6468
def self.cheatsheets_path
6569
File.absolute_path("#{doc_path}/cheatsheets")
6670
end
@@ -69,6 +73,70 @@ def self.tutorial_path
6973
File.absolute_path("#{doc_path}/tutorial")
7074
end
7175

76+
def self.doc_templates_path
77+
File.absolute_path("#{doc_path}/templates")
78+
end
79+
80+
def self.lang_template_path
81+
File.absolute_path("#{doc_templates_path}/lang.toml.erb")
82+
end
83+
84+
def self.synth_and_fx_template_path
85+
File.absolute_path("#{doc_templates_path}/synth_and_fx.toml.erb")
86+
end
87+
88+
def self.slides_template_path
89+
File.absolute_path("#{doc_templates_path}/slides.toml.erb")
90+
end
91+
92+
def self.samples_template_path
93+
File.absolute_path("#{doc_templates_path}/samples.toml.erb")
94+
end
95+
96+
def self.interpolated_template_path
97+
File.absolute_path("#{generated_path}/interpolated_templates")
98+
end
99+
100+
def self.lang_interpolated_path
101+
File.absolute_path("#{interpolated_template_path}/lang")
102+
end
103+
104+
def self.synths_interpolated_path
105+
File.absolute_path("#{interpolated_template_path}/synths")
106+
end
107+
108+
def self.fx_interpolated_path
109+
File.absolute_path("#{interpolated_template_path}/fx")
110+
end
111+
112+
def self.samples_interpolated_path
113+
File.absolute_path("#{interpolated_template_path}/samples")
114+
end
115+
116+
def self.doc_toml_path
117+
File.absolute_path("#{doc_path}/generated/toml")
118+
end
119+
120+
def self.lang_toml_path
121+
File.absolute_path("#{doc_toml_path}/lang")
122+
end
123+
124+
def self.synths_toml_path
125+
File.absolute_path("#{doc_toml_path}/synths")
126+
end
127+
128+
def self.fx_toml_path
129+
File.absolute_path("#{doc_toml_path}/fx")
130+
end
131+
132+
def self.samples_toml_path
133+
File.absolute_path("#{doc_toml_path}/samples")
134+
end
135+
136+
def self.documentation_app_priv_path
137+
File.absolute_path("#{etc_path}/docs/priv/")
138+
end
139+
72140
def self.tmp_path
73141
File.absolute_path("#{root_path}/tmp")
74142
end

etc/doc/templates/samples.toml.erb

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,6 @@ t_(
7474

7575
<%=
7676
if data_object.arg_info.any? { |name, arg| arg[:slidable] }
77-
ERB.new(File.read(slides_template_path), nil, '-', eoutvar: '_slide01').result(binding)
77+
ERB.new(File.read(::SonicPi::Paths.slides_template_path), nil, '-', eoutvar: '_slide01').result(binding)
7878
end
7979
%>

etc/doc/templates/synth_and_fx.toml.erb

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,6 @@ t_(
9292
<% end %>
9393
<%=
9494
if item.arg_info.any? { |name, arg| arg[:slidable] }
95-
ERB.new(File.read(slides_template_path), nil, '-', eoutvar: '_slide01').result(binding)
95+
ERB.new(File.read(::SonicPi::Paths.slides_template_path), nil, '-', eoutvar: '_slide01').result(binding)
9696
end
9797
%>

0 commit comments

Comments
 (0)