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',
45 'Internals': 'Interna',
51 'Regression tests for ': 0,
52 'PDF of regtests for ': 0,
53 'MusicXML Regression tests for ': 0,
54 'PDF of MusicXML regtests for ': 0,
56 'Doc tarball for ': 0,
57 ' (did not exist in 2.12)': 0,
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',
126 'Internals': 'Belső működés',
132 'Regression tests for ': 0,
133 'PDF of regtests for ': 0,
134 'MusicXML Regression tests for ': 0,
135 'PDF of MusicXML regtests for ': 0,
137 'Doc tarball for ': 0,
138 ' (did not exist in 2.12)': 0,
143 'Music glossary': '用語集',
147 'Snippets': 'コード断片集',
153 'Internals': '内部リファレンス',
159 'Regression tests for ': 0,
160 'PDF of regtests for ': 0,
161 'MusicXML Regression tests for ': 0,
162 'PDF of MusicXML regtests for ': 0,
164 'Doc tarball for ': 0,
165 ' (did not exist in 2.12)': 0,
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'
348 def make_manual_links(name, version, lang):
349 """Here is where all the macros manualStableLearningSplit,
350 manualStableLearningBig, manualStableLearningSplitNoName, etc. are
351 created on the fly. Hopefully this documentation string will help
352 others a bit while grepping for those.
356 # TODO: this is a stupid way of doing it
357 if (m=='music-glossary'):
360 mshort = m.capitalize()
361 if (manual=='music-glossary'):
362 manual = 'Music glossary'
363 url = translateNameToUrl(m, version)
366 # can't have a comma here due to texinfo
367 make_ver_link(macroLang("manual"+name+mshort+'Pdf',lang),
368 "http://lilypond.org",
369 mshort+getTrans(" (did not exist in 2.12)",lang))
370 make_ver_link(macroLang("manual"+name+mshort+'Split',lang),
371 "http://lilypond.org",
372 mshort+getTrans(" (did not exist in 2.12)",lang))
373 make_ver_link(macroLang("manual"+name+mshort+'Big',lang),
374 "http://lilypond.org",
375 mshort+getTrans(" (did not exist in 2.12)",lang))
376 make_ver_link(macroLang("manual"+name+mshort+'SplitNoName',lang),
377 "http://lilypond.org",
378 mshort+getTrans(" (did not exist in 2.12)",lang))
380 make_ver_link(macroLang("manual"+name+mshort+'Pdf',lang),
382 getTrans(manual.capitalize(),lang) + '.pdf')
383 make_ver_link(macroLang("manual"+name+mshort+'Split',lang),
385 getTrans(manual.capitalize(),lang) +
386 getTrans(' (split HTML)',lang))
387 make_ver_link(macroLang("manual"+name+mshort+'Big',lang),
388 url + '-big-page.html',
389 getTrans(manual.capitalize(),lang) +
390 getTrans(' (big HTML)',lang))
391 # this is stupid and I shouldn't have bothered trying
392 # to support the 2.12 docs and it will be deleted once
393 # 2.14 is out and the website won't be visible to users
394 # until 2.14 is out. -gp
395 if (url.endswith('.html')):
398 newurl = url + '/index.html'
399 make_ver_link(macroLang("manual"+name+mshort+'SplitNoName',lang),
401 getTrans(manual.capitalize(),lang))
403 def make_regtest_links(name, version, lang):
404 ver_split = version.split('.')
405 ver_minor = ver_split[0] + '.' + ver_split[1]
406 url = depth + "doc/v" + ver_minor + "/input/regression/"
408 make_ver_link(macroLang("regtest"+name, lang),
409 url+"collated-files.html",
410 getTrans("Regression tests for ", lang)+version)
411 make_ver_link(macroLang("regtest"+name+"Pdf", lang),
412 url+"collated-files.pdf",
413 getTrans("PDF of regtests for ", lang)+version)
414 make_ver_link(macroLang("regtest"+name+"Xml", lang),
415 url+"musicxml/collated-files.html",
416 getTrans("MusicXML Regression tests for ", lang)+version)
417 make_ver_link(macroLang("regtest"+name+"XmlPdf", lang),
418 url+"musicxml/collated-files.html",
419 getTrans("PDF of MusicXML regtests for ", lang)+version)
421 def make_doctarball_links(name, version, lang):
422 url = depth + "download/binaries/documentation/lilypond-"
423 # ugly FIXME, but proper build number support isn't Critical.
424 url += version + "-1"
425 url += ".documentation.tar.bz2"
426 make_ver_link(macroLang("doctarball"+name, lang),
427 url, getTrans("Doc tarball for ", lang)+version)
429 print "@c ************************ Download binaries ************"
430 make_all_downloads("Stable", VERSION_STABLE)
431 make_all_downloads("Devel", VERSION_DEVEL)
433 print "@c ************************ Download source ************"
434 # FIXME: icky hard-coding! -gp
436 print "@c *********", lang, "***"
437 make_download_source("downloadStableSource","v2.12",VERSION_STABLE,lang)
438 make_download_source("downloadDevelSource","v2.13",VERSION_DEVEL,lang)
440 print "@c ************************ Manual links ************"
442 print "@c *********", lang, "***"
443 make_manual_links("Stable", VERSION_STABLE,lang)
444 make_manual_links("Devel", VERSION_DEVEL,lang)
446 make_doctarball_links("Stable", VERSION_STABLE,lang)
447 make_doctarball_links("Devel", VERSION_DEVEL,lang)
449 print "@c ************************ Regtest links ************"
451 print "@c *********", lang, "***"
452 make_regtest_links("Stable", VERSION_STABLE,lang)
453 make_regtest_links("Devel", VERSION_DEVEL,lang)