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 ### translation data -- shouldn't be here; see issue
13 ### http://code.google.com/p/lilypond/issues/detail?id=1050
18 langobjs = langdefs.LANGUAGES
25 # these links are relative from /website/ on lilypond.org
28 # Get/update node translations
30 for i in cs de es fr hu it ja nl zh; do
32 (echo '--' ; grep -nH -B1 translationof Documentation/$i/web/* ) \
33 | pytt '^--\n.*@(?:unnum|sub)[^ ]* (.*)\n.*@translationof (.*)\n' "'\2': '\1',\n" \
34 | grep -E 'Source|Learning|Glossary|Essay|Notation|Usage|Snippets|Web|Changes|Extending|Internals|Contributor'
42 'Learning': 'Einführung',
43 'Music glossary': 'Glossar',
45 'Notation': 'Notation',
47 'Snippets': 'Schnipsel',
49 'Changes': 'Änderungen',
51 'Extending': 'Erweitern',
52 'Internals': 'Interna',
53 'Contributor': 'Beitragen',
55 ' (split HTML)': ' (geteiltes HTML)',
56 ' (big HTML)': ' (großes HTML)',
58 'Regression tests for ': 'Regressionstests für ',
59 'PDF of regtests for ': 'PDF der Regressionstests für ',
60 'MusicXML Regression tests for ': 'MusicXML Regressionstests für ',
61 'PDF of MusicXML regtests for ': 'PDF der MusicXML Regressionstests für ',
63 'Doc tarball for ': 'Dokumentation tar-gepackt für ',
64 ' (did not exist in 2.12)': ' (nicht existent in 2.12)',
67 'Source': 'Código fuente',
69 'Learning': 'Aprendizaje',
70 'Music glossary': 'Glosario',
72 'Notation': 'Notación',
73 'Usage': 'Utilización',
74 'Snippets': 'Fragmentos',
77 'Extending': 'Extensión',
78 'Internals': 'Funcionamiento interno',
79 'Contributor': 'Guía del colaborador',
82 ' (split HTML)': ' (HTML seccionado)',
83 ' (big HTML)': ' (HTML monolítico)',
85 'Regression tests for ': 'Pruebas de regresión para ',
86 'PDF of regtests for ': 'Pruebas en PDF para ',
87 'MusicXML Regression tests for ': 'Pruebas de regresión de MusicXML para ',
88 'PDF of MusicXML regtests for ': 'Pruebas de MusicXML en PDF para ',
90 'Doc tarball for ': 'Tarball de la documentación para ',
91 ' (did not exist in 2.12)': ' (no existía en la versión 2.12)',
96 'Learning': 'Initiation',
97 'Music glossary': 'Glossaire',
99 'Notation': 'Notation',
100 'Usage': 'Utilisation',
101 'Snippets': 'Morceaux choisis',
103 'Changes': 'Nouveautés',
104 'Extending': 'Extension',
105 'Internals': 'Propriétés internes',
106 'Contributor': 'Guide du contributeur',
109 ' (split HTML)': ' (HTML multipages)',
110 ' (big HTML)': ' (HTML en page unique)',
112 'Regression tests for ': 'Tests de régression pour ',
113 'PDF of regtests for ': 'PDF des tests de régression pour ',
114 'MusicXML Regression tests for ': 'Tests de régression de MusicXML pour ',
115 'PDF of MusicXML regtests for ': 'PDF des tests de régression de MusicXML pour ',
117 'Doc tarball for ': 'Archive de la documentation pour ',
118 ' (did not exist in 2.12)': ' (non disponible pour la version 2.12)',
122 'Learning': 'Tankönyv',
123 'Music glossary': 'Fogalomtár',
125 'Notation': 'Kottaírás',
126 'Usage': 'Használat',
127 'Snippets': 'Kódrészletek',
129 'Changes': 'Változások',
130 'Extending': 'Bővítés',
131 'Internals': 'Belső működés',
132 'Contributor': 'Közreműködés',
134 ' (split HTML)': ' (HTML oldalak)',
135 ' (big HTML)': ' (egy nagy HTML oldal)',
137 'Regression tests for ': 'Regressziós tesztek - verzió: ',
138 'PDF of regtests for ': 'PDF formátumban - verzió: ',
139 'MusicXML Regression tests for ': 'MusicXML regressziós tesztek - verzió: ',
140 'PDF of MusicXML regtests for ': 'PDF formátumban - verzió: ',
142 'Doc tarball for ': 'Tömörített csomag - verzió: ',
143 ' (did not exist in 2.12)': ' (nem létezett a 2.12-es verzióban)',
148 'Music glossary': '用語集',
152 'Snippets': 'コード断片集',
158 'Internals': '内部リファレンス',
159 'Contributor': '貢献者向けガイド',
162 ' (split HTML)': ' (ページ毎に分割された HTML)',
163 ' (big HTML)': ' (1 つの大きな HTML)',
165 'Regression tests for ': '回帰テスト バージョン ',
166 'PDF of regtests for ': '回帰テスト (PDF 版) バージョン ',
167 'MusicXML Regression tests for ': 'MusicXML 回帰テスト バージョン ',
168 'PDF of MusicXML regtests for ': 'MusicXML 回帰テスト (PDF 版) バージョン ',
170 'Doc tarball for ': 'ドキュメント アーカイブ バージョン ',
171 ' (did not exist in 2.12)': ' (バージョン 2.12 には存在しません)',
175 'Source': 'Broncode',
177 'Learning': 'Beginnen',
178 'Music glossary': 'Terminologie',
180 'Notation': 'Notatie',
182 'Snippets': 'Snippers',
184 'Changes': 'Veranderingen',
185 'Extending': 'Uitbreidingen',
186 'Internals': 'Internals',
187 'Contributor': 'Contributor',
190 ' (split HTML)': ' (opgesplitste HTML)',
191 ' (big HTML)': ' (grote pagina HTML)',
193 'Regression tests for ': 'Regressietesten voor ',
194 'PDF of regtests for ': 'PDF van regressietesten voor ',
195 'MusicXML Regression tests for ': 'MusicXML regressietesten voor ',
196 'PDF of MusicXML regtests for ': 'MusicXML regressietesten voor ',
198 'Doc tarball for ': 'Tarball met documentation voor ',
199 ' (did not exist in 2.12)': ' (bestond nog niet in 2.12)',
204 'Music glossary': '音乐术语表',
214 'Contributor': '贡献者',
217 ' (split HTML)': ' (分开的HTML',
218 ' (big HTML)': ' (大的HTML)',
220 'Regression tests for ': '回归测试',
221 'PDF of regtests for ': '回归的PDF',
222 'MusicXML Regression tests for ': 'MusicXML回归测试',
223 'PDF of MusicXML regtests for ': 'MusicXML的PDF回归',
225 'Doc tarball for ': '为文档压缩包',
226 ' (did not exist in 2.12)': ' (在2.12中不存在)',
242 myDir = os.path.dirname(sys.argv[0])
243 # use two abspaths to work around some windows python bug
244 topDir = os.path.join(os.path.abspath(myDir)+os.sep+'..'+os.sep+'..'+os.sep)
245 topDir = os.path.abspath( topDir )
248 # TODO: this might be useful for other scripts; can we make it available?
249 manuals = map(lambda x: os.path.splitext(x)[0],
250 map(os.path.basename,
251 glob.glob(os.path.join(topDir,'Documentation', '*.te??'))))
252 #manuals = map(lambda x: 'glossary' if x=='music-glossary' else x, manuals)
253 manuals.append('internals')
256 version_file_path = os.path.join(topDir, "VERSION")
258 version_contents = open(version_file_path).readlines()
262 for line in version_contents:
263 if (line.startswith('MAJOR_VERSION')):
265 if (line.startswith('MINOR_VERSION')):
267 if (line.startswith('PATCH_LEVEL')):
269 if (line.startswith('VERSION_STABLE')):
270 VERSION_STABLE = line[15:-1]
271 if (line.startswith('VERSION_DEVEL')):
272 VERSION_DEVEL = line[14:-1]
274 VERSION = str(major)+'.'+str(minor)+'.'+str(patch)
276 def _ (string, lang):
277 return translations.get (lang.split ('_')[0], {}).get (string, string)
280 # let's not barf, but print a warning when something's missing
281 def getTrans(text, lang):
282 trans = _ (text, lang)
285 sys.stderr.write ('create-weblinks-itexi: warning: [%(lang)s]: translation missing for: %(text)s\n' % locals ())
288 def macroLang(name, lang):
290 return name + '-' + lang
293 def make_macro(name, string):
299 def make_download(name, osA, osB, version, revision, text):
300 string = "@uref{http://download.linuxaudio.org/lilypond/binaries/"
301 string += osA + "lilypond-"
302 string += version + "-" + revision
303 string += "." + osB + ",\n"
305 string += ": LilyPond "
306 string += version + "-" + revision
308 make_macro(name, string)
310 def make_download_source(name, vstring, version, lang):
311 string = "@uref{http://download.linuxaudio.org/lilypond/sources/"
312 string += vstring + "/"
313 string += "lilypond-" + version + ".tar.gz"
315 string += getTrans("Source", lang)
316 string += ": lilypond-" + version + ".tar.gz"
318 make_macro(macroLang(name,lang), string)
320 def make_all_downloads(macroName, version):
321 make_download("download"+macroName+"LinuxNormal", "linux-x86/",
322 "linux-x86.sh", version, "1", "Linux x86")
323 make_download("download"+macroName+"LinuxBig", "linux-64/",
324 "linux-64.sh", version, "1", "Linux 64")
325 make_download("download"+macroName+"LinuxPPC", "linux-ppc/",
326 "linux-ppc.sh", version, "1", "Linux PPC")
328 make_download("download"+macroName+"FreeBSDNormal", "freebsd-x86/",
329 "freebsd-x86.sh", version, "1", "FreeBSD i386")
330 make_download("download"+macroName+"FreeBSDBig", "freebsd-64/",
331 "freebsd-64.sh", version, "1", "FreeBSD amd64")
333 make_download("download"+macroName+"DarwinNormal", "darwin-x86/",
334 "darwin-x86.tar.bz2", version, "1", "MacOS X x86")
335 make_download("download"+macroName+"DarwinPPC", "darwin-ppc/",
336 "darwin-ppc.tar.bz2", version, "1", "MacOS X PPC")
338 make_download("download"+macroName+"Windows", "mingw/",
339 "mingw.exe", version, "1", "Windows")
341 def make_ver_link(macroname, url, linktext):
347 make_macro(macroname, string)
349 # TODO: this kind of thing should really be in a central place for
350 # lilypond python build scripts
351 def translateNameToUrl(manual, version):
352 ver_split = version.split('.')
353 ver_minor = ver_split[0] + '.' + ver_split[1]
354 url = depth + "doc/v" + ver_minor + "/Documentation/"
356 if (ver_minor == '2.12'):
357 if (manual=='learning'):
358 return url+'user/lilypond-learning'
359 elif (manual=='internals'):
360 return url+'user/lilypond-internals'
361 elif (manual=='notation'):
362 return url+'user/lilypond'
363 elif (manual=='usage'):
364 return url+'user/lilypond-program'
365 elif (manual=='snippets'):
366 return url+'../input/lsr/lilypond-snippets'
367 elif (manual=='changes'):
368 return url+'topdocs/NEWS.html'
369 elif (manual=='music-glossary'):
370 return url+'user/music-glossary'
371 elif (manual=='essay'):
372 return url+'user/lilypond-learning/Background.html'
373 elif (manual=='extending'):
374 return url+'user/lilypond/Interfaces-for-programmers.html'
380 def addLang(url, lang):
382 base, ext = os.path.splitext(url)
383 return base + '.' + lang + ext
387 def make_manual_links(name, version, lang):
388 """Here is where all the macros manualStableLearningSplit,
389 manualStableLearningBig, manualStableLearningSplitNoName, etc. are
390 created on the fly. Hopefully this documentation string will help
391 others a bit while grepping for those.
395 # TODO: this is a stupid way of doing it
396 if (m=='music-glossary'):
399 mshort = m.capitalize()
400 if (manual=='music-glossary'):
401 manual = 'Music glossary'
402 url = translateNameToUrl(m, version)
405 # can't have a comma here due to texinfo
406 make_ver_link(macroLang("manual"+name+mshort+'Pdf',lang),
407 "http://lilypond.org",
408 mshort+getTrans(" (did not exist in 2.12)",lang))
409 make_ver_link(macroLang("manual"+name+mshort+'Split',lang),
410 "http://lilypond.org",
411 mshort+getTrans(" (did not exist in 2.12)",lang))
412 make_ver_link(macroLang("manual"+name+mshort+'Big',lang),
413 "http://lilypond.org",
414 mshort+getTrans(" (did not exist in 2.12)",lang))
415 make_ver_link(macroLang("manual"+name+mshort+'SplitNoName',lang),
416 "http://lilypond.org",
417 mshort+getTrans(" (did not exist in 2.12)",lang))
419 # this is stupid and I shouldn't have bothered trying
420 # to support the 2.12 docs and it will be deleted once
421 # 2.14 is out and the website won't be visible to users
422 # until 2.14 is out. -gp
423 if (url.endswith('.html')):
424 make_ver_link(macroLang("manual"+name+mshort+'Pdf',lang),
426 getTrans(manual.capitalize(),lang) + '.pdf')
427 make_ver_link(macroLang("manual"+name+mshort+'Split',lang),
429 getTrans(manual.capitalize(),lang) +
430 getTrans(' (split HTML)',lang))
431 make_ver_link(macroLang("manual"+name+mshort+'Big',lang),
433 getTrans(manual.capitalize(),lang) +
434 getTrans(' (big HTML)',lang))
437 make_ver_link(macroLang("manual"+name+mshort+'Pdf',lang),
438 # TODO: this is an even stupider way of doing it
439 addLang(url+'.pdf', lang),
440 getTrans(manual.capitalize(),lang) + '.pdf')
441 make_ver_link(macroLang("manual"+name+mshort+'Split',lang),
442 addLang(url + '/index.html', lang),
443 getTrans(manual.capitalize(),lang) +
444 getTrans(' (split HTML)',lang))
445 make_ver_link(macroLang("manual"+name+mshort+'Big',lang),
446 addLang(url + '-big-page.html', lang),
447 getTrans(manual.capitalize(),lang) +
448 getTrans(' (big HTML)',lang))
449 newurl = url + '/index.html'
450 make_ver_link(macroLang("manual"+name+mshort+'SplitNoName',lang),
451 addLang(newurl, lang),
452 getTrans(manual.capitalize(),lang))
454 def make_regtest_links(name, version, lang):
455 ver_split = version.split('.')
456 ver_minor = ver_split[0] + '.' + ver_split[1]
457 url = depth + "doc/v" + ver_minor + "/input/regression/"
459 make_ver_link(macroLang("regtest"+name, lang),
460 url+"collated-files.html",
461 getTrans("Regression tests for ", lang)+version)
462 make_ver_link(macroLang("regtest"+name+"Pdf", lang),
463 url+"collated-files.pdf",
464 getTrans("PDF of regtests for ", lang)+version)
465 make_ver_link(macroLang("regtest"+name+"Xml", lang),
466 url+"musicxml/collated-files.html",
467 getTrans("MusicXML Regression tests for ", lang)+version)
468 make_ver_link(macroLang("regtest"+name+"Abc", lang),
469 url+"abc2ly/collated-files.html",
470 getTrans("abc2ly Regression tests for ", lang)+version)
471 make_ver_link(macroLang("regtest"+name+"LilypondBook", lang),
472 url+"lilypond-book/collated-files.html",
473 getTrans("lilypond-book Regression tests for ", lang)+version)
474 make_ver_link(macroLang("regtest"+name+"XmlPdf", lang),
475 url+"musicxml/collated-files.pdf",
476 getTrans("PDF of MusicXML regtests for ", lang)+version)
477 make_ver_link(macroLang("regtest"+name+"AbcPdf", lang),
478 url+"abc2ly/collated-files.pdf",
479 getTrans("PDF of abc2ly regtests for ", lang)+version)
480 make_ver_link(macroLang("regtest"+name+"LilypondBookPdf", lang),
481 url+"lilypond-book/collated-files.pdf",
482 getTrans("PDF of lilypond-book regtests for ", lang)+version)
484 def make_doctarball_links(name, version, lang):
485 url = depth + "download/binaries/documentation/lilypond-"
486 # ugly FIXME, but proper build number support isn't Critical.
487 url += version + "-1"
488 url += ".documentation.tar.bz2"
489 make_ver_link(macroLang("doctarball"+name, lang),
490 url, getTrans("Doc tarball for ", lang)+version)
492 print "@c ************************ Download binaries ************"
493 make_all_downloads("Stable", VERSION_STABLE)
494 make_all_downloads("Devel", VERSION_DEVEL)
496 print "@c ************************ Download source ************"
497 # FIXME: icky hard-coding! -gp
499 print "@c *********", lang, "***"
500 make_download_source("downloadStableSource","v2.14",VERSION_STABLE,lang)
501 make_download_source("downloadDevelSource","v2.15",VERSION_DEVEL,lang)
503 print "@c ************************ Manual links ************"
505 print "@c *********", lang, "***"
506 make_manual_links("Stable", VERSION_STABLE,lang)
507 make_manual_links("Devel", VERSION_DEVEL,lang)
509 make_doctarball_links("Stable", VERSION_STABLE,lang)
510 make_doctarball_links("Devel", VERSION_DEVEL,lang)
512 print "@c ************************ Regtest links ************"
514 print "@c *********", lang, "***"
515 make_regtest_links("Stable", VERSION_STABLE,lang)
516 make_regtest_links("Devel", VERSION_DEVEL,lang)