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': '内部リファレンス',
158 'Regression tests for ': 0,
159 'PDF of regtests for ': 0,
160 'MusicXML Regression tests for ': 0,
161 'PDF of MusicXML regtests for ': 0,
163 'Doc tarball for ': 0,
164 ' (did not exist in 2.12)': 0,
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)',
208 myDir = os.path.dirname(sys.argv[0])
209 # use two abspaths to work around some windows python bug
210 topDir = os.path.join(os.path.abspath(myDir)+os.sep+'..'+os.sep+'..'+os.sep)
211 topDir = os.path.abspath( topDir )
214 # TODO: this might be useful for other scripts; can we make it available?
215 manuals = map(lambda x: os.path.splitext(x)[0],
216 map(os.path.basename,
217 glob.glob(os.path.join(topDir,'Documentation', '*.te??'))))
218 #manuals = map(lambda x: 'glossary' if x=='music-glossary' else x, manuals)
219 manuals.append('internals')
222 version_file_path = os.path.join(topDir, "VERSION")
224 version_contents = open(version_file_path).readlines()
228 for line in version_contents:
229 if (line.startswith('MAJOR_VERSION')):
231 if (line.startswith('MINOR_VERSION')):
233 if (line.startswith('PATCH_LEVEL')):
235 if (line.startswith('VERSION_STABLE')):
236 VERSION_STABLE = line[15:-1]
237 if (line.startswith('VERSION_DEVEL')):
238 VERSION_DEVEL = line[14:-1]
240 VERSION = str(major)+'.'+str(minor)+'.'+str(patch)
242 def _ (string, lang):
243 return translations.get (lang.split ('_')[0], {}).get (string, string)
246 # let's not barf, but print a warning when something's missing
247 def getTrans(text, lang):
248 trans = _ (text, lang)
251 sys.stderr.write ('create-weblinks-itexi: warning: [%(lang)s]: translation missing for: %(text)s\n' % locals ())
254 def macroLang(name, lang):
256 return name + '-' + lang
259 def make_macro(name, string):
265 def make_download(name, osA, osB, version, revision, text):
266 string = "@uref{http://download.linuxaudio.org/lilypond/binaries/"
267 string += osA + "lilypond-"
268 string += version + "-" + revision
269 string += "." + osB + ",\n"
271 string += ": LilyPond "
272 string += version + "-" + revision
274 make_macro(name, string)
276 def make_download_source(name, vstring, version, lang):
277 string = "@uref{http://download.linuxaudio.org/lilypond/sources/"
278 string += vstring + "/"
279 string += "lilypond-" + version + ".tar.gz"
281 string += getTrans("Source", lang)
282 string += ": lilypond-" + version + ".tar.gz"
284 make_macro(macroLang(name,lang), string)
286 def make_all_downloads(macroName, version):
287 make_download("download"+macroName+"LinuxNormal", "linux-x86/",
288 "linux-x86.sh", version, "1", "Linux x86")
289 make_download("download"+macroName+"LinuxBig", "linux-64/",
290 "linux-64.sh", version, "1", "Linux 64")
291 make_download("download"+macroName+"LinuxPPC", "linux-ppc/",
292 "linux-ppc.sh", version, "1", "Linux PPC")
294 make_download("download"+macroName+"FreeBSDNormal", "freebsd-x86/",
295 "freebsd-x86.sh", version, "1", "FreeBSD i386")
296 make_download("download"+macroName+"FreeBSDBig", "freebsd-64/",
297 "freebsd-64.sh", version, "1", "FreeBSD amd64")
299 make_download("download"+macroName+"DarwinNormal", "darwin-x86/",
300 "darwin-x86.tar.bz2", version, "1", "MacOS X x86")
301 make_download("download"+macroName+"DarwinPPC", "darwin-ppc/",
302 "darwin-ppc.tar.bz2", version, "1", "MacOS X PPC")
304 make_download("download"+macroName+"Windows", "mingw/",
305 "mingw.exe", version, "1", "Windows")
307 def make_ver_link(macroname, url, linktext):
313 make_macro(macroname, string)
315 # TODO: this kind of thing should really be in a central place for
316 # lilypond python build scripts
317 def translateNameToUrl(manual, version):
318 ver_split = version.split('.')
319 ver_minor = ver_split[0] + '.' + ver_split[1]
320 url = depth + "doc/v" + ver_minor + "/Documentation/"
322 if (ver_minor == '2.13'):
324 if (ver_minor == '2.12'):
325 if (manual=='learning'):
326 return url+'user/lilypond-learning'
327 elif (manual=='internals'):
328 return url+'user/lilypond-internals'
329 elif (manual=='notation'):
330 return url+'user/lilypond'
331 elif (manual=='usage'):
332 return url+'user/lilypond-program'
333 elif (manual=='snippets'):
334 return url+'../input/lsr/lilypond-snippets'
335 elif (manual=='changes'):
336 return url+'topdocs/NEWS.html'
337 elif (manual=='music-glossary'):
338 return url+'user/music-glossary'
339 elif (manual=='essay'):
340 return url+'user/lilypond-learning/Background.html'
341 elif (manual=='extending'):
342 return url+'user/lilypond/Interfaces-for-programmers.html'
346 def addLang(url, lang):
348 base, ext = os.path.splitext(url)
349 return base + '.' + lang + ext
353 def make_manual_links(name, version, lang):
354 """Here is where all the macros manualStableLearningSplit,
355 manualStableLearningBig, manualStableLearningSplitNoName, etc. are
356 created on the fly. Hopefully this documentation string will help
357 others a bit while grepping for those.
361 # TODO: this is a stupid way of doing it
362 if (m=='music-glossary'):
365 mshort = m.capitalize()
366 if (manual=='music-glossary'):
367 manual = 'Music glossary'
368 url = translateNameToUrl(m, version)
371 # can't have a comma here due to texinfo
372 make_ver_link(macroLang("manual"+name+mshort+'Pdf',lang),
373 "http://lilypond.org",
374 mshort+getTrans(" (did not exist in 2.12)",lang))
375 make_ver_link(macroLang("manual"+name+mshort+'Split',lang),
376 "http://lilypond.org",
377 mshort+getTrans(" (did not exist in 2.12)",lang))
378 make_ver_link(macroLang("manual"+name+mshort+'Big',lang),
379 "http://lilypond.org",
380 mshort+getTrans(" (did not exist in 2.12)",lang))
381 make_ver_link(macroLang("manual"+name+mshort+'SplitNoName',lang),
382 "http://lilypond.org",
383 mshort+getTrans(" (did not exist in 2.12)",lang))
385 # this is stupid and I shouldn't have bothered trying
386 # to support the 2.12 docs and it will be deleted once
387 # 2.14 is out and the website won't be visible to users
388 # until 2.14 is out. -gp
389 if (url.endswith('.html')):
390 make_ver_link(macroLang("manual"+name+mshort+'Pdf',lang),
392 getTrans(manual.capitalize(),lang) + '.pdf')
393 make_ver_link(macroLang("manual"+name+mshort+'Split',lang),
395 getTrans(manual.capitalize(),lang) +
396 getTrans(' (split HTML)',lang))
397 make_ver_link(macroLang("manual"+name+mshort+'Big',lang),
399 getTrans(manual.capitalize(),lang) +
400 getTrans(' (big HTML)',lang))
403 make_ver_link(macroLang("manual"+name+mshort+'Pdf',lang),
404 # TODO: this is an even stupider way of doing it
405 addLang(url+'.pdf', lang),
406 getTrans(manual.capitalize(),lang) + '.pdf')
407 make_ver_link(macroLang("manual"+name+mshort+'Split',lang),
408 addLang(url + '/index.html', lang),
409 getTrans(manual.capitalize(),lang) +
410 getTrans(' (split HTML)',lang))
411 make_ver_link(macroLang("manual"+name+mshort+'Big',lang),
412 addLang(url + '-big-page.html', lang),
413 getTrans(manual.capitalize(),lang) +
414 getTrans(' (big HTML)',lang))
415 newurl = url + '/index.html'
416 make_ver_link(macroLang("manual"+name+mshort+'SplitNoName',lang),
417 addLang(newurl, lang),
418 getTrans(manual.capitalize(),lang))
420 def make_regtest_links(name, version, lang):
421 ver_split = version.split('.')
422 ver_minor = ver_split[0] + '.' + ver_split[1]
423 url = depth + "doc/v" + ver_minor + "/input/regression/"
425 make_ver_link(macroLang("regtest"+name, lang),
426 url+"collated-files.html",
427 getTrans("Regression tests for ", lang)+version)
428 make_ver_link(macroLang("regtest"+name+"Pdf", lang),
429 url+"collated-files.pdf",
430 getTrans("PDF of regtests for ", lang)+version)
431 make_ver_link(macroLang("regtest"+name+"Xml", lang),
432 url+"musicxml/collated-files.html",
433 getTrans("MusicXML Regression tests for ", lang)+version)
434 make_ver_link(macroLang("regtest"+name+"Abc", lang),
435 url+"abc2ly/collated-files.html",
436 getTrans("abc2ly Regression tests for ", lang)+version)
437 make_ver_link(macroLang("regtest"+name+"LilypondBook", lang),
438 url+"lilypond-book/collated-files.html",
439 getTrans("lilypond-book Regression tests for ", lang)+version)
440 make_ver_link(macroLang("regtest"+name+"XmlPdf", lang),
441 url+"musicxml/collated-files.pdf",
442 getTrans("PDF of MusicXML regtests for ", lang)+version)
443 make_ver_link(macroLang("regtest"+name+"AbcPdf", lang),
444 url+"abc2ly/collated-files.pdf",
445 getTrans("PDF of abc2ly regtests for ", lang)+version)
446 make_ver_link(macroLang("regtest"+name+"LilypondBookPdf", lang),
447 url+"lilypond-book/collated-files.pdf",
448 getTrans("PDF of lilypond-book regtests for ", lang)+version)
450 def make_doctarball_links(name, version, lang):
451 url = depth + "download/binaries/documentation/lilypond-"
452 # ugly FIXME, but proper build number support isn't Critical.
453 url += version + "-1"
454 url += ".documentation.tar.bz2"
455 make_ver_link(macroLang("doctarball"+name, lang),
456 url, getTrans("Doc tarball for ", lang)+version)
458 print "@c ************************ Download binaries ************"
459 make_all_downloads("Stable", VERSION_STABLE)
460 make_all_downloads("Devel", VERSION_DEVEL)
462 print "@c ************************ Download source ************"
463 # FIXME: icky hard-coding! -gp
465 print "@c *********", lang, "***"
466 make_download_source("downloadStableSource","v2.12",VERSION_STABLE,lang)
467 make_download_source("downloadDevelSource","v2.13",VERSION_DEVEL,lang)
469 print "@c ************************ Manual links ************"
471 print "@c *********", lang, "***"
472 make_manual_links("Stable", VERSION_STABLE,lang)
473 make_manual_links("Devel", VERSION_DEVEL,lang)
475 make_doctarball_links("Stable", VERSION_STABLE,lang)
476 make_doctarball_links("Devel", VERSION_DEVEL,lang)
478 print "@c ************************ Regtest links ************"
480 print "@c *********", lang, "***"
481 make_regtest_links("Stable", VERSION_STABLE,lang)
482 make_regtest_links("Devel", VERSION_DEVEL,lang)