]> git.donarmstrong.com Git - lilypond.git/blob - scripts/build/create-weblinks-itexi.py
Build: fix 1169 and 1170.
[lilypond.git] / scripts / build / create-weblinks-itexi.py
1 #!@PYTHON@
2 # -*- coding: utf-8 -*-
3 # create-version-itexi.py
4
5 """ when being called on lilypond.org, pass it the location of the
6 top source dir on the command-line. """
7
8 import sys
9 import os
10 import glob
11
12 # these links are relative from /website/ on lilypond.org
13 depth = "../"
14
15 ### translation data -- shouldn't be here; see issue
16 ### http://code.google.com/p/lilypond/issues/detail?id=1050
17
18 langs = ['', 'de', 'es', 'fr', 'hu', 'it', 'ja', 'nl']
19
20 # Get/update node translations
21 '''
22 for i in de es fr hu it ja nl; do
23     echo "'"$i"': {"
24     (echo '--' ; grep -nH -B1 translationof Documentation/$i/web/* ) \
25         | pytt '^--\n.*@(?:unnum|sub)[^ ]* (.*)\n.*@translationof (.*)\n' "'\2': '\1',\n" \
26         | grep -E 'Source|Learning|Glossary|Essay|Notation|Usage|Snippets|Web|Changes|Extending|Internals|Contributor'
27     echo "},"
28 done
29 '''
30
31 translations = {
32     'de': {
33         'Source': 'Quellen',
34         'Learning': 'Einführung',
35         'Music glossary': 'Glossar',
36         'Essay': 'Aufsatz',
37         'Notation': 'Notation',
38         'Usage': 'Benutzung',
39         'Snippets': 'Schnipsel',
40         'Web': 'Web',
41         'Changes': 'Änderungen',
42
43         'Extending': 'Erweitern',
44         'Internals': 'Interna',
45         'Contributor': 'Beitragen',
46
47         ' (split HTML)': ' (geteiltes HTML)',
48         ' (big HTML)': ' (großes HTML)',
49
50         'Regression tests for ': 'Regressionstests für ',
51         'PDF of regtests for ': 'PDF der Regressionstests für ',
52         'MusicXML Regression tests for ': 'MusicXML Regressionstests für ',
53         'PDF of MusicXML regtests for ': 'PDF der MusicXML Regressionstests für ',
54
55         'Doc tarball for ': 'Dokumentation tar-gepackt für ',
56         ' (did not exist in 2.12)': ' (nicht existent in 2.12)',
57         },
58     'es': {
59         'Source': 'Código fuente',
60
61         'Learning': 'Aprendizaje',
62         'Music glossary': 'Glosario',
63         'Essay': 'Ensayo',
64         'Notation': 'Notación',
65         'Usage': 'Utilización',
66         'Snippets': 'Fragmentos',
67         'Web': 'Web',
68         'Changes': 'Cambios',
69         'Extending': 'Extensión',
70         'Internals': 'Funcionamiento interno',
71         'Contributor': 'Guía del colaborador',
72
73 # keep the spaces!
74         ' (split HTML)': ' (HTML seccionado)',
75         ' (big HTML)': ' (HTML monolítico)',
76
77         'Regression tests for ': 'Pruebas de regresión para ',
78         'PDF of regtests for ': 'Pruebas en PDF para ',
79         'MusicXML Regression tests for ': 'Pruebas de regresión de MusicXML para ',
80         'PDF of MusicXML regtests for ': 'Pruebas de MusicXML en PDF para ',
81
82         'Doc tarball for ': 'Tarball de la documentación para ',
83         ' (did not exist in 2.12)': ' (no existía en la versión 2.12)',
84      },
85     'fr': {
86         'Source': 'Sources',
87
88         'Learning': 'Initiation',
89         'Music glossary': 'Glossaire',
90         'Essay': 'Essai',
91         'Notation': 'Notation',
92         'Usage': 'Utilisation',
93         'Snippets': 'Morceaux choisis',
94         'Web': 'Web',
95         'Changes': 'Nouveautés',
96         'Extending': 'Extension',
97         'Internals': 'Propriétés internes',
98         'Contributor': 'Guide du contributeur',
99
100 # keep the spaces!
101         ' (split HTML)': ' (HTML multipages)',
102         ' (big HTML)': ' (HTML en page unique)',
103
104         'Regression tests for ': 'Tests de régression pour ',
105         'PDF of regtests for ': 'PDF des tests de régression pour ',
106         'MusicXML Regression tests for ': 'Tests de régression de MusicXML pour ',
107         'PDF of MusicXML regtests for ': 'PDF des tests de régression de MusicXML pour ',
108
109         'Doc tarball for ': 'Archive de la documentation pour ',
110         ' (did not exist in 2.12)': ' (non disponible pour la version 2.12)',
111         },
112     'hu': {
113         'Source': 'Forrás',
114         'Learning': 'Tankönyv',
115         'Music glossary': 'Fogalomtár',
116         'Essay': 'Esszé',
117         'Notation': 'Kottaírás',
118         'Usage': 'Használat',
119         'Snippets': 'Kódrészletek',
120         'Web': 'Web',
121         'Changes': 'Változások',
122
123         #TODO
124         'Extending': 0,
125         'Internals': 'Belső működés',
126         'Contributor': 0,
127
128         ' (split HTML)': 0,
129         ' (big HTML)': 0,
130
131         'Regression tests for ': 0,
132         'PDF of regtests for ': 0,
133         'MusicXML Regression tests for ': 0,
134         'PDF of MusicXML regtests for ': 0,
135
136         'Doc tarball for ': 0,
137         ' (did not exist in 2.12)': 0,
138         },
139     'ja': {
140         'Source': 'ソース',
141         'Learning': '学習',
142         'Music glossary': '用語集',
143         'Essay': 'エッセー',
144         'Notation': '記譜法',
145         'Usage': '使用方法',
146         'Snippets': 'コード断片集',
147         'Web': 'Web',
148         'Changes': '変更点',
149
150         #TODO
151         'Extending': 0,
152         'Internals': '内部リファレンス',
153         'Contributor': 0,
154
155         ' (split HTML)': 0,
156         ' (big HTML)': 0,
157
158         'Regression tests for ': 0,
159         'PDF of regtests for ': 0,
160         'MusicXML Regression tests for ': 0,
161         'PDF of MusicXML regtests for ': 0,
162
163         'Doc tarball for ': 0,
164         ' (did not exist in 2.12)': 0,
165
166         },
167     'nl': {
168         'Source': 'Broncode',
169
170         'Learning': 'Beginnen',
171         'Music glossary': 'Terminologie',
172         'Essay': 'Essay',
173         'Notation': 'Notatie',
174         'Usage': 'Gebruik',
175         'Snippets': 'Snippers',
176         'Web': 'Web',
177         'Changes': 'Veranderingen',
178         'Extending': 'Uitbreidingen',
179         'Internals': 'Internals',
180         'Contributor': 'Contributor',
181
182 # keep the spaces!
183         ' (split HTML)': ' (opgesplitste HTML)',
184         ' (big HTML)': ' (grote pagina HTML)',
185
186         'Regression tests for ': 'Regressietesten voor ',
187         'PDF of regtests for ': 'PDF van regressietesten voor ',
188         'MusicXML Regression tests for ': 'MusicXML regressietesten voor ',
189         'PDF of MusicXML regtests for ': 'MusicXML regressietesten voor ',
190
191         'Doc tarball for ': 'Tarball met documentation voor ',
192         ' (did not exist in 2.12)': ' (bestond nog niet in 2.12)',
193      },
194     }
195
196
197
198
199 ### actual program
200
201
202 VERSION_STABLE = ""
203 VERSION_DEVEL = ""
204
205 try:
206     topDir = sys.argv[1]
207 except:
208     myDir = os.path.dirname(sys.argv[0])
209     # use two abspaths to work around some windows python bug
210     topDir = os.path.join(os.path.abspath(myDir)+os.sep+'..'+os.sep+'..'+os.sep)
211     topDir = os.path.abspath( topDir )
212
213
214 # TODO: this might be useful for other scripts; can we make it available?
215 manuals = map(lambda x: os.path.splitext(x)[0],
216               map(os.path.basename,
217                   glob.glob(os.path.join(topDir,'Documentation', '*.te??'))))
218 #manuals = map(lambda x: 'glossary' if x=='music-glossary' else x, manuals)
219 manuals.append('internals')
220
221
222 version_file_path = os.path.join(topDir, "VERSION")
223
224 version_contents = open(version_file_path).readlines()
225 major = 0
226 minor = 0
227 patch = 0
228 for line in version_contents:
229     if (line.startswith('MAJOR_VERSION')):
230         major = line[14:-1]
231     if (line.startswith('MINOR_VERSION')):
232         minor = line[14:-1]
233     if (line.startswith('PATCH_LEVEL')):
234         patch = line[12:-1]
235     if (line.startswith('VERSION_STABLE')):
236         VERSION_STABLE = line[15:-1]
237     if (line.startswith('VERSION_DEVEL')):
238         VERSION_DEVEL = line[14:-1]
239
240 VERSION = str(major)+'.'+str(minor)+'.'+str(patch)
241
242 def _ (string, lang):
243     return translations.get (lang.split ('_')[0], {}).get (string, string)
244
245 getTrans = _
246 # let's not barf, but print a warning when something's missing
247 def getTrans(text, lang):
248     trans = _ (text, lang)
249     if not trans:
250         trans = text
251         sys.stderr.write ('create-weblinks-itexi: warning: [%(lang)s]: translation missing for: %(text)s\n' % locals ())
252     return trans
253
254 def macroLang(name, lang):
255     if (lang != ''):
256         return name + '-' + lang
257     return name
258
259 def make_macro(name, string):
260     print "@macro", name
261     print string
262     print "@end macro"
263     print ""
264
265 def make_download(name, osA, osB, version, revision, text):
266     string = "@uref{http://download.linuxaudio.org/lilypond/binaries/"
267     string += osA + "lilypond-"
268     string += version + "-" + revision
269     string += "." + osB + ",\n"
270     string += text
271     string += ": LilyPond "
272     string += version + "-" + revision
273     string += "}"
274     make_macro(name, string)
275
276 def make_download_source(name, vstring, version, lang):
277     string = "@uref{http://download.linuxaudio.org/lilypond/sources/"
278     string += vstring + "/"
279     string += "lilypond-" + version + ".tar.gz"
280     string += ", "
281     string += getTrans("Source", lang)
282     string += ": lilypond-" + version + ".tar.gz"
283     string += "}"
284     make_macro(macroLang(name,lang), string)
285
286 def make_all_downloads(macroName, version):
287     make_download("download"+macroName+"LinuxNormal", "linux-x86/",
288         "linux-x86.sh",    version, "1", "Linux x86")
289     make_download("download"+macroName+"LinuxBig", "linux-64/",
290         "linux-64.sh", version, "1", "Linux 64")
291     make_download("download"+macroName+"LinuxPPC", "linux-ppc/",
292         "linux-ppc.sh", version, "1", "Linux PPC")
293
294     make_download("download"+macroName+"FreeBSDNormal", "freebsd-x86/",
295         "freebsd-x86.sh", version, "1", "FreeBSD i386")
296     make_download("download"+macroName+"FreeBSDBig", "freebsd-64/",
297         "freebsd-64.sh", version, "1", "FreeBSD amd64")
298
299     make_download("download"+macroName+"DarwinNormal", "darwin-x86/",
300         "darwin-x86.tar.bz2", version, "1", "MacOS X x86")
301     make_download("download"+macroName+"DarwinPPC", "darwin-ppc/",
302         "darwin-ppc.tar.bz2", version, "1", "MacOS X PPC")
303
304     make_download("download"+macroName+"Windows", "mingw/",
305         "mingw.exe", version, "1", "Windows")
306
307 def make_ver_link(macroname, url, linktext):
308     string = "@uref{"
309     string += url
310     string += ","
311     string += linktext
312     string += "}"
313     make_macro(macroname, string)
314
315 # TODO: this kind of thing should really be in a central place for
316 # lilypond python build scripts
317 def translateNameToUrl(manual, version):
318     ver_split = version.split('.')
319     ver_minor = ver_split[0] + '.' + ver_split[1]
320     url = depth + "doc/v" + ver_minor + "/Documentation/"
321
322     if (ver_minor == '2.13'):
323         return url+manual
324     if (ver_minor == '2.12'):
325         if (manual=='learning'):
326             return url+'user/lilypond-learning'
327         elif (manual=='internals'):
328             return url+'user/lilypond-internals'
329         elif (manual=='notation'):
330             return url+'user/lilypond'
331         elif (manual=='usage'):
332             return url+'user/lilypond-program'
333         elif (manual=='snippets'):
334             return url+'../input/lsr/lilypond-snippets'
335         elif (manual=='changes'):
336             return url+'topdocs/NEWS.html'
337         elif (manual=='music-glossary'):
338             return url+'user/music-glossary'
339         elif (manual=='essay'):
340             return url+'user/lilypond-learning/Background.html'
341         elif (manual=='extending'):
342             return url+'user/lilypond/Interfaces-for-programmers.html'
343         else:
344             return ''
345
346
347 def make_manual_links(name, version, lang):
348     """Here is where all the macros manualStableLearningSplit,
349     manualStableLearningBig, manualStableLearningSplitNoName, etc. are
350     created on the fly.  Hopefully this documentation string will help
351     others a bit while grepping for those.
352     """
353     for m in manuals:
354         manual = m
355         # TODO: this is a stupid way of doing it
356         if (m=='music-glossary'):
357             mshort = 'Glossary'
358         else:
359             mshort = m.capitalize()
360         if (manual=='music-glossary'):
361             manual = 'Music glossary'
362         url = translateNameToUrl(m, version)
363
364         if (url == ''):
365             # can't have a comma here due to texinfo
366             make_ver_link(macroLang("manual"+name+mshort+'Pdf',lang),
367                 "http://lilypond.org",
368                 mshort+getTrans(" (did not exist in 2.12)",lang))
369             make_ver_link(macroLang("manual"+name+mshort+'Split',lang),
370                 "http://lilypond.org",
371                 mshort+getTrans(" (did not exist in 2.12)",lang))
372             make_ver_link(macroLang("manual"+name+mshort+'Big',lang),
373                 "http://lilypond.org",
374                 mshort+getTrans(" (did not exist in 2.12)",lang))
375             make_ver_link(macroLang("manual"+name+mshort+'SplitNoName',lang),
376                 "http://lilypond.org",
377                 mshort+getTrans(" (did not exist in 2.12)",lang))
378             continue
379         # this is stupid and I shouldn't have bothered trying
380         # to support the 2.12 docs and it will be deleted once
381         # 2.14 is out and the website won't be visible to users
382         # until 2.14 is out.  -gp
383         if (url.endswith('.html')):
384             make_ver_link(macroLang("manual"+name+mshort+'Pdf',lang),
385                       url,
386                       getTrans(manual.capitalize(),lang) + '.pdf')
387             make_ver_link(macroLang("manual"+name+mshort+'Split',lang),
388                       url,
389                       getTrans(manual.capitalize(),lang) +
390                       getTrans(' (split HTML)',lang))
391             make_ver_link(macroLang("manual"+name+mshort+'Big',lang),
392                       url,
393                       getTrans(manual.capitalize(),lang) +
394                       getTrans(' (big HTML)',lang))
395             newurl = url
396         else:
397             make_ver_link(macroLang("manual"+name+mshort+'Pdf',lang),
398                       url + '.pdf',
399                       getTrans(manual.capitalize(),lang) + '.pdf')
400             make_ver_link(macroLang("manual"+name+mshort+'Split',lang),
401                       url + '/index.html',
402                       getTrans(manual.capitalize(),lang) +
403                       getTrans(' (split HTML)',lang))
404             make_ver_link(macroLang("manual"+name+mshort+'Big',lang),
405                       url + '-big-page.html',
406                       getTrans(manual.capitalize(),lang) +
407                       getTrans(' (big HTML)',lang))
408             newurl = url + '/index.html'
409         make_ver_link(macroLang("manual"+name+mshort+'SplitNoName',lang),
410                   newurl,
411                   getTrans(manual.capitalize(),lang))
412
413 def make_regtest_links(name, version, lang):
414     ver_split = version.split('.')
415     ver_minor = ver_split[0] + '.' + ver_split[1]
416     url = depth + "doc/v" + ver_minor + "/input/regression/"
417
418     make_ver_link(macroLang("regtest"+name, lang),
419         url+"collated-files.html",
420         getTrans("Regression tests for ", lang)+version)
421     make_ver_link(macroLang("regtest"+name+"Pdf", lang),
422         url+"collated-files.pdf",
423         getTrans("PDF of regtests for ", lang)+version)
424     make_ver_link(macroLang("regtest"+name+"Xml", lang),
425         url+"musicxml/collated-files.html",
426         getTrans("MusicXML Regression tests for ", lang)+version)
427     make_ver_link(macroLang("regtest"+name+"XmlPdf", lang),
428          url+"musicxml/collated-files.html",
429         getTrans("PDF of MusicXML regtests for ", lang)+version)
430
431 def make_doctarball_links(name, version, lang):
432     url = depth + "download/binaries/documentation/lilypond-"
433     # ugly FIXME, but proper build number support isn't Critical.
434     url += version + "-1"
435     url += ".documentation.tar.bz2"
436     make_ver_link(macroLang("doctarball"+name, lang),
437         url, getTrans("Doc tarball for ", lang)+version)
438
439 print "@c ************************ Download binaries ************"
440 make_all_downloads("Stable", VERSION_STABLE)
441 make_all_downloads("Devel", VERSION_DEVEL)
442
443 print "@c ************************ Download source ************"
444 # FIXME: icky hard-coding!  -gp
445 for lang in langs:
446     print "@c *********", lang, "***"
447     make_download_source("downloadStableSource","v2.12",VERSION_STABLE,lang)
448     make_download_source("downloadDevelSource","v2.13",VERSION_DEVEL,lang)
449
450 print "@c ************************ Manual links ************"
451 for lang in langs:
452     print "@c *********", lang, "***"
453     make_manual_links("Stable", VERSION_STABLE,lang)
454     make_manual_links("Devel", VERSION_DEVEL,lang)
455
456     make_doctarball_links("Stable", VERSION_STABLE,lang)
457     make_doctarball_links("Devel", VERSION_DEVEL,lang)
458
459 print "@c ************************ Regtest links ************"
460 for lang in langs:
461     print "@c *********", lang, "***"
462     make_regtest_links("Stable", VERSION_STABLE,lang)
463     make_regtest_links("Devel", VERSION_DEVEL,lang)
464
465