2 # -*- coding: utf-8 -*-
3 # create-version-itexi.py
5 """ when being called on lilypond.org, pass it the location of the
6 top source dir on the command-line. """
12 # these links are relative from /website/ on lilypond.org
15 ### translation data -- shouldn't be here; see issue
16 ### http://code.google.com/p/lilypond/issues/detail?id=1050
18 #langs = ['', 'cs', 'de', 'es', 'fr', 'hu', 'it', 'ja', 'nl', 'zh']
19 langs = ['', 'cs', 'de', 'es', 'fr', 'hu', 'it', 'ja', 'nl', 'zh']
21 # Get/update node translations
23 for i in cs de es fr hu it ja nl zh; do
25 (echo '--' ; grep -nH -B1 translationof Documentation/$i/web/* ) \
26 | pytt '^--\n.*@(?:unnum|sub)[^ ]* (.*)\n.*@translationof (.*)\n' "'\2': '\1',\n" \
27 | grep -E 'Source|Learning|Glossary|Essay|Notation|Usage|Snippets|Web|Changes|Extending|Internals|Contributor'
35 'Learning': 'Einführung',
36 'Music glossary': 'Glossar',
38 'Notation': 'Notation',
40 'Snippets': 'Schnipsel',
42 'Changes': 'Änderungen',
44 'Extending': 'Erweitern',
45 'Internals': 'Interna',
46 'Contributor': 'Beitragen',
48 ' (split HTML)': ' (geteiltes HTML)',
49 ' (big HTML)': ' (großes HTML)',
51 'Regression tests for ': 'Regressionstests für ',
52 'PDF of regtests for ': 'PDF der Regressionstests für ',
53 'MusicXML Regression tests for ': 'MusicXML Regressionstests für ',
54 'PDF of MusicXML regtests for ': 'PDF der MusicXML Regressionstests für ',
56 'Doc tarball for ': 'Dokumentation tar-gepackt für ',
57 ' (did not exist in 2.12)': ' (nicht existent in 2.12)',
60 'Source': 'Código fuente',
62 'Learning': 'Aprendizaje',
63 'Music glossary': 'Glosario',
65 'Notation': 'Notación',
66 'Usage': 'Utilización',
67 'Snippets': 'Fragmentos',
70 'Extending': 'Extensión',
71 'Internals': 'Funcionamiento interno',
72 'Contributor': 'Guía del colaborador',
75 ' (split HTML)': ' (HTML seccionado)',
76 ' (big HTML)': ' (HTML monolítico)',
78 'Regression tests for ': 'Pruebas de regresión para ',
79 'PDF of regtests for ': 'Pruebas en PDF para ',
80 'MusicXML Regression tests for ': 'Pruebas de regresión de MusicXML para ',
81 'PDF of MusicXML regtests for ': 'Pruebas de MusicXML en PDF para ',
83 'Doc tarball for ': 'Tarball de la documentación para ',
84 ' (did not exist in 2.12)': ' (no existía en la versión 2.12)',
89 'Learning': 'Initiation',
90 'Music glossary': 'Glossaire',
92 'Notation': 'Notation',
93 'Usage': 'Utilisation',
94 'Snippets': 'Morceaux choisis',
96 'Changes': 'Nouveautés',
97 'Extending': 'Extension',
98 'Internals': 'Propriétés internes',
99 'Contributor': 'Guide du contributeur',
102 ' (split HTML)': ' (HTML multipages)',
103 ' (big HTML)': ' (HTML en page unique)',
105 'Regression tests for ': 'Tests de régression pour ',
106 'PDF of regtests for ': 'PDF des tests de régression pour ',
107 'MusicXML Regression tests for ': 'Tests de régression de MusicXML pour ',
108 'PDF of MusicXML regtests for ': 'PDF des tests de régression de MusicXML pour ',
110 'Doc tarball for ': 'Archive de la documentation pour ',
111 ' (did not exist in 2.12)': ' (non disponible pour la version 2.12)',
115 'Learning': 'Tankönyv',
116 'Music glossary': 'Fogalomtár',
118 'Notation': 'Kottaírás',
119 'Usage': 'Használat',
120 'Snippets': 'Kódrészletek',
122 'Changes': 'Változások',
123 'Extending': 'Bővítés',
124 'Internals': 'Belső működés',
125 'Contributor': 'Közreműködés',
127 ' (split HTML)': ' (HTML oldalak)',
128 ' (big HTML)': ' (egy nagy HTML oldal)',
130 'Regression tests for ': 'Regressziós tesztek - verzió: ',
131 'PDF of regtests for ': 'PDF formátumban - verzió: ',
132 'MusicXML Regression tests for ': 'MusicXML regressziós tesztek - verzió: ',
133 'PDF of MusicXML regtests for ': 'PDF formátumban - verzió: ',
135 'Doc tarball for ': 'Tömörített csomag - verzió: ',
136 ' (did not exist in 2.12)': ' (nem létezett a 2.12-es verzióban)',
141 'Music glossary': '用語集',
145 'Snippets': 'コード断片集',
151 'Internals': '内部リファレンス',
152 'Contributor': '貢献者向けガイド',
155 ' (split HTML)': ' (ページ毎に分割された HTML)',
156 ' (big HTML)': ' (1 つの大きな HTML)',
158 'Regression tests for ': '回帰テスト バージョン ',
159 'PDF of regtests for ': '回帰テスト (PDF 版) バージョン ',
160 'MusicXML Regression tests for ': 'MusicXML 回帰テスト バージョン ',
161 'PDF of MusicXML regtests for ': 'MusicXML 回帰テスト (PDF 版) バージョン ',
163 'Doc tarball for ': 'ドキュメント アーカイブ バージョン ',
164 ' (did not exist in 2.12)': ' (バージョン 2.12 には存在しません)',
168 'Source': 'Broncode',
170 'Learning': 'Beginnen',
171 'Music glossary': 'Terminologie',
173 'Notation': 'Notatie',
175 'Snippets': 'Snippers',
177 'Changes': 'Veranderingen',
178 'Extending': 'Uitbreidingen',
179 'Internals': 'Internals',
180 'Contributor': 'Contributor',
183 ' (split HTML)': ' (opgesplitste HTML)',
184 ' (big HTML)': ' (grote pagina HTML)',
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 ',
191 'Doc tarball for ': 'Tarball met documentation voor ',
192 ' (did not exist in 2.12)': ' (bestond nog niet in 2.12)',
212 'Regression tests for ': 0,
213 'PDF of regtests for ': 0,
214 'MusicXML Regression tests for ': 0,
215 'PDF of MusicXML regtests for ': 0,
217 'Doc tarball for ': 0,
218 ' (did not exist in 2.12)': 0,
234 myDir = os.path.dirname(sys.argv[0])
235 # use two abspaths to work around some windows python bug
236 topDir = os.path.join(os.path.abspath(myDir)+os.sep+'..'+os.sep+'..'+os.sep)
237 topDir = os.path.abspath( topDir )
240 # TODO: this might be useful for other scripts; can we make it available?
241 manuals = map(lambda x: os.path.splitext(x)[0],
242 map(os.path.basename,
243 glob.glob(os.path.join(topDir,'Documentation', '*.te??'))))
244 #manuals = map(lambda x: 'glossary' if x=='music-glossary' else x, manuals)
245 manuals.append('internals')
248 version_file_path = os.path.join(topDir, "VERSION")
250 version_contents = open(version_file_path).readlines()
254 for line in version_contents:
255 if (line.startswith('MAJOR_VERSION')):
257 if (line.startswith('MINOR_VERSION')):
259 if (line.startswith('PATCH_LEVEL')):
261 if (line.startswith('VERSION_STABLE')):
262 VERSION_STABLE = line[15:-1]
263 if (line.startswith('VERSION_DEVEL')):
264 VERSION_DEVEL = line[14:-1]
266 VERSION = str(major)+'.'+str(minor)+'.'+str(patch)
268 def _ (string, lang):
269 return translations.get (lang.split ('_')[0], {}).get (string, string)
272 # let's not barf, but print a warning when something's missing
273 def getTrans(text, lang):
274 trans = _ (text, lang)
277 sys.stderr.write ('create-weblinks-itexi: warning: [%(lang)s]: translation missing for: %(text)s\n' % locals ())
280 def macroLang(name, lang):
282 return name + '-' + lang
285 def make_macro(name, string):
291 def make_download(name, osA, osB, version, revision, text):
292 string = "@uref{http://download.linuxaudio.org/lilypond/binaries/"
293 string += osA + "lilypond-"
294 string += version + "-" + revision
295 string += "." + osB + ",\n"
297 string += ": LilyPond "
298 string += version + "-" + revision
300 make_macro(name, string)
302 def make_download_source(name, vstring, version, lang):
303 string = "@uref{http://download.linuxaudio.org/lilypond/sources/"
304 string += vstring + "/"
305 string += "lilypond-" + version + ".tar.gz"
307 string += getTrans("Source", lang)
308 string += ": lilypond-" + version + ".tar.gz"
310 make_macro(macroLang(name,lang), string)
312 def make_all_downloads(macroName, version):
313 make_download("download"+macroName+"LinuxNormal", "linux-x86/",
314 "linux-x86.sh", version, "1", "Linux x86")
315 make_download("download"+macroName+"LinuxBig", "linux-64/",
316 "linux-64.sh", version, "1", "Linux 64")
317 make_download("download"+macroName+"LinuxPPC", "linux-ppc/",
318 "linux-ppc.sh", version, "1", "Linux PPC")
320 make_download("download"+macroName+"FreeBSDNormal", "freebsd-x86/",
321 "freebsd-x86.sh", version, "1", "FreeBSD i386")
322 make_download("download"+macroName+"FreeBSDBig", "freebsd-64/",
323 "freebsd-64.sh", version, "1", "FreeBSD amd64")
325 make_download("download"+macroName+"DarwinNormal", "darwin-x86/",
326 "darwin-x86.tar.bz2", version, "1", "MacOS X x86")
327 make_download("download"+macroName+"DarwinPPC", "darwin-ppc/",
328 "darwin-ppc.tar.bz2", version, "1", "MacOS X PPC")
330 make_download("download"+macroName+"Windows", "mingw/",
331 "mingw.exe", version, "1", "Windows")
333 def make_ver_link(macroname, url, linktext):
339 make_macro(macroname, string)
341 # TODO: this kind of thing should really be in a central place for
342 # lilypond python build scripts
343 def translateNameToUrl(manual, version):
344 ver_split = version.split('.')
345 ver_minor = ver_split[0] + '.' + ver_split[1]
346 url = depth + "doc/v" + ver_minor + "/Documentation/"
348 if (ver_minor == '2.13'):
350 if (ver_minor == '2.12'):
351 if (manual=='learning'):
352 return url+'user/lilypond-learning'
353 elif (manual=='internals'):
354 return url+'user/lilypond-internals'
355 elif (manual=='notation'):
356 return url+'user/lilypond'
357 elif (manual=='usage'):
358 return url+'user/lilypond-program'
359 elif (manual=='snippets'):
360 return url+'../input/lsr/lilypond-snippets'
361 elif (manual=='changes'):
362 return url+'topdocs/NEWS.html'
363 elif (manual=='music-glossary'):
364 return url+'user/music-glossary'
365 elif (manual=='essay'):
366 return url+'user/lilypond-learning/Background.html'
367 elif (manual=='extending'):
368 return url+'user/lilypond/Interfaces-for-programmers.html'
372 def addLang(url, lang):
374 base, ext = os.path.splitext(url)
375 return base + '.' + lang + ext
379 def make_manual_links(name, version, lang):
380 """Here is where all the macros manualStableLearningSplit,
381 manualStableLearningBig, manualStableLearningSplitNoName, etc. are
382 created on the fly. Hopefully this documentation string will help
383 others a bit while grepping for those.
387 # TODO: this is a stupid way of doing it
388 if (m=='music-glossary'):
391 mshort = m.capitalize()
392 if (manual=='music-glossary'):
393 manual = 'Music glossary'
394 url = translateNameToUrl(m, version)
397 # can't have a comma here due to texinfo
398 make_ver_link(macroLang("manual"+name+mshort+'Pdf',lang),
399 "http://lilypond.org",
400 mshort+getTrans(" (did not exist in 2.12)",lang))
401 make_ver_link(macroLang("manual"+name+mshort+'Split',lang),
402 "http://lilypond.org",
403 mshort+getTrans(" (did not exist in 2.12)",lang))
404 make_ver_link(macroLang("manual"+name+mshort+'Big',lang),
405 "http://lilypond.org",
406 mshort+getTrans(" (did not exist in 2.12)",lang))
407 make_ver_link(macroLang("manual"+name+mshort+'SplitNoName',lang),
408 "http://lilypond.org",
409 mshort+getTrans(" (did not exist in 2.12)",lang))
411 # this is stupid and I shouldn't have bothered trying
412 # to support the 2.12 docs and it will be deleted once
413 # 2.14 is out and the website won't be visible to users
414 # until 2.14 is out. -gp
415 if (url.endswith('.html')):
416 make_ver_link(macroLang("manual"+name+mshort+'Pdf',lang),
418 getTrans(manual.capitalize(),lang) + '.pdf')
419 make_ver_link(macroLang("manual"+name+mshort+'Split',lang),
421 getTrans(manual.capitalize(),lang) +
422 getTrans(' (split HTML)',lang))
423 make_ver_link(macroLang("manual"+name+mshort+'Big',lang),
425 getTrans(manual.capitalize(),lang) +
426 getTrans(' (big HTML)',lang))
429 make_ver_link(macroLang("manual"+name+mshort+'Pdf',lang),
430 # TODO: this is an even stupider way of doing it
431 addLang(url+'.pdf', lang),
432 getTrans(manual.capitalize(),lang) + '.pdf')
433 make_ver_link(macroLang("manual"+name+mshort+'Split',lang),
434 addLang(url + '/index.html', lang),
435 getTrans(manual.capitalize(),lang) +
436 getTrans(' (split HTML)',lang))
437 make_ver_link(macroLang("manual"+name+mshort+'Big',lang),
438 addLang(url + '-big-page.html', lang),
439 getTrans(manual.capitalize(),lang) +
440 getTrans(' (big HTML)',lang))
441 newurl = url + '/index.html'
442 make_ver_link(macroLang("manual"+name+mshort+'SplitNoName',lang),
443 addLang(newurl, lang),
444 getTrans(manual.capitalize(),lang))
446 def make_regtest_links(name, version, lang):
447 ver_split = version.split('.')
448 ver_minor = ver_split[0] + '.' + ver_split[1]
449 url = depth + "doc/v" + ver_minor + "/input/regression/"
451 make_ver_link(macroLang("regtest"+name, lang),
452 url+"collated-files.html",
453 getTrans("Regression tests for ", lang)+version)
454 make_ver_link(macroLang("regtest"+name+"Pdf", lang),
455 url+"collated-files.pdf",
456 getTrans("PDF of regtests for ", lang)+version)
457 make_ver_link(macroLang("regtest"+name+"Xml", lang),
458 url+"musicxml/collated-files.html",
459 getTrans("MusicXML Regression tests for ", lang)+version)
460 make_ver_link(macroLang("regtest"+name+"Abc", lang),
461 url+"abc2ly/collated-files.html",
462 getTrans("abc2ly Regression tests for ", lang)+version)
463 make_ver_link(macroLang("regtest"+name+"LilypondBook", lang),
464 url+"lilypond-book/collated-files.html",
465 getTrans("lilypond-book Regression tests for ", lang)+version)
466 make_ver_link(macroLang("regtest"+name+"XmlPdf", lang),
467 url+"musicxml/collated-files.pdf",
468 getTrans("PDF of MusicXML regtests for ", lang)+version)
469 make_ver_link(macroLang("regtest"+name+"AbcPdf", lang),
470 url+"abc2ly/collated-files.pdf",
471 getTrans("PDF of abc2ly regtests for ", lang)+version)
472 make_ver_link(macroLang("regtest"+name+"LilypondBookPdf", lang),
473 url+"lilypond-book/collated-files.pdf",
474 getTrans("PDF of lilypond-book regtests for ", lang)+version)
476 def make_doctarball_links(name, version, lang):
477 url = depth + "download/binaries/documentation/lilypond-"
478 # ugly FIXME, but proper build number support isn't Critical.
479 url += version + "-1"
480 url += ".documentation.tar.bz2"
481 make_ver_link(macroLang("doctarball"+name, lang),
482 url, getTrans("Doc tarball for ", lang)+version)
484 print "@c ************************ Download binaries ************"
485 make_all_downloads("Stable", VERSION_STABLE)
486 make_all_downloads("Devel", VERSION_DEVEL)
488 print "@c ************************ Download source ************"
489 # FIXME: icky hard-coding! -gp
491 print "@c *********", lang, "***"
492 make_download_source("downloadStableSource","v2.12",VERSION_STABLE,lang)
493 make_download_source("downloadDevelSource","v2.13",VERSION_DEVEL,lang)
495 print "@c ************************ Manual links ************"
497 print "@c *********", lang, "***"
498 make_manual_links("Stable", VERSION_STABLE,lang)
499 make_manual_links("Devel", VERSION_DEVEL,lang)
501 make_doctarball_links("Stable", VERSION_STABLE,lang)
502 make_doctarball_links("Devel", VERSION_DEVEL,lang)
504 print "@c ************************ Regtest links ************"
506 print "@c *********", lang, "***"
507 make_regtest_links("Stable", VERSION_STABLE,lang)
508 make_regtest_links("Devel", VERSION_DEVEL,lang)