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