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 = ['', 'de', 'es', 'fr', 'hu', 'it', 'ja', 'nl']
20 # Get/update node translations
22 for i in de es fr hu it ja nl; do
24 (echo '--' ; grep -nH -B1 translationof Documentation/$i/web/* ) \
25 | pytt '^--\n.*@(?:unnum|sub)[^ ]* (.*)\n.*@translationof (.*)\n' "'\2': '\1',\n" \
26 | grep -E 'Source|Learning|Glossary|Essay|Notation|Usage|Snippets|Web|Changes|Extending|Internals|Contributor'
34 'Learning': 'Einführung',
35 'Music glossary': 'Glossar',
37 'Notation': 'Notation',
39 'Snippets': 'Schnipsel',
41 'Changes': 'Änderungen',
43 'Extending': 'Erweitern',
44 'Internals': 'Interna',
45 'Contributor': 'Beitragen',
47 ' (split HTML)': ' (geteiltes HTML)',
48 ' (big HTML)': ' (großes HTML)',
50 'Regression tests for ': 'Regressionstests für ',
51 'PDF of regtests for ': 'PDF der Regressionstests für ',
52 'MusicXML Regression tests for ': 'MusicXML Regressionstests für ',
53 'PDF of MusicXML regtests for ': 'PDF der MusicXML Regressionstests für ',
55 'Doc tarball for ': 'Dokumentation tar-gepackt für ',
56 ' (did not exist in 2.12)': ' (nicht existent in 2.12)',
59 'Source': 'Código fuente',
61 'Learning': 'Aprendizaje',
62 'Music glossary': 'Glosario',
64 'Notation': 'Notación',
65 'Usage': 'Utilización',
66 'Snippets': 'Fragmentos',
69 'Extending': 'Extensión',
70 'Internals': 'Funcionamiento interno',
71 'Contributor': 'Guía del colaborador',
74 ' (split HTML)': ' (HTML seccionado)',
75 ' (big HTML)': ' (HTML monolítico)',
77 'Regression tests for ': 'Pruebas de regresión para ',
78 'PDF of regtests for ': 'Pruebas en PDF para ',
79 'MusicXML Regression tests for ': 'Pruebas de regresión de MusicXML para ',
80 'PDF of MusicXML regtests for ': 'Pruebas de MusicXML en PDF para ',
82 'Doc tarball for ': 'Tarball de la documentación para ',
83 ' (did not exist in 2.12)': ' (no existía en la versión 2.12)',
88 'Learning': 'Initiation',
89 'Music glossary': 'Glossaire',
91 'Notation': 'Notation',
92 'Usage': 'Utilisation',
93 'Snippets': 'Morceaux choisis',
95 'Changes': 'Nouveautés',
96 'Extending': 'Extension',
97 'Internals': 'Propriétés internes',
98 'Contributor': 'Guide du contributeur',
101 ' (split HTML)': ' (HTML multipages)',
102 ' (big HTML)': ' (HTML en page unique)',
104 'Regression tests for ': 'Tests de régression pour ',
105 'PDF of regtests for ': 'PDF des tests de régression pour ',
106 'MusicXML Regression tests for ': 'Tests de régression de MusicXML pour ',
107 'PDF of MusicXML regtests for ': 'PDF des tests de régression de MusicXML pour ',
109 'Doc tarball for ': 'Archive de la documentation pour ',
110 ' (did not exist in 2.12)': ' (non disponible pour la version 2.12)',
114 'Learning': 'Tankönyv',
115 'Music glossary': 'Fogalomtár',
117 'Notation': 'Kottaírás',
118 'Usage': 'Használat',
119 'Snippets': 'Kódrészletek',
121 'Changes': 'Változások',
125 'Internals': 'Belső működés',
131 'Regression tests for ': 0,
132 'PDF of regtests for ': 0,
133 'MusicXML Regression tests for ': 0,
134 'PDF of MusicXML regtests for ': 0,
136 'Doc tarball for ': 0,
137 ' (did not exist in 2.12)': 0,
142 'Music glossary': '用語集',
146 'Snippets': 'コード断片集',
152 'Internals': '内部リファレンス',
153 'Contributor': '貢献者向けガイド',
156 ' (split HTML)': ' (ページ毎に分割された HTML)',
157 ' (big HTML)': ' (1 つの大きな HTML)',
159 'Regression tests for ': '回帰テスト バージョン ',
160 'PDF of regtests for ': '回帰テスト (PDF 版) バージョン ',
161 'MusicXML Regression tests for ': 'MusicXML 回帰テスト バージョン ',
162 'PDF of MusicXML regtests for ': 'MusicXML 回帰テスト (PDF 版) バージョン ',
164 'Doc tarball for ': 'ドキュメント アーカイブ バージョン ',
165 ' (did not exist in 2.12)': ' (バージョン 2.12 には存在しません)',
169 'Source': 'Broncode',
171 'Learning': 'Beginnen',
172 'Music glossary': 'Terminologie',
174 'Notation': 'Notatie',
176 'Snippets': 'Snippers',
178 'Changes': 'Veranderingen',
179 'Extending': 'Uitbreidingen',
180 'Internals': 'Internals',
181 'Contributor': 'Contributor',
184 ' (split HTML)': ' (opgesplitste HTML)',
185 ' (big HTML)': ' (grote pagina HTML)',
187 'Regression tests for ': 'Regressietesten voor ',
188 'PDF of regtests for ': 'PDF van regressietesten voor ',
189 'MusicXML Regression tests for ': 'MusicXML regressietesten voor ',
190 'PDF of MusicXML regtests for ': 'MusicXML regressietesten voor ',
192 'Doc tarball for ': 'Tarball met documentation voor ',
193 ' (did not exist in 2.12)': ' (bestond nog niet in 2.12)',
209 myDir = os.path.dirname(sys.argv[0])
210 # use two abspaths to work around some windows python bug
211 topDir = os.path.join(os.path.abspath(myDir)+os.sep+'..'+os.sep+'..'+os.sep)
212 topDir = os.path.abspath( topDir )
215 # TODO: this might be useful for other scripts; can we make it available?
216 manuals = map(lambda x: os.path.splitext(x)[0],
217 map(os.path.basename,
218 glob.glob(os.path.join(topDir,'Documentation', '*.te??'))))
219 #manuals = map(lambda x: 'glossary' if x=='music-glossary' else x, manuals)
220 manuals.append('internals')
223 version_file_path = os.path.join(topDir, "VERSION")
225 version_contents = open(version_file_path).readlines()
229 for line in version_contents:
230 if (line.startswith('MAJOR_VERSION')):
232 if (line.startswith('MINOR_VERSION')):
234 if (line.startswith('PATCH_LEVEL')):
236 if (line.startswith('VERSION_STABLE')):
237 VERSION_STABLE = line[15:-1]
238 if (line.startswith('VERSION_DEVEL')):
239 VERSION_DEVEL = line[14:-1]
241 VERSION = str(major)+'.'+str(minor)+'.'+str(patch)
243 def _ (string, lang):
244 return translations.get (lang.split ('_')[0], {}).get (string, string)
247 # let's not barf, but print a warning when something's missing
248 def getTrans(text, lang):
249 trans = _ (text, lang)
252 sys.stderr.write ('create-weblinks-itexi: warning: [%(lang)s]: translation missing for: %(text)s\n' % locals ())
255 def macroLang(name, lang):
257 return name + '-' + lang
260 def make_macro(name, string):
266 def make_download(name, osA, osB, version, revision, text):
267 string = "@uref{http://download.linuxaudio.org/lilypond/binaries/"
268 string += osA + "lilypond-"
269 string += version + "-" + revision
270 string += "." + osB + ",\n"
272 string += ": LilyPond "
273 string += version + "-" + revision
275 make_macro(name, string)
277 def make_download_source(name, vstring, version, lang):
278 string = "@uref{http://download.linuxaudio.org/lilypond/sources/"
279 string += vstring + "/"
280 string += "lilypond-" + version + ".tar.gz"
282 string += getTrans("Source", lang)
283 string += ": lilypond-" + version + ".tar.gz"
285 make_macro(macroLang(name,lang), string)
287 def make_all_downloads(macroName, version):
288 make_download("download"+macroName+"LinuxNormal", "linux-x86/",
289 "linux-x86.sh", version, "1", "Linux x86")
290 make_download("download"+macroName+"LinuxBig", "linux-64/",
291 "linux-64.sh", version, "1", "Linux 64")
292 make_download("download"+macroName+"LinuxPPC", "linux-ppc/",
293 "linux-ppc.sh", version, "1", "Linux PPC")
295 make_download("download"+macroName+"FreeBSDNormal", "freebsd-x86/",
296 "freebsd-x86.sh", version, "1", "FreeBSD i386")
297 make_download("download"+macroName+"FreeBSDBig", "freebsd-64/",
298 "freebsd-64.sh", version, "1", "FreeBSD amd64")
300 make_download("download"+macroName+"DarwinNormal", "darwin-x86/",
301 "darwin-x86.tar.bz2", version, "1", "MacOS X x86")
302 make_download("download"+macroName+"DarwinPPC", "darwin-ppc/",
303 "darwin-ppc.tar.bz2", version, "1", "MacOS X PPC")
305 make_download("download"+macroName+"Windows", "mingw/",
306 "mingw.exe", version, "1", "Windows")
308 def make_ver_link(macroname, url, linktext):
314 make_macro(macroname, string)
316 # TODO: this kind of thing should really be in a central place for
317 # lilypond python build scripts
318 def translateNameToUrl(manual, version):
319 ver_split = version.split('.')
320 ver_minor = ver_split[0] + '.' + ver_split[1]
321 url = depth + "doc/v" + ver_minor + "/Documentation/"
323 if (ver_minor == '2.13'):
325 if (ver_minor == '2.12'):
326 if (manual=='learning'):
327 return url+'user/lilypond-learning'
328 elif (manual=='internals'):
329 return url+'user/lilypond-internals'
330 elif (manual=='notation'):
331 return url+'user/lilypond'
332 elif (manual=='usage'):
333 return url+'user/lilypond-program'
334 elif (manual=='snippets'):
335 return url+'../input/lsr/lilypond-snippets'
336 elif (manual=='changes'):
337 return url+'topdocs/NEWS.html'
338 elif (manual=='music-glossary'):
339 return url+'user/music-glossary'
340 elif (manual=='essay'):
341 return url+'user/lilypond-learning/Background.html'
342 elif (manual=='extending'):
343 return url+'user/lilypond/Interfaces-for-programmers.html'
347 def addLang(url, lang):
349 base, ext = os.path.splitext(url)
350 return base + '.' + lang + ext
354 def make_manual_links(name, version, lang):
355 """Here is where all the macros manualStableLearningSplit,
356 manualStableLearningBig, manualStableLearningSplitNoName, etc. are
357 created on the fly. Hopefully this documentation string will help
358 others a bit while grepping for those.
362 # TODO: this is a stupid way of doing it
363 if (m=='music-glossary'):
366 mshort = m.capitalize()
367 if (manual=='music-glossary'):
368 manual = 'Music glossary'
369 url = translateNameToUrl(m, version)
372 # can't have a comma here due to texinfo
373 make_ver_link(macroLang("manual"+name+mshort+'Pdf',lang),
374 "http://lilypond.org",
375 mshort+getTrans(" (did not exist in 2.12)",lang))
376 make_ver_link(macroLang("manual"+name+mshort+'Split',lang),
377 "http://lilypond.org",
378 mshort+getTrans(" (did not exist in 2.12)",lang))
379 make_ver_link(macroLang("manual"+name+mshort+'Big',lang),
380 "http://lilypond.org",
381 mshort+getTrans(" (did not exist in 2.12)",lang))
382 make_ver_link(macroLang("manual"+name+mshort+'SplitNoName',lang),
383 "http://lilypond.org",
384 mshort+getTrans(" (did not exist in 2.12)",lang))
386 # this is stupid and I shouldn't have bothered trying
387 # to support the 2.12 docs and it will be deleted once
388 # 2.14 is out and the website won't be visible to users
389 # until 2.14 is out. -gp
390 if (url.endswith('.html')):
391 make_ver_link(macroLang("manual"+name+mshort+'Pdf',lang),
393 getTrans(manual.capitalize(),lang) + '.pdf')
394 make_ver_link(macroLang("manual"+name+mshort+'Split',lang),
396 getTrans(manual.capitalize(),lang) +
397 getTrans(' (split HTML)',lang))
398 make_ver_link(macroLang("manual"+name+mshort+'Big',lang),
400 getTrans(manual.capitalize(),lang) +
401 getTrans(' (big HTML)',lang))
404 make_ver_link(macroLang("manual"+name+mshort+'Pdf',lang),
405 # TODO: this is an even stupider way of doing it
406 addLang(url+'.pdf', lang),
407 getTrans(manual.capitalize(),lang) + '.pdf')
408 make_ver_link(macroLang("manual"+name+mshort+'Split',lang),
409 addLang(url + '/index.html', lang),
410 getTrans(manual.capitalize(),lang) +
411 getTrans(' (split HTML)',lang))
412 make_ver_link(macroLang("manual"+name+mshort+'Big',lang),
413 addLang(url + '-big-page.html', lang),
414 getTrans(manual.capitalize(),lang) +
415 getTrans(' (big HTML)',lang))
416 newurl = url + '/index.html'
417 make_ver_link(macroLang("manual"+name+mshort+'SplitNoName',lang),
418 addLang(newurl, lang),
419 getTrans(manual.capitalize(),lang))
421 def make_regtest_links(name, version, lang):
422 ver_split = version.split('.')
423 ver_minor = ver_split[0] + '.' + ver_split[1]
424 url = depth + "doc/v" + ver_minor + "/input/regression/"
426 make_ver_link(macroLang("regtest"+name, lang),
427 url+"collated-files.html",
428 getTrans("Regression tests for ", lang)+version)
429 make_ver_link(macroLang("regtest"+name+"Pdf", lang),
430 url+"collated-files.pdf",
431 getTrans("PDF of regtests for ", lang)+version)
432 make_ver_link(macroLang("regtest"+name+"Xml", lang),
433 url+"musicxml/collated-files.html",
434 getTrans("MusicXML Regression tests for ", lang)+version)
435 make_ver_link(macroLang("regtest"+name+"Abc", lang),
436 url+"abc2ly/collated-files.html",
437 getTrans("abc2ly Regression tests for ", lang)+version)
438 make_ver_link(macroLang("regtest"+name+"LilypondBook", lang),
439 url+"lilypond-book/collated-files.html",
440 getTrans("lilypond-book Regression tests for ", lang)+version)
441 make_ver_link(macroLang("regtest"+name+"XmlPdf", lang),
442 url+"musicxml/collated-files.pdf",
443 getTrans("PDF of MusicXML regtests for ", lang)+version)
444 make_ver_link(macroLang("regtest"+name+"AbcPdf", lang),
445 url+"abc2ly/collated-files.pdf",
446 getTrans("PDF of abc2ly regtests for ", lang)+version)
447 make_ver_link(macroLang("regtest"+name+"LilypondBookPdf", lang),
448 url+"lilypond-book/collated-files.pdf",
449 getTrans("PDF of lilypond-book regtests for ", lang)+version)
451 def make_doctarball_links(name, version, lang):
452 url = depth + "download/binaries/documentation/lilypond-"
453 # ugly FIXME, but proper build number support isn't Critical.
454 url += version + "-1"
455 url += ".documentation.tar.bz2"
456 make_ver_link(macroLang("doctarball"+name, lang),
457 url, getTrans("Doc tarball for ", lang)+version)
459 print "@c ************************ Download binaries ************"
460 make_all_downloads("Stable", VERSION_STABLE)
461 make_all_downloads("Devel", VERSION_DEVEL)
463 print "@c ************************ Download source ************"
464 # FIXME: icky hard-coding! -gp
466 print "@c *********", lang, "***"
467 make_download_source("downloadStableSource","v2.12",VERSION_STABLE,lang)
468 make_download_source("downloadDevelSource","v2.13",VERSION_DEVEL,lang)
470 print "@c ************************ Manual links ************"
472 print "@c *********", lang, "***"
473 make_manual_links("Stable", VERSION_STABLE,lang)
474 make_manual_links("Devel", VERSION_DEVEL,lang)
476 make_doctarball_links("Stable", VERSION_STABLE,lang)
477 make_doctarball_links("Devel", VERSION_DEVEL,lang)
479 print "@c ************************ Regtest links ************"
481 print "@c *********", lang, "***"
482 make_regtest_links("Stable", VERSION_STABLE,lang)
483 make_regtest_links("Devel", VERSION_DEVEL,lang)