Skip to content

Commit

Permalink
Spider - fix paths
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ethancrawford committed Sep 8, 2021
1 parent 4393c08 commit 6d4d48e
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 18 deletions.
32 changes: 16 additions & 16 deletions app/server/ruby/bin/qt-doc2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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'
Expand All @@ -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
Expand All @@ -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
Expand All @@ -120,29 +120,29 @@ 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

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

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
Expand Down
68 changes: 68 additions & 0 deletions app/server/ruby/paths.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion etc/doc/templates/samples.toml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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
%>
2 changes: 1 addition & 1 deletion etc/doc/templates/synth_and_fx.toml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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
%>

0 comments on commit 6d4d48e

Please sign in to comment.