Skip to content

Commit 71a22c5

Browse files
committed
Server - update doc generating script & templates
Both the generating of the documentation TOML files and the Phoenix app's build process are now hooked into the pre-build process. The TOML templates have also been updated.
1 parent bbdd835 commit 71a22c5

File tree

8 files changed

+115
-14
lines changed

8 files changed

+115
-14
lines changed

app/linux-prebuild.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ echo "Translating tutorial..."
3939
ruby "${SCRIPT_DIR}/server/ruby/bin/i18n-tool.rb" -t
4040

4141
echo "Generating docs for the Qt GUI..."
42+
ruby "${SCRIPT_DIR}/server/ruby/bin/qt-doc2.rb"
43+
# TODO: remove the below lines once the new documentation system is integrated into the GUI
4244
cp "${SCRIPT_DIR}/gui/qt/utils/ruby_help.tmpl" "${SCRIPT_DIR}/gui/qt/utils/ruby_help.h"
4345
ruby "${SCRIPT_DIR}/server/ruby/bin/qt-doc.rb" -o "${SCRIPT_DIR}/gui/qt/utils/ruby_help.h"
4446

app/mac-prebuild.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ echo "Translating tutorial..."
7575
$RUBY "${SCRIPT_DIR}/server/ruby/bin/i18n-tool.rb" -t
7676

7777
echo "Generating docs for the Qt GUI..."
78+
$RUBY "${SCRIPT_DIR}/server/ruby/bin/qt-doc2.rb"
79+
# TODO: remove the below lines once the new documentation system is integrated into the GUI
7880
cp "${SCRIPT_DIR}/gui/qt/utils/ruby_help.tmpl" "${SCRIPT_DIR}/gui/qt/utils/ruby_help.h"
7981
$RUBY "${SCRIPT_DIR}/server/ruby/bin/qt-doc.rb" -o "${SCRIPT_DIR}/gui/qt/utils/ruby_help.h"
8082

@@ -90,3 +92,8 @@ mix release
9092

9193
cp src/tau.app.src ebin/tau.app
9294
cd "${SCRIPT_DIR}"
95+
cd "${SCRIPT_DIR}/../etc/docs"
96+
mix deps.get
97+
cd "${SCRIPT_DIR}/../etc/docs/assets"
98+
yarn install
99+
cd "${SCRIPT_DIR}"

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

100644100755
Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ def t_(arg)
4949

5050
private
5151
def generate_docs
52+
puts 'Rendering the interpolated TOML erb files...'
5253
interpolated_file_paths = [synths, fx, samples, lang].each_with_object([]) do |collection, paths|
5354
original_template = File.read(collection[:template_path])
5455
collection[:items].to_a.take(2).each do |key, item|
@@ -58,25 +59,31 @@ def generate_docs
5859
key = key.to_s[3..-1] if collection[:klass] == SonicPi::Synths::FXInfo
5960
interpolated_file_path = "#{collection[:interpolated_path]}/#{key}.toml.erb"
6061
template = ERB.new(original_template, nil, '-').result(binding)
62+
FileUtils.mkdir_p(collection[:interpolated_path]) unless File.exist?(collection[:interpolated_path])
6163
File.open(interpolated_file_path, 'w') do |f|
6264
f.write template
6365
end
6466
paths << interpolated_file_path
6567
end
66-
6768
end
6869
generate_pot_file(interpolated_file_paths)
6970
generate_toml_files
7071
end
7172

7273
def generate_pot_file(interpolated_file_paths)
74+
puts 'Extracting the translatable text into pot file...'
75+
FileUtils.mkdir_p(interpolated_template_path) unless File.exist?(interpolated_template_path)
76+
cwd = Dir.pwd
77+
Dir.chdir(generated_path)
7378
GetText::Tools::XGetText.run(
7479
*interpolated_file_paths,
75-
"-o ../../../../../../etc/doc/generated/toml/synths/test.pot"
80+
'-otest.pot'
7681
)
82+
Dir.chdir(cwd)
7783
end
7884

7985
def generate_toml_files
86+
puts 'Rendering the final TOML output files...'
8087
[synths, fx, samples, lang].each do |collection|
8188
collection[:items].to_a.take(2).each do |key, item|
8289
key = key.to_s[3..-1] if collection[:klass] == SonicPi::Synths::FXInfo
@@ -90,6 +97,7 @@ def generate_toml_files
9097
end
9198

9299
def sync_to_documentation_app
100+
puts 'Syncing the TOML files to the documentation web app...'
93101
FileUtils.cp_r(doc_toml_path, documentation_app_priv_path, remove_destination: true)
94102
end
95103

@@ -137,7 +145,6 @@ def lang
137145
output_path: lang_toml_path
138146
}
139147
end
140-
141148
end
142149

143150
QtDocs.new.run

app/win-prebuild.bat

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ xcopy /Y /I /R /E external\build\sp_link-prefix\src\sp_link-build\Release\*.dll
4747
server\native\ruby\bin\ruby server/ruby/bin/i18n-tool.rb -t
4848

4949
@echo Generating docs for the Qt GUI...
50+
server\native\ruby\bin\ruby server/ruby/bin/qt-doc2.rb
51+
REM TODO: remove the below lines once the new documentation system is integrated into the GUI
5052
copy /Y gui\qt\utils\ruby_help.tmpl gui\qt\utils\ruby_help.h
5153
server\native\ruby\bin\ruby server/ruby/bin/qt-doc.rb -o gui\qt\utils/ruby_help.h
5254

etc/doc/templates/lang.toml.erb

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@
22
t_(<<~TEXT.chomp
33
# This is a data file that contains information describing the text that is
44
# displayed on pages in the Lang section of Sonic Pi's help panel.
5+
6+
# A unique identifier for this function.
7+
# (For example: chord).
58
TEXT
69
)
710
%>
8-
<%
9-
summary = item[:summary]
10-
summary[0] = summary[0].capitalize
11-
%>
1211
[<%= item[:name] %>]
1312

1413
<%=
@@ -17,6 +16,10 @@ t_(<<~TEXT.chomp
1716
# a summary phrase: 'Create chord').
1817
TEXT
1918
)
19+
-%>
20+
<%
21+
summary = item[:summary]
22+
summary[0] = summary[0].capitalize
2023
%>
2124
summary = "<%= t_(summary) %>"
2225

@@ -81,4 +84,7 @@ label_plural = "<%= t_('Examples') %>"
8184
<% item[:examples].each_with_index do |e, index| %>
8285
[[<%= item[:name] %>.examples.list]]
8386
label = "<%= t_("Example #{index + 1}") %>"
87+
example = '''
88+
<%= e %>
89+
'''
8490
<% end %>

etc/doc/templates/samples.toml.erb

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
<%=
2+
t_(<<~TEXT.chomp
3+
# This is a data file that contains information describing the text that is
4+
# displayed on pages in the Samples section of Sonic Pi's help panel.
5+
6+
# A unique identifier for a group of samples, so that samples are grouped
7+
# into 'categories'.
8+
# (For example: ambi).
9+
TEXT
10+
)
11+
%>
12+
[<%= key %>]
13+
14+
<%=
15+
t_(<<~TEXT.chomp
16+
# A word or short phrase that is used as a label for the sample group.
17+
# (For example: Ambient Sounds).
18+
TEXT
19+
)
20+
%>
21+
name = "<%= t_(item[:desc]) %>"
22+
23+
<%= t_('# Basic code examples of how to use the samples in the group.') %>
24+
usage = '''
25+
<%= item[:samples].map do |s|
26+
"sample :#{s}"
27+
end.join("\n")
28+
%>
29+
'''
30+
31+
<%=
32+
t_(<<~TEXT.chomp
33+
# The options are the opts of the sample function.
34+
# In the documentation, we currently display two tables of opts:
35+
# - one listing the name of each opt and its default value for easy reference
36+
# - a second, more detailed table labelled 'Options', containing:
37+
# - the name of each opt
38+
# - a detailed description of it
39+
# - its default value
40+
# - (if the opt has constraints (limits or a specific range of permitted
41+
# values, etc)): the constraints of the opt
42+
# - a label describing whether this opt can be modulated (altered) while the
43+
# sample is running
44+
# - (if the opt is slidable): a label indicating that the opt is slidable
45+
TEXT
46+
)
47+
%>
48+
[<%= key %>.options]
49+
label = "<%= t_('Options') %>"
50+
<% data_object.arg_info.each do |name, attributes| %>
51+
[[<%= key %>.options.list]]
52+
name = "<%= name %>:"
53+
doc = '''
54+
<%= t_(attributes[:doc] || 'write me') %>
55+
'''
56+
default_value = "<%= attributes[:default] %>"
57+
<% unless attributes[:constraints].empty? -%>
58+
constraints = '''
59+
<%= t_(attributes[:constraints].join(', ').capitalize) %>
60+
'''
61+
<% end -%>
62+
modulatable = '''
63+
<%=
64+
t_(
65+
if attributes[:modulatable]
66+
'May be changed whilst playing'
67+
else
68+
'Can not be changed once set'
69+
end
70+
)
71+
%>
72+
'''
73+
<% end -%>
74+
75+
<%=
76+
if data_object.arg_info.any? { |name, arg| arg[:slidable] }
77+
ERB.new(File.read(slides_template_path), nil, '-', eoutvar: '_slide01').result(binding)
78+
end
79+
%>

etc/doc/templates/slides.toml.erb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ Any parameter that is slidable has three additional options named _slide,
77
slide_curve, and _slide_shape. For example, 'amp' is slidable, so you can also
88
set amp_slide, amp_slide_curve, and amp_slide_shape with the following effects:
99
TEXT
10-
)
11-
%>
10+
)%>
1211
'''
1312
<%
1413
slide_opts = {

etc/doc/templates/synth_and_fx.toml.erb

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@ t_(<<~TEXT.chomp
33
# This is a data file that contains information describing the text that is
44
# displayed on pages in the Synths section of Sonic Pi's help panel.
55

6-
# A unique identifier for this synth or fx, the word that is typed in the code
7-
# to use it.
8-
# (For example: :pretty_bell).
6+
# A unique identifier for this synth or fx.
7+
# (For example: pretty_bell).
98
TEXT
109
)
1110
%>
@@ -74,11 +73,11 @@ label = "<%= t_('Options') %>"
7473
name = "<%= name %>:"
7574
doc = "<%= t_(attributes[:doc] || 'write me') %>"
7675
default_value = "<%= attributes[:default] %>"
77-
<% unless attributes[:constraints].empty? %>
76+
<% unless attributes[:constraints].empty? -%>
7877
constraints = '''
7978
<%= t_(attributes[:constraints].join(', ').capitalize) %>
8079
'''
81-
<% end %>
80+
<% end -%>
8281
modulatable = '''
8382
<%=
8483
t_(

0 commit comments

Comments
 (0)