From 6d4d48e30ad1c0961ad9679c0438cc6518660bab Mon Sep 17 00:00:00 2001 From: Ethan Crawford Date: Wed, 8 Sep 2021 21:21:11 +0800 Subject: [PATCH] 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. --- app/server/ruby/bin/qt-doc2.rb | 32 ++++++------ app/server/ruby/paths.rb | 68 +++++++++++++++++++++++++ etc/doc/templates/samples.toml.erb | 2 +- etc/doc/templates/synth_and_fx.toml.erb | 2 +- 4 files changed, 86 insertions(+), 18 deletions(-) diff --git a/app/server/ruby/bin/qt-doc2.rb b/app/server/ruby/bin/qt-doc2.rb index 2a1d05b354..64ed06ee18 100755 --- a/app/server/ruby/bin/qt-doc2.rb +++ b/app/server/ruby/bin/qt-doc2.rb @@ -25,12 +25,12 @@ require_relative "../lib/sonicpi/lang/sound" require_relative "../lib/sonicpi/lang/minecraftpi" require_relative "../lib/sonicpi/lang/midi" +require_relative '../paths' require 'active_support/inflector' require 'erb' require 'gettext' require "gettext/tools/xgettext" - class QtDocs include SonicPi::Lang::Support::DocSystem include SonicPi::Util @@ -72,9 +72,9 @@ def generate_docs def generate_pot_file(interpolated_file_paths) puts 'Extracting the translatable text into pot file...' - FileUtils.mkdir_p(interpolated_template_path) unless File.exist?(interpolated_template_path) + FileUtils.mkdir_p(::SonicPi::Paths.interpolated_template_path) unless File.exist?(::SonicPi::Paths.interpolated_template_path) cwd = Dir.pwd - Dir.chdir(generated_path) + Dir.chdir(::SonicPi::Paths.generated_path) GetText::Tools::XGetText.run( *interpolated_file_paths, '-otest.pot' @@ -98,7 +98,7 @@ def generate_toml_files def sync_to_documentation_app puts 'Syncing the TOML files to the documentation web app...' - FileUtils.cp_r(doc_toml_path, documentation_app_priv_path, remove_destination: true) + FileUtils.cp_r(::SonicPi::Paths.doc_toml_path, ::SonicPi::Paths.documentation_app_priv_path, remove_destination: true) end def synths @@ -107,9 +107,9 @@ def synths end { items: items, - template_path: synth_and_fx_template_path, - interpolated_path: synths_interpolated_path, - output_path: synths_toml_path, + template_path: ::SonicPi::Paths.synth_and_fx_template_path, + interpolated_path: ::SonicPi::Paths.synths_interpolated_path, + output_path: ::SonicPi::Paths.synths_toml_path, klass: SonicPi::Synths::SynthInfo } end @@ -120,9 +120,9 @@ def fx end { items: items, - template_path: synth_and_fx_template_path, - interpolated_path: fx_interpolated_path, - output_path: fx_toml_path, + template_path: ::SonicPi::Paths.synth_and_fx_template_path, + interpolated_path: ::SonicPi::Paths.fx_interpolated_path, + output_path: ::SonicPi::Paths.fx_toml_path, klass: SonicPi::Synths::FXInfo } end @@ -130,9 +130,9 @@ def fx def samples { items: SonicPi::Synths::SynthInfo.grouped_samples, - template_path: samples_template_path, - interpolated_path: samples_interpolated_path, - output_path: samples_toml_path, + template_path: ::SonicPi::Paths.samples_template_path, + interpolated_path: ::SonicPi::Paths.samples_interpolated_path, + output_path: ::SonicPi::Paths.samples_toml_path, data_object: SonicPi::Synths::StereoPlayer.new } end @@ -140,9 +140,9 @@ def samples def lang { items: @@docs, - template_path: lang_template_path, - interpolated_path: lang_interpolated_path, - output_path: lang_toml_path + template_path: ::SonicPi::Paths.lang_template_path, + interpolated_path: ::SonicPi::Paths.lang_interpolated_path, + output_path: ::SonicPi::Paths.lang_toml_path } end end diff --git a/app/server/ruby/paths.rb b/app/server/ruby/paths.rb index 08ec291ccc..b37552b4fd 100644 --- a/app/server/ruby/paths.rb +++ b/app/server/ruby/paths.rb @@ -61,6 +61,10 @@ def self.doc_path File.absolute_path("#{etc_path}/doc") end + def self.generated_path + File.absolute_path("#{doc_path}/generated") + end + def self.cheatsheets_path File.absolute_path("#{doc_path}/cheatsheets") end @@ -69,6 +73,70 @@ def self.tutorial_path File.absolute_path("#{doc_path}/tutorial") end + def self.doc_templates_path + File.absolute_path("#{doc_path}/templates") + end + + def self.lang_template_path + File.absolute_path("#{doc_templates_path}/lang.toml.erb") + end + + def self.synth_and_fx_template_path + File.absolute_path("#{doc_templates_path}/synth_and_fx.toml.erb") + end + + def self.slides_template_path + File.absolute_path("#{doc_templates_path}/slides.toml.erb") + end + + def self.samples_template_path + File.absolute_path("#{doc_templates_path}/samples.toml.erb") + end + + def self.interpolated_template_path + File.absolute_path("#{generated_path}/interpolated_templates") + end + + def self.lang_interpolated_path + File.absolute_path("#{interpolated_template_path}/lang") + end + + def self.synths_interpolated_path + File.absolute_path("#{interpolated_template_path}/synths") + end + + def self.fx_interpolated_path + File.absolute_path("#{interpolated_template_path}/fx") + end + + def self.samples_interpolated_path + File.absolute_path("#{interpolated_template_path}/samples") + end + + def self.doc_toml_path + File.absolute_path("#{doc_path}/generated/toml") + end + + def self.lang_toml_path + File.absolute_path("#{doc_toml_path}/lang") + end + + def self.synths_toml_path + File.absolute_path("#{doc_toml_path}/synths") + end + + def self.fx_toml_path + File.absolute_path("#{doc_toml_path}/fx") + end + + def self.samples_toml_path + File.absolute_path("#{doc_toml_path}/samples") + end + + def self.documentation_app_priv_path + File.absolute_path("#{etc_path}/docs/priv/") + end + def self.tmp_path File.absolute_path("#{root_path}/tmp") end diff --git a/etc/doc/templates/samples.toml.erb b/etc/doc/templates/samples.toml.erb index 87b3a92951..7231657f0c 100644 --- a/etc/doc/templates/samples.toml.erb +++ b/etc/doc/templates/samples.toml.erb @@ -74,6 +74,6 @@ t_( <%= if data_object.arg_info.any? { |name, arg| arg[:slidable] } - ERB.new(File.read(slides_template_path), nil, '-', eoutvar: '_slide01').result(binding) + ERB.new(File.read(::SonicPi::Paths.slides_template_path), nil, '-', eoutvar: '_slide01').result(binding) end %> diff --git a/etc/doc/templates/synth_and_fx.toml.erb b/etc/doc/templates/synth_and_fx.toml.erb index 2aef7e4cbd..580c24daf5 100644 --- a/etc/doc/templates/synth_and_fx.toml.erb +++ b/etc/doc/templates/synth_and_fx.toml.erb @@ -92,6 +92,6 @@ t_( <% end %> <%= if item.arg_info.any? { |name, arg| arg[:slidable] } - ERB.new(File.read(slides_template_path), nil, '-', eoutvar: '_slide01').result(binding) + ERB.new(File.read(::SonicPi::Paths.slides_template_path), nil, '-', eoutvar: '_slide01').result(binding) end %>