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)',
163 'Source': 'Sorgenti',
164 'Learning': 'Apprendimento',
165 'Music glossary': 'Glossario',
167 'Notation': 'Notazione',
169 'Snippets': 'Frammenti',
171 'Changes': 'Cambiamenti',
172 'Extending': 'Estendere',
173 'Internals': 'Funzionamento interno',
174 'Contributor': 'Guida del collaboratore',
177 ' (split HTML)': ' (HTML multipagina)',
178 ' (big HTML)': ' (HTML pagina unica)',
180 'Regression tests for ': 'Test di collaudo per ',
181 'PDF of regtests for ': 'PDF dei test di collaudo per ',
182 'abc2ly Regression tests for ': 'Test di collaudo di abc2ly per ',
183 'PDF of abc2ly regtests for ': 'PDF dei test di collaudo di abc2ly per ',
184 'lilypond-book Regression tests for ': 'Test di collaudo di lilypond-book per ',
185 'PDF of lilypond-book regtests for ': 'PDF dei test di collaudo di lilypond-book per ',
186 'MusicXML Regression tests for ': 'Test di collaudo di MusicXML per ',
187 'PDF of MusicXML regtests for ': 'PDF dei test di collaudo di MusicXML per ',
189 'Doc tarball for ': 'Archivio della documentazione per ',
190 ' (did not exist in 2.12)': ' (non disponibile per la versione 2.12)',
195 'Music glossary': '用語集',
199 'Snippets': 'コード断片集',
205 'Internals': '内部リファレンス',
206 'Contributor': '貢献者向けガイド',
209 ' (split HTML)': ' (ページ毎に分割された HTML)',
210 ' (big HTML)': ' (1 つの大きな HTML)',
212 'Regression tests for ': '回帰テスト バージョン ',
213 'PDF of regtests for ': '回帰テスト (PDF 版) バージョン ',
214 'abc2ly Regression tests for ': 'abc2ly 回帰テスト バージョン ',
215 'PDF of abc2ly regtests for ': 'abc2ly 回帰テスト (PDF 版) バージョン ',
216 'lilypond-book Regression tests for ': 'lilypond-book 回帰テスト バージョン ',
217 'PDF of lilypond-book regtests for ': 'lilypond-book 回帰テスト (PDF 版) バージョン ',
218 'MusicXML Regression tests for ': 'MusicXML 回帰テスト バージョン ',
219 'PDF of MusicXML regtests for ': 'MusicXML 回帰テスト (PDF 版) バージョン ',
221 'Doc tarball for ': 'ドキュメント アーカイブ バージョン ',
222 ' (did not exist in 2.12)': ' (バージョン 2.12 には存在しません)',
226 'Source': 'Broncode',
228 'Learning': 'Beginnen',
229 'Music glossary': 'Terminologie',
231 'Notation': 'Notatie',
233 'Snippets': 'Snippers',
235 'Changes': 'Veranderingen',
236 'Extending': 'Uitbreidingen',
237 'Internals': 'Internals',
238 'Contributor': 'Contributor',
241 ' (split HTML)': ' (opgesplitste HTML)',
242 ' (big HTML)': ' (grote pagina HTML)',
244 'Regression tests for ': 'Regressietesten voor ',
245 'PDF of regtests for ': 'PDF van regressietesten voor ',
246 'abc2ly Regression tests for ': 'abc2ly regressietesten voor ',
247 'PDF of abc2ly regtests for ': 'abc2ly regressietesten voor ',
248 'lilypond-book Regression tests for ': 'lilypond-book regressietesten voor ',
249 'PDF of lilypond-book regtests for ': 'lilypond-book regressietesten voor ',
250 'MusicXML Regression tests for ': 'MusicXML regressietesten voor ',
251 'PDF of MusicXML regtests for ': 'MusicXML regressietesten voor ',
253 'Doc tarball for ': 'Tarball met documentation voor ',
254 ' (did not exist in 2.12)': ' (bestond nog niet in 2.12)',
259 'Music glossary': '音乐术语表',
269 'Contributor': '贡献者',
272 ' (split HTML)': ' (分开的 HTML)',
273 ' (big HTML)': ' (大的 HTML)',
275 'Regression tests for ': '回归测试 ',
276 'PDF of regtests for ': '回归测试的 PDF ',
277 'abc2ly Regression tests for ': 'abc2ly 回归测试 ',
278 'PDF of abc2ly regtests for ': 'abc2ly 的 PDF 回归测试 ',
279 'lilypond-book Regression tests for ': 'lilypond-book 回归测试 ',
280 'PDF of lilypond-book regtests for ': 'lilypond-book 的 PDF 回归测试 ',
281 'MusicXML Regression tests for ': 'MusicXML 回归测试 ',
282 'PDF of MusicXML regtests for ': 'MusicXML 的 PDF 回归测试 ',
284 'Doc tarball for ': '为文档压缩包',
285 ' (did not exist in 2.12)': ' (在 2.12 中不存在)',
301 myDir = os.path.dirname(sys.argv[0])
302 # use two abspaths to work around some windows python bug
303 topDir = os.path.join(os.path.abspath(myDir)+os.sep+'..'+os.sep+'..'+os.sep)
304 topDir = os.path.abspath( topDir )
307 # TODO: this might be useful for other scripts; can we make it available?
308 manuals = map(lambda x: os.path.splitext(x)[0],
309 map(os.path.basename,
310 glob.glob(os.path.join(topDir,'Documentation', '*.te??'))))
311 #manuals = map(lambda x: 'glossary' if x=='music-glossary' else x, manuals)
312 manuals.append('internals')
315 version_file_path = os.path.join(topDir, "VERSION")
317 version_contents = open(version_file_path).readlines()
321 for line in version_contents:
322 if (line.startswith('MAJOR_VERSION')):
324 if (line.startswith('MINOR_VERSION')):
326 if (line.startswith('PATCH_LEVEL')):
328 if (line.startswith('VERSION_STABLE')):
329 VERSION_STABLE = line[15:-1]
330 if (line.startswith('VERSION_DEVEL')):
331 VERSION_DEVEL = line[14:-1]
333 VERSION = str(major)+'.'+str(minor)+'.'+str(patch)
335 def _ (string, lang):
336 return translations.get (lang.split ('_')[0], {}).get (string, None)
339 # let's not barf, but print a warning when something's missing
340 def getTrans(text, lang):
343 trans = _ (text, lang)
346 sys.stderr.write ('create-weblinks-itexi: warning: [%(lang)s]: translation missing for: %(text)s\n' % locals ())
349 def macroLang(name, lang):
351 return name + '-' + lang
354 def make_macro(name, string):
360 def make_download(name, osA, osB, version, revision, text):
361 string = "@uref{http://download.linuxaudio.org/lilypond/binaries/"
362 string += osA + "lilypond-"
363 string += version + "-" + revision
364 string += "." + osB + ",\n"
366 string += ": LilyPond "
367 string += version + "-" + revision
369 make_macro(name, string)
371 def make_download_source(name, version, lang):
372 assert "." in version
373 vstring = "v%s.%s" % tuple(version.split(".", 2)[0:2])
374 string = "@uref{http://download.linuxaudio.org/lilypond/sources/"
375 string += vstring + "/"
376 string += "lilypond-" + version + ".tar.gz"
378 string += getTrans("Source", lang)
379 string += ": lilypond-" + version + ".tar.gz"
381 make_macro(macroLang(name,lang), string)
383 def make_all_downloads(macroName, version):
384 make_download("download"+macroName+"LinuxNormal", "linux-x86/",
385 "linux-x86.sh", version, "1", "GNU/Linux x86")
386 make_download("download"+macroName+"LinuxBig", "linux-64/",
387 "linux-64.sh", version, "1", "GNU/Linux 64")
388 make_download("download"+macroName+"LinuxPPC", "linux-ppc/",
389 "linux-ppc.sh", version, "1", "GNU/Linux PPC")
391 make_download("download"+macroName+"FreeBSDNormal", "freebsd-x86/",
392 "freebsd-x86.sh", version, "1", "FreeBSD i386")
393 make_download("download"+macroName+"FreeBSDBig", "freebsd-64/",
394 "freebsd-64.sh", version, "1", "FreeBSD amd64")
396 make_download("download"+macroName+"DarwinNormal", "darwin-x86/",
397 "darwin-x86.tar.bz2", version, "1", "MacOS X x86")
398 make_download("download"+macroName+"DarwinPPC", "darwin-ppc/",
399 "darwin-ppc.tar.bz2", version, "1", "MacOS X PPC")
401 make_download("download"+macroName+"Windows", "mingw/",
402 "mingw.exe", version, "1", "Windows")
404 def make_ver_link(macroname, url, linktext):
410 make_macro(macroname, string)
412 # TODO: this kind of thing should really be in a central place for
413 # lilypond python build scripts
414 def translateNameToUrl(manual, version):
415 ver_split = version.split('.')
416 ver_minor = ver_split[0] + '.' + ver_split[1]
417 url = depth + "doc/v" + ver_minor + "/Documentation/"
419 if (ver_minor == '2.12'):
420 if (manual=='learning'):
421 return url+'user/lilypond-learning'
422 elif (manual=='internals'):
423 return url+'user/lilypond-internals'
424 elif (manual=='notation'):
425 return url+'user/lilypond'
426 elif (manual=='usage'):
427 return url+'user/lilypond-program'
428 elif (manual=='snippets'):
429 return url+'../input/lsr/lilypond-snippets'
430 elif (manual=='changes'):
431 return url+'topdocs/NEWS.html'
432 elif (manual=='music-glossary'):
433 return url+'user/music-glossary'
434 elif (manual=='essay'):
435 return url+'user/lilypond-learning/Background.html'
436 elif (manual=='extending'):
437 return url+'user/lilypond/Interfaces-for-programmers.html'
443 def addLang(url, lang):
445 base, ext = os.path.splitext(url)
446 return base + '.' + lang + ext
450 def make_manual_links(name, version, lang):
451 """Here is where all the macros manualStableLearningSplit,
452 manualStableLearningBig, manualStableLearningSplitNoName, etc. are
453 created on the fly. Hopefully this documentation string will help
454 others a bit while grepping for those.
458 # TODO: this is a stupid way of doing it
459 if (m=='music-glossary'):
462 mshort = m.capitalize()
463 if (manual=='music-glossary'):
464 manual = 'Music glossary'
465 url = translateNameToUrl(m, version)
468 # can't have a comma here due to texinfo
469 make_ver_link(macroLang("manual"+name+mshort+'Pdf',lang),
470 "http://lilypond.org",
471 mshort+getTrans(" (did not exist in 2.12)",lang))
472 make_ver_link(macroLang("manual"+name+mshort+'Split',lang),
473 "http://lilypond.org",
474 mshort+getTrans(" (did not exist in 2.12)",lang))
475 make_ver_link(macroLang("manual"+name+mshort+'Big',lang),
476 "http://lilypond.org",
477 mshort+getTrans(" (did not exist in 2.12)",lang))
478 make_ver_link(macroLang("manual"+name+mshort+'SplitNoName',lang),
479 "http://lilypond.org",
480 mshort+getTrans(" (did not exist in 2.12)",lang))
482 # this is stupid and I shouldn't have bothered trying
483 # to support the 2.12 docs and it will be deleted once
484 # 2.14 is out and the website won't be visible to users
485 # until 2.14 is out. -gp
486 if (url.endswith('.html')):
487 make_ver_link(macroLang("manual"+name+mshort+'Pdf',lang),
489 getTrans(manual.capitalize(),lang) + '.pdf')
490 make_ver_link(macroLang("manual"+name+mshort+'Split',lang),
492 getTrans(manual.capitalize(),lang) +
493 getTrans(' (split HTML)',lang))
494 make_ver_link(macroLang("manual"+name+mshort+'Big',lang),
496 getTrans(manual.capitalize(),lang) +
497 getTrans(' (big HTML)',lang))
500 make_ver_link(macroLang("manual"+name+mshort+'Pdf',lang),
501 # TODO: this is an even stupider way of doing it
502 addLang(url+'.pdf', lang),
503 getTrans(manual.capitalize(),lang) + '.pdf')
504 make_ver_link(macroLang("manual"+name+mshort+'Split',lang),
505 addLang(url + '/index.html', lang),
506 getTrans(manual.capitalize(),lang) +
507 getTrans(' (split HTML)',lang))
508 make_ver_link(macroLang("manual"+name+mshort+'Big',lang),
509 addLang(url + '-big-page.html', lang),
510 getTrans(manual.capitalize(),lang) +
511 getTrans(' (big HTML)',lang))
512 newurl = url + '/index.html'
513 make_ver_link(macroLang("manual"+name+mshort+'SplitNoName',lang),
514 addLang(newurl, lang),
515 getTrans(manual.capitalize(),lang))
517 def make_regtest_links(name, version, lang):
518 ver_split = version.split('.')
519 ver_minor = ver_split[0] + '.' + ver_split[1]
520 url = depth + "doc/v" + ver_minor + "/input/regression/"
522 make_ver_link(macroLang("regtest"+name, lang),
523 url+"collated-files.html",
524 getTrans("Regression tests for ", lang)+version)
525 make_ver_link(macroLang("regtest"+name+"Pdf", lang),
526 url+"collated-files.pdf",
527 getTrans("PDF of regtests for ", lang)+version)
528 make_ver_link(macroLang("regtest"+name+"Xml", lang),
529 url+"musicxml/collated-files.html",
530 getTrans("MusicXML Regression tests for ", lang)+version)
531 make_ver_link(macroLang("regtest"+name+"Abc", lang),
532 url+"abc2ly/collated-files.html",
533 getTrans("abc2ly Regression tests for ", lang)+version)
534 make_ver_link(macroLang("regtest"+name+"LilypondBook", lang),
535 url+"lilypond-book/collated-files.html",
536 getTrans("lilypond-book Regression tests for ", lang)+version)
537 make_ver_link(macroLang("regtest"+name+"XmlPdf", lang),
538 url+"musicxml/collated-files.pdf",
539 getTrans("PDF of MusicXML regtests for ", lang)+version)
540 make_ver_link(macroLang("regtest"+name+"AbcPdf", lang),
541 url+"abc2ly/collated-files.pdf",
542 getTrans("PDF of abc2ly regtests for ", lang)+version)
543 make_ver_link(macroLang("regtest"+name+"LilypondBookPdf", lang),
544 url+"lilypond-book/collated-files.pdf",
545 getTrans("PDF of lilypond-book regtests for ", lang)+version)
547 def make_doctarball_links(name, version, lang):
548 url = depth + "download/binaries/documentation/lilypond-"
549 # ugly FIXME, but proper build number support isn't Critical.
550 url += version + "-1"
551 url += ".documentation.tar.bz2"
552 make_ver_link(macroLang("doctarball"+name, lang),
553 url, getTrans("Doc tarball for ", lang)+version)
555 print "@c This file was autogenerated"
556 print "@c from: %s" % VERSION
557 print "@c by: %s" % sys.argv[0]
559 print "@c ************************ Download binaries ************"
562 make_all_downloads("Stable", VERSION_STABLE)
563 make_all_downloads("Devel", VERSION_DEVEL)
565 print "@c ************************ Download source ************"
569 print "@c *********", lang or "en", "***"
570 make_download_source("downloadStableSource", VERSION_STABLE, lang)
571 make_download_source("downloadDevelSource", VERSION_DEVEL, lang)
573 print "@c ************************ Manual links ************"
577 print "@c *********", lang or "en", "***"
578 make_manual_links("Stable", VERSION_STABLE, lang)
579 make_manual_links("Devel", VERSION_DEVEL, lang)
581 make_doctarball_links("Stable", VERSION_STABLE, lang)
582 make_doctarball_links("Devel", VERSION_DEVEL, lang)
584 print "@c ************************ Regtest links ************"
588 print "@c *********", lang or "en", "***"
589 make_regtest_links("Stable", VERSION_STABLE, lang)
590 make_regtest_links("Devel", VERSION_DEVEL, lang)
591 print "@c ***************************************************"