2 # -*- coding: utf-8 -*-
3 # create-weblinks-itexi.py
5 """ when being called on lilypond.org, pass it the location of the
6 top source dir on the command-line. """
12 ### translation data -- shouldn't be here; see issue
13 ### http://code.google.com/p/lilypond/issues/detail?id=1050
16 # GUB only has python 2.4 !!!
17 # langs = [i.code if i.code != 'en' else '' for i in langdefs.WEB_LANGUAGES]
19 for lang in langdefs.WEB_LANGUAGES:
23 langs.append(lang.code)
26 # these links are relative from /website/ on lilypond.org
29 # Get/update node translations
31 for i in cs de es fr hu it ja nl zh; do
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'
43 'Learning': 'Einführung',
44 'Music glossary': 'Glossar',
46 'Notation': 'Notation',
48 'Snippets': 'Schnipsel',
50 'Changes': 'Änderungen',
52 'Extending': 'Erweitern',
53 'Internals': 'Interna',
54 'Contributor': 'Beitragen',
56 ' (split HTML)': ' (geteiltes HTML)',
57 ' (big HTML)': ' (großes HTML)',
59 'Regression tests for ': 'Regressionstests für ',
60 'PDF of regtests for ': 'PDF der Regressionstests für ',
61 'abc2ly Regression tests for ': 'abc2ly Regressionstests für ',
62 'PDF of abc2ly regtests for ': 'PDF der abc2ly Regressionstests für ',
63 'lilypond-book Regression tests for ': 'lilypond-book Regressionstests für ',
64 'PDF of lilypond-book regtests for ': 'PDF der lilypond-book Regressionstests für ',
65 'MusicXML Regression tests for ': 'MusicXML Regressionstests für ',
66 'PDF of MusicXML regtests for ': 'PDF der MusicXML Regressionstests für ',
68 'Doc tarball for ': 'Dokumentation tar-gepackt für ',
69 ' (did not exist in 2.12)': ' (nicht existent in 2.12)',
72 'Source': 'Código fuente',
74 'Learning': 'Aprendizaje',
75 'Music glossary': 'Glosario',
77 'Notation': 'Notación',
78 'Usage': 'Utilización',
79 'Snippets': 'Fragmentos',
82 'Extending': 'Extensión',
83 'Internals': 'Funcionamiento interno',
84 'Contributor': 'Guía del colaborador',
87 ' (split HTML)': ' (HTML seccionado)',
88 ' (big HTML)': ' (HTML monolítico)',
90 'Regression tests for ': 'Pruebas de regresión para ',
91 'PDF of regtests for ': 'Pruebas en PDF para ',
92 'abc2ly Regression tests for ': 'Pruebas de regresión de abc2ly para ',
93 'PDF of abc2ly regtests for ': 'Pruebas de abc2ly en PDF para ',
94 'lilypond-book Regression tests for ': 'Pruebas de regresión de lilypond-book para ',
95 'PDF of lilypond-book regtests for ': 'Pruebas de lilypond-book en PDF para ',
96 'MusicXML Regression tests for ': 'Pruebas de regresión de MusicXML para ',
97 'PDF of MusicXML regtests for ': 'Pruebas de MusicXML en PDF para ',
99 'Doc tarball for ': 'Tarball de la documentación para ',
100 ' (did not exist in 2.12)': ' (no existía en la versión 2.12)',
105 'Learning': 'Initiation',
106 'Music glossary': 'Glossaire',
108 'Notation': 'Notation',
109 'Usage': 'Utilisation',
110 'Snippets': 'Morceaux choisis',
112 'Changes': 'Nouveautés',
113 'Extending': 'Extension',
114 'Internals': 'Propriétés internes',
115 'Contributor': 'Guide du contributeur',
118 ' (split HTML)': ' (HTML multipages)',
119 ' (big HTML)': ' (HTML en page unique)',
121 'Regression tests for ': 'Tests de régression pour ',
122 'PDF of regtests for ': 'PDF des tests de régression pour ',
123 'abc2ly Regression tests for ': 'Tests de régression de abc2ly pour ',
124 'PDF of abc2ly regtests for ': 'PDF des tests de régression de abc2ly pour ',
125 'lilypond-book Regression tests for ': 'Tests de régression de lilypond-book pour ',
126 'PDF of lilypond-book regtests for ': 'PDF des tests de régression de lilypond-book pour ',
127 'MusicXML Regression tests for ': 'Tests de régression de MusicXML pour ',
128 'PDF of MusicXML regtests for ': 'PDF des tests de régression de MusicXML pour ',
130 'Doc tarball for ': 'Archive de la documentation pour ',
131 ' (did not exist in 2.12)': ' (non disponible pour la version 2.12)',
135 'Learning': 'Tankönyv',
136 'Music glossary': 'Fogalomtár',
138 'Notation': 'Kottaírás',
139 'Usage': 'Használat',
140 'Snippets': 'Kódrészletek',
142 'Changes': 'Változások',
143 'Extending': 'Bővítés',
144 'Internals': 'Belső működés',
145 'Contributor': 'Közreműködés',
147 ' (split HTML)': ' (HTML oldalak)',
148 ' (big HTML)': ' (egy nagy HTML oldal)',
150 'Regression tests for ': 'Regressziós tesztek - verzió: ',
151 'PDF of regtests for ': 'PDF formátumban - verzió: ',
152 'abc2ly Regression tests for ': 'abc2ly regressziós tesztek - verzió: ',
153 'PDF of abc2ly regtests for ': 'PDF formátumban - verzió: ',
154 'lilypond-book Regression tests for ': 'lilypond-book regressziós tesztek - verzió: ',
155 'PDF of lilypond-book regtests for ': 'PDF formátumban - verzió: ',
156 'MusicXML Regression tests for ': 'MusicXML regressziós tesztek - verzió: ',
157 'PDF of MusicXML regtests for ': 'PDF formátumban - verzió: ',
159 'Doc tarball for ': 'Tömörített csomag - verzió: ',
160 ' (did not exist in 2.12)': ' (nem létezett a 2.12-es verzióban)',
165 'Music glossary': '用語集',
169 'Snippets': 'コード断片集',
175 'Internals': '内部リファレンス',
176 'Contributor': '貢献者向けガイド',
179 ' (split HTML)': ' (ページ毎に分割された HTML)',
180 ' (big HTML)': ' (1 つの大きな HTML)',
182 'Regression tests for ': '回帰テスト バージョン ',
183 'PDF of regtests for ': '回帰テスト (PDF 版) バージョン ',
184 'abc2ly Regression tests for ': 'abc2ly 回帰テスト バージョン ',
185 'PDF of abc2ly regtests for ': 'abc2ly 回帰テスト (PDF 版) バージョン ',
186 'lilypond-book Regression tests for ': 'lilypond-book 回帰テスト バージョン ',
187 'PDF of lilypond-book regtests for ': 'lilypond-book 回帰テスト (PDF 版) バージョン ',
188 'MusicXML Regression tests for ': 'MusicXML 回帰テスト バージョン ',
189 'PDF of MusicXML regtests for ': 'MusicXML 回帰テスト (PDF 版) バージョン ',
191 'Doc tarball for ': 'ドキュメント アーカイブ バージョン ',
192 ' (did not exist in 2.12)': ' (バージョン 2.12 には存在しません)',
196 'Source': 'Broncode',
198 'Learning': 'Beginnen',
199 'Music glossary': 'Terminologie',
201 'Notation': 'Notatie',
203 'Snippets': 'Snippers',
205 'Changes': 'Veranderingen',
206 'Extending': 'Uitbreidingen',
207 'Internals': 'Internals',
208 'Contributor': 'Contributor',
211 ' (split HTML)': ' (opgesplitste HTML)',
212 ' (big HTML)': ' (grote pagina HTML)',
214 'Regression tests for ': 'Regressietesten voor ',
215 'PDF of regtests for ': 'PDF van regressietesten voor ',
216 'abc2ly Regression tests for ': 'abc2ly regressietesten voor ',
217 'PDF of abc2ly regtests for ': 'abc2ly regressietesten voor ',
218 'lilypond-book Regression tests for ': 'lilypond-book regressietesten voor ',
219 'PDF of lilypond-book regtests for ': 'lilypond-book regressietesten voor ',
220 'MusicXML Regression tests for ': 'MusicXML regressietesten voor ',
221 'PDF of MusicXML regtests for ': 'MusicXML regressietesten voor ',
223 'Doc tarball for ': 'Tarball met documentation voor ',
224 ' (did not exist in 2.12)': ' (bestond nog niet in 2.12)',
229 'Music glossary': '音乐术语表',
239 'Contributor': '贡献者',
242 ' (split HTML)': ' (分开的 HTML)',
243 ' (big HTML)': ' (大的 HTML)',
245 'Regression tests for ': '回归测试 ',
246 'PDF of regtests for ': '回归测试的 PDF ',
247 'abc2ly Regression tests for ': 'abc2ly 回归测试 ',
248 'PDF of abc2ly regtests for ': 'abc2ly 的 PDF 回归测试 ',
249 'lilypond-book Regression tests for ': 'lilypond-book 回归测试 ',
250 'PDF of lilypond-book regtests for ': 'lilypond-book 的 PDF 回归测试 ',
251 'MusicXML Regression tests for ': 'MusicXML 回归测试 ',
252 'PDF of MusicXML regtests for ': 'MusicXML 的 PDF 回归测试 ',
254 'Doc tarball for ': '为文档压缩包',
255 ' (did not exist in 2.12)': ' (在 2.12 中不存在)',
271 myDir = os.path.dirname(sys.argv[0])
272 # use two abspaths to work around some windows python bug
273 topDir = os.path.join(os.path.abspath(myDir)+os.sep+'..'+os.sep+'..'+os.sep)
274 topDir = os.path.abspath( topDir )
277 # TODO: this might be useful for other scripts; can we make it available?
278 manuals = map(lambda x: os.path.splitext(x)[0],
279 map(os.path.basename,
280 glob.glob(os.path.join(topDir,'Documentation', '*.te??'))))
281 #manuals = map(lambda x: 'glossary' if x=='music-glossary' else x, manuals)
282 manuals.append('internals')
285 version_file_path = os.path.join(topDir, "VERSION")
287 version_contents = open(version_file_path).readlines()
291 for line in version_contents:
292 if (line.startswith('MAJOR_VERSION')):
294 if (line.startswith('MINOR_VERSION')):
296 if (line.startswith('PATCH_LEVEL')):
298 if (line.startswith('VERSION_STABLE')):
299 VERSION_STABLE = line[15:-1]
300 if (line.startswith('VERSION_DEVEL')):
301 VERSION_DEVEL = line[14:-1]
303 VERSION = str(major)+'.'+str(minor)+'.'+str(patch)
305 def _ (string, lang):
306 return translations.get (lang.split ('_')[0], {}).get (string, None)
309 # let's not barf, but print a warning when something's missing
310 def getTrans(text, lang):
313 trans = _ (text, lang)
316 sys.stderr.write ('create-weblinks-itexi: warning: [%(lang)s]: translation missing for: %(text)s\n' % locals ())
319 def macroLang(name, lang):
321 return name + '-' + lang
324 def make_macro(name, string):
330 def make_download(name, osA, osB, version, revision, text):
331 string = "@uref{http://download.linuxaudio.org/lilypond/binaries/"
332 string += osA + "lilypond-"
333 string += version + "-" + revision
334 string += "." + osB + ",\n"
336 string += ": LilyPond "
337 string += version + "-" + revision
339 make_macro(name, string)
341 def make_download_source(name, version, lang):
342 assert "." in version
343 vstring = "v%s.%s" % tuple(version.split(".", 2)[0:2])
344 string = "@uref{http://download.linuxaudio.org/lilypond/sources/"
345 string += vstring + "/"
346 string += "lilypond-" + version + ".tar.gz"
348 string += getTrans("Source", lang)
349 string += ": lilypond-" + version + ".tar.gz"
351 make_macro(macroLang(name,lang), string)
353 def make_all_downloads(macroName, version):
354 make_download("download"+macroName+"LinuxNormal", "linux-x86/",
355 "linux-x86.sh", version, "1", "GNU/Linux x86")
356 make_download("download"+macroName+"LinuxBig", "linux-64/",
357 "linux-64.sh", version, "1", "GNU/Linux 64")
358 make_download("download"+macroName+"LinuxPPC", "linux-ppc/",
359 "linux-ppc.sh", version, "1", "GNU/Linux PPC")
361 make_download("download"+macroName+"FreeBSDNormal", "freebsd-x86/",
362 "freebsd-x86.sh", version, "1", "FreeBSD i386")
363 make_download("download"+macroName+"FreeBSDBig", "freebsd-64/",
364 "freebsd-64.sh", version, "1", "FreeBSD amd64")
366 make_download("download"+macroName+"DarwinNormal", "darwin-x86/",
367 "darwin-x86.tar.bz2", version, "1", "MacOS X x86")
368 make_download("download"+macroName+"DarwinPPC", "darwin-ppc/",
369 "darwin-ppc.tar.bz2", version, "1", "MacOS X PPC")
371 make_download("download"+macroName+"Windows", "mingw/",
372 "mingw.exe", version, "1", "Windows")
374 def make_ver_link(macroname, url, linktext):
380 make_macro(macroname, string)
382 # TODO: this kind of thing should really be in a central place for
383 # lilypond python build scripts
384 def translateNameToUrl(manual, version):
385 ver_split = version.split('.')
386 ver_minor = ver_split[0] + '.' + ver_split[1]
387 url = depth + "doc/v" + ver_minor + "/Documentation/"
389 if (ver_minor == '2.12'):
390 if (manual=='learning'):
391 return url+'user/lilypond-learning'
392 elif (manual=='internals'):
393 return url+'user/lilypond-internals'
394 elif (manual=='notation'):
395 return url+'user/lilypond'
396 elif (manual=='usage'):
397 return url+'user/lilypond-program'
398 elif (manual=='snippets'):
399 return url+'../input/lsr/lilypond-snippets'
400 elif (manual=='changes'):
401 return url+'topdocs/NEWS.html'
402 elif (manual=='music-glossary'):
403 return url+'user/music-glossary'
404 elif (manual=='essay'):
405 return url+'user/lilypond-learning/Background.html'
406 elif (manual=='extending'):
407 return url+'user/lilypond/Interfaces-for-programmers.html'
413 def addLang(url, lang):
415 base, ext = os.path.splitext(url)
416 return base + '.' + lang + ext
420 def make_manual_links(name, version, lang):
421 """Here is where all the macros manualStableLearningSplit,
422 manualStableLearningBig, manualStableLearningSplitNoName, etc. are
423 created on the fly. Hopefully this documentation string will help
424 others a bit while grepping for those.
428 # TODO: this is a stupid way of doing it
429 if (m=='music-glossary'):
432 mshort = m.capitalize()
433 if (manual=='music-glossary'):
434 manual = 'Music glossary'
435 url = translateNameToUrl(m, version)
438 # can't have a comma here due to texinfo
439 make_ver_link(macroLang("manual"+name+mshort+'Pdf',lang),
440 "http://lilypond.org",
441 mshort+getTrans(" (did not exist in 2.12)",lang))
442 make_ver_link(macroLang("manual"+name+mshort+'Split',lang),
443 "http://lilypond.org",
444 mshort+getTrans(" (did not exist in 2.12)",lang))
445 make_ver_link(macroLang("manual"+name+mshort+'Big',lang),
446 "http://lilypond.org",
447 mshort+getTrans(" (did not exist in 2.12)",lang))
448 make_ver_link(macroLang("manual"+name+mshort+'SplitNoName',lang),
449 "http://lilypond.org",
450 mshort+getTrans(" (did not exist in 2.12)",lang))
452 # this is stupid and I shouldn't have bothered trying
453 # to support the 2.12 docs and it will be deleted once
454 # 2.14 is out and the website won't be visible to users
455 # until 2.14 is out. -gp
456 if (url.endswith('.html')):
457 make_ver_link(macroLang("manual"+name+mshort+'Pdf',lang),
459 getTrans(manual.capitalize(),lang) + '.pdf')
460 make_ver_link(macroLang("manual"+name+mshort+'Split',lang),
462 getTrans(manual.capitalize(),lang) +
463 getTrans(' (split HTML)',lang))
464 make_ver_link(macroLang("manual"+name+mshort+'Big',lang),
466 getTrans(manual.capitalize(),lang) +
467 getTrans(' (big HTML)',lang))
470 make_ver_link(macroLang("manual"+name+mshort+'Pdf',lang),
471 # TODO: this is an even stupider way of doing it
472 addLang(url+'.pdf', lang),
473 getTrans(manual.capitalize(),lang) + '.pdf')
474 make_ver_link(macroLang("manual"+name+mshort+'Split',lang),
475 addLang(url + '/index.html', lang),
476 getTrans(manual.capitalize(),lang) +
477 getTrans(' (split HTML)',lang))
478 make_ver_link(macroLang("manual"+name+mshort+'Big',lang),
479 addLang(url + '-big-page.html', lang),
480 getTrans(manual.capitalize(),lang) +
481 getTrans(' (big HTML)',lang))
482 newurl = url + '/index.html'
483 make_ver_link(macroLang("manual"+name+mshort+'SplitNoName',lang),
484 addLang(newurl, lang),
485 getTrans(manual.capitalize(),lang))
487 def make_regtest_links(name, version, lang):
488 ver_split = version.split('.')
489 ver_minor = ver_split[0] + '.' + ver_split[1]
490 url = depth + "doc/v" + ver_minor + "/input/regression/"
492 make_ver_link(macroLang("regtest"+name, lang),
493 url+"collated-files.html",
494 getTrans("Regression tests for ", lang)+version)
495 make_ver_link(macroLang("regtest"+name+"Pdf", lang),
496 url+"collated-files.pdf",
497 getTrans("PDF of regtests for ", lang)+version)
498 make_ver_link(macroLang("regtest"+name+"Xml", lang),
499 url+"musicxml/collated-files.html",
500 getTrans("MusicXML Regression tests for ", lang)+version)
501 make_ver_link(macroLang("regtest"+name+"Abc", lang),
502 url+"abc2ly/collated-files.html",
503 getTrans("abc2ly Regression tests for ", lang)+version)
504 make_ver_link(macroLang("regtest"+name+"LilypondBook", lang),
505 url+"lilypond-book/collated-files.html",
506 getTrans("lilypond-book Regression tests for ", lang)+version)
507 make_ver_link(macroLang("regtest"+name+"XmlPdf", lang),
508 url+"musicxml/collated-files.pdf",
509 getTrans("PDF of MusicXML regtests for ", lang)+version)
510 make_ver_link(macroLang("regtest"+name+"AbcPdf", lang),
511 url+"abc2ly/collated-files.pdf",
512 getTrans("PDF of abc2ly regtests for ", lang)+version)
513 make_ver_link(macroLang("regtest"+name+"LilypondBookPdf", lang),
514 url+"lilypond-book/collated-files.pdf",
515 getTrans("PDF of lilypond-book regtests for ", lang)+version)
517 def make_doctarball_links(name, version, lang):
518 url = depth + "download/binaries/documentation/lilypond-"
519 # ugly FIXME, but proper build number support isn't Critical.
520 url += version + "-1"
521 url += ".documentation.tar.bz2"
522 make_ver_link(macroLang("doctarball"+name, lang),
523 url, getTrans("Doc tarball for ", lang)+version)
525 print "@c This file was autogenerated"
526 print "@c from: VERSION"
527 print "@c by: %s" % sys.argv[0]
529 print "@c ************************ Download binaries ************"
532 make_all_downloads("Stable", VERSION_STABLE)
533 make_all_downloads("Devel", VERSION_DEVEL)
535 print "@c ************************ Download source ************"
539 print "@c *********", lang or "en", "***"
540 make_download_source("downloadStableSource", VERSION_STABLE, lang)
541 make_download_source("downloadDevelSource", VERSION_DEVEL, lang)
543 print "@c ************************ Manual links ************"
547 print "@c *********", lang or "en", "***"
548 make_manual_links("Stable", VERSION_STABLE, lang)
549 make_manual_links("Devel", VERSION_DEVEL, lang)
551 make_doctarball_links("Stable", VERSION_STABLE, lang)
552 make_doctarball_links("Devel", VERSION_DEVEL, lang)
554 print "@c ************************ Regtest links ************"
558 print "@c *********", lang or "en", "***"
559 make_regtest_links("Stable", VERSION_STABLE, lang)
560 make_regtest_links("Devel", VERSION_DEVEL, lang)
561 print "@c ***************************************************"