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 'MusicXML Regression tests for ': 'MusicXML Regressionstests für ',
62 'PDF of MusicXML regtests for ': 'PDF der MusicXML Regressionstests für ',
64 'Doc tarball for ': 'Dokumentation tar-gepackt für ',
65 ' (did not exist in 2.12)': ' (nicht existent in 2.12)',
68 'Source': 'Código fuente',
70 'Learning': 'Aprendizaje',
71 'Music glossary': 'Glosario',
73 'Notation': 'Notación',
74 'Usage': 'Utilización',
75 'Snippets': 'Fragmentos',
78 'Extending': 'Extensión',
79 'Internals': 'Funcionamiento interno',
80 'Contributor': 'Guía del colaborador',
83 ' (split HTML)': ' (HTML seccionado)',
84 ' (big HTML)': ' (HTML monolítico)',
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 ',
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)',
97 'Learning': 'Initiation',
98 'Music glossary': 'Glossaire',
100 'Notation': 'Notation',
101 'Usage': 'Utilisation',
102 'Snippets': 'Morceaux choisis',
104 'Changes': 'Nouveautés',
105 'Extending': 'Extension',
106 'Internals': 'Propriétés internes',
107 'Contributor': 'Guide du contributeur',
110 ' (split HTML)': ' (HTML multipages)',
111 ' (big HTML)': ' (HTML en page unique)',
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 ',
118 'Doc tarball for ': 'Archive de la documentation pour ',
119 ' (did not exist in 2.12)': ' (non disponible pour la version 2.12)',
123 'Learning': 'Tankönyv',
124 'Music glossary': 'Fogalomtár',
126 'Notation': 'Kottaírás',
127 'Usage': 'Használat',
128 'Snippets': 'Kódrészletek',
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',
135 ' (split HTML)': ' (HTML oldalak)',
136 ' (big HTML)': ' (egy nagy HTML oldal)',
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ó: ',
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)',
149 'Music glossary': '用語集',
153 'Snippets': 'コード断片集',
159 'Internals': '内部リファレンス',
160 'Contributor': '貢献者向けガイド',
163 ' (split HTML)': ' (ページ毎に分割された HTML)',
164 ' (big HTML)': ' (1 つの大きな HTML)',
166 'Regression tests for ': '回帰テスト バージョン ',
167 'PDF of regtests for ': '回帰テスト (PDF 版) バージョン ',
168 'MusicXML Regression tests for ': 'MusicXML 回帰テスト バージョン ',
169 'PDF of MusicXML regtests for ': 'MusicXML 回帰テスト (PDF 版) バージョン ',
171 'Doc tarball for ': 'ドキュメント アーカイブ バージョン ',
172 ' (did not exist in 2.12)': ' (バージョン 2.12 には存在しません)',
176 'Source': 'Broncode',
178 'Learning': 'Beginnen',
179 'Music glossary': 'Terminologie',
181 'Notation': 'Notatie',
183 'Snippets': 'Snippers',
185 'Changes': 'Veranderingen',
186 'Extending': 'Uitbreidingen',
187 'Internals': 'Internals',
188 'Contributor': 'Contributor',
191 ' (split HTML)': ' (opgesplitste HTML)',
192 ' (big HTML)': ' (grote pagina HTML)',
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 ',
199 'Doc tarball for ': 'Tarball met documentation voor ',
200 ' (did not exist in 2.12)': ' (bestond nog niet in 2.12)',
205 'Music glossary': '音乐术语表',
215 'Contributor': '贡献者',
218 ' (split HTML)': ' (分开的 HTML)',
219 ' (big HTML)': ' (大的 HTML)',
221 'Regression tests for ': '回归测试 ',
222 'PDF of regtests for ': '回归测试的 PDF ',
223 'MusicXML Regression tests for ': 'MusicXML 回归测试 ',
224 'PDF of MusicXML regtests for ': 'MusicXML 的 PDF 回归测试 ',
226 'Doc tarball for ': '为文档压缩包',
227 ' (did not exist in 2.12)': ' (在 2.12 中不存在)',
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 )
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')
257 version_file_path = os.path.join(topDir, "VERSION")
259 version_contents = open(version_file_path).readlines()
263 for line in version_contents:
264 if (line.startswith('MAJOR_VERSION')):
266 if (line.startswith('MINOR_VERSION')):
268 if (line.startswith('PATCH_LEVEL')):
270 if (line.startswith('VERSION_STABLE')):
271 VERSION_STABLE = line[15:-1]
272 if (line.startswith('VERSION_DEVEL')):
273 VERSION_DEVEL = line[14:-1]
275 VERSION = str(major)+'.'+str(minor)+'.'+str(patch)
277 def _ (string, lang):
278 return translations.get (lang.split ('_')[0], {}).get (string, string)
281 # let's not barf, but print a warning when something's missing
282 def getTrans(text, lang):
283 trans = _ (text, lang)
286 sys.stderr.write ('create-weblinks-itexi: warning: [%(lang)s]: translation missing for: %(text)s\n' % locals ())
289 def macroLang(name, lang):
291 return name + '-' + lang
294 def make_macro(name, string):
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"
306 string += ": LilyPond "
307 string += version + "-" + revision
309 make_macro(name, string)
311 def make_download_source(name, version, lang):
312 assert "." in version
313 vstring = "v%s.%s" % tuple(version.split(".", 2)[0:2])
314 string = "@uref{http://download.linuxaudio.org/lilypond/sources/"
315 string += vstring + "/"
316 string += "lilypond-" + version + ".tar.gz"
318 string += getTrans("Source", lang)
319 string += ": lilypond-" + version + ".tar.gz"
321 make_macro(macroLang(name,lang), string)
323 def make_all_downloads(macroName, version):
324 make_download("download"+macroName+"LinuxNormal", "linux-x86/",
325 "linux-x86.sh", version, "1", "GNU/Linux x86")
326 make_download("download"+macroName+"LinuxBig", "linux-64/",
327 "linux-64.sh", version, "1", "GNU/Linux 64")
328 make_download("download"+macroName+"LinuxPPC", "linux-ppc/",
329 "linux-ppc.sh", version, "1", "GNU/Linux PPC")
331 make_download("download"+macroName+"FreeBSDNormal", "freebsd-x86/",
332 "freebsd-x86.sh", version, "1", "FreeBSD i386")
333 make_download("download"+macroName+"FreeBSDBig", "freebsd-64/",
334 "freebsd-64.sh", version, "1", "FreeBSD amd64")
336 make_download("download"+macroName+"DarwinNormal", "darwin-x86/",
337 "darwin-x86.tar.bz2", version, "1", "MacOS X x86")
338 make_download("download"+macroName+"DarwinPPC", "darwin-ppc/",
339 "darwin-ppc.tar.bz2", version, "1", "MacOS X PPC")
341 make_download("download"+macroName+"Windows", "mingw/",
342 "mingw.exe", version, "1", "Windows")
344 def make_ver_link(macroname, url, linktext):
350 make_macro(macroname, string)
352 # TODO: this kind of thing should really be in a central place for
353 # lilypond python build scripts
354 def translateNameToUrl(manual, version):
355 ver_split = version.split('.')
356 ver_minor = ver_split[0] + '.' + ver_split[1]
357 url = depth + "doc/v" + ver_minor + "/Documentation/"
359 if (ver_minor == '2.12'):
360 if (manual=='learning'):
361 return url+'user/lilypond-learning'
362 elif (manual=='internals'):
363 return url+'user/lilypond-internals'
364 elif (manual=='notation'):
365 return url+'user/lilypond'
366 elif (manual=='usage'):
367 return url+'user/lilypond-program'
368 elif (manual=='snippets'):
369 return url+'../input/lsr/lilypond-snippets'
370 elif (manual=='changes'):
371 return url+'topdocs/NEWS.html'
372 elif (manual=='music-glossary'):
373 return url+'user/music-glossary'
374 elif (manual=='essay'):
375 return url+'user/lilypond-learning/Background.html'
376 elif (manual=='extending'):
377 return url+'user/lilypond/Interfaces-for-programmers.html'
383 def addLang(url, lang):
385 base, ext = os.path.splitext(url)
386 return base + '.' + lang + ext
390 def make_manual_links(name, version, lang):
391 """Here is where all the macros manualStableLearningSplit,
392 manualStableLearningBig, manualStableLearningSplitNoName, etc. are
393 created on the fly. Hopefully this documentation string will help
394 others a bit while grepping for those.
398 # TODO: this is a stupid way of doing it
399 if (m=='music-glossary'):
402 mshort = m.capitalize()
403 if (manual=='music-glossary'):
404 manual = 'Music glossary'
405 url = translateNameToUrl(m, version)
408 # can't have a comma here due to texinfo
409 make_ver_link(macroLang("manual"+name+mshort+'Pdf',lang),
410 "http://lilypond.org",
411 mshort+getTrans(" (did not exist in 2.12)",lang))
412 make_ver_link(macroLang("manual"+name+mshort+'Split',lang),
413 "http://lilypond.org",
414 mshort+getTrans(" (did not exist in 2.12)",lang))
415 make_ver_link(macroLang("manual"+name+mshort+'Big',lang),
416 "http://lilypond.org",
417 mshort+getTrans(" (did not exist in 2.12)",lang))
418 make_ver_link(macroLang("manual"+name+mshort+'SplitNoName',lang),
419 "http://lilypond.org",
420 mshort+getTrans(" (did not exist in 2.12)",lang))
422 # this is stupid and I shouldn't have bothered trying
423 # to support the 2.12 docs and it will be deleted once
424 # 2.14 is out and the website won't be visible to users
425 # until 2.14 is out. -gp
426 if (url.endswith('.html')):
427 make_ver_link(macroLang("manual"+name+mshort+'Pdf',lang),
429 getTrans(manual.capitalize(),lang) + '.pdf')
430 make_ver_link(macroLang("manual"+name+mshort+'Split',lang),
432 getTrans(manual.capitalize(),lang) +
433 getTrans(' (split HTML)',lang))
434 make_ver_link(macroLang("manual"+name+mshort+'Big',lang),
436 getTrans(manual.capitalize(),lang) +
437 getTrans(' (big HTML)',lang))
440 make_ver_link(macroLang("manual"+name+mshort+'Pdf',lang),
441 # TODO: this is an even stupider way of doing it
442 addLang(url+'.pdf', lang),
443 getTrans(manual.capitalize(),lang) + '.pdf')
444 make_ver_link(macroLang("manual"+name+mshort+'Split',lang),
445 addLang(url + '/index.html', lang),
446 getTrans(manual.capitalize(),lang) +
447 getTrans(' (split HTML)',lang))
448 make_ver_link(macroLang("manual"+name+mshort+'Big',lang),
449 addLang(url + '-big-page.html', lang),
450 getTrans(manual.capitalize(),lang) +
451 getTrans(' (big HTML)',lang))
452 newurl = url + '/index.html'
453 make_ver_link(macroLang("manual"+name+mshort+'SplitNoName',lang),
454 addLang(newurl, lang),
455 getTrans(manual.capitalize(),lang))
457 def make_regtest_links(name, version, lang):
458 ver_split = version.split('.')
459 ver_minor = ver_split[0] + '.' + ver_split[1]
460 url = depth + "doc/v" + ver_minor + "/input/regression/"
462 make_ver_link(macroLang("regtest"+name, lang),
463 url+"collated-files.html",
464 getTrans("Regression tests for ", lang)+version)
465 make_ver_link(macroLang("regtest"+name+"Pdf", lang),
466 url+"collated-files.pdf",
467 getTrans("PDF of regtests for ", lang)+version)
468 make_ver_link(macroLang("regtest"+name+"Xml", lang),
469 url+"musicxml/collated-files.html",
470 getTrans("MusicXML Regression tests for ", lang)+version)
471 make_ver_link(macroLang("regtest"+name+"Abc", lang),
472 url+"abc2ly/collated-files.html",
473 getTrans("abc2ly Regression tests for ", lang)+version)
474 make_ver_link(macroLang("regtest"+name+"LilypondBook", lang),
475 url+"lilypond-book/collated-files.html",
476 getTrans("lilypond-book Regression tests for ", lang)+version)
477 make_ver_link(macroLang("regtest"+name+"XmlPdf", lang),
478 url+"musicxml/collated-files.pdf",
479 getTrans("PDF of MusicXML regtests for ", lang)+version)
480 make_ver_link(macroLang("regtest"+name+"AbcPdf", lang),
481 url+"abc2ly/collated-files.pdf",
482 getTrans("PDF of abc2ly regtests for ", lang)+version)
483 make_ver_link(macroLang("regtest"+name+"LilypondBookPdf", lang),
484 url+"lilypond-book/collated-files.pdf",
485 getTrans("PDF of lilypond-book regtests for ", lang)+version)
487 def make_doctarball_links(name, version, lang):
488 url = depth + "download/binaries/documentation/lilypond-"
489 # ugly FIXME, but proper build number support isn't Critical.
490 url += version + "-1"
491 url += ".documentation.tar.bz2"
492 make_ver_link(macroLang("doctarball"+name, lang),
493 url, getTrans("Doc tarball for ", lang)+version)
495 print "@c This file was autogenerated"
496 print "@c from: VERSION"
497 print "@c by: %s" % sys.argv[0]
499 print "@c ************************ Download binaries ************"
502 make_all_downloads("Stable", VERSION_STABLE)
503 make_all_downloads("Devel", VERSION_DEVEL)
505 print "@c ************************ Download source ************"
509 print "@c *********", lang or "en", "***"
510 make_download_source("downloadStableSource", VERSION_STABLE, lang)
511 make_download_source("downloadDevelSource", VERSION_DEVEL, lang)
513 print "@c ************************ Manual links ************"
517 print "@c *********", lang or "en", "***"
518 make_manual_links("Stable", VERSION_STABLE, lang)
519 make_manual_links("Devel", VERSION_DEVEL, lang)
521 make_doctarball_links("Stable", VERSION_STABLE, lang)
522 make_doctarball_links("Devel", VERSION_DEVEL, lang)
524 print "@c ************************ Regtest links ************"
528 print "@c *********", lang or "en", "***"
529 make_regtest_links("Stable", VERSION_STABLE, lang)
530 make_regtest_links("Devel", VERSION_DEVEL, lang)
531 print "@c ***************************************************"