]> git.donarmstrong.com Git - lilypond.git/blob - scripts/build/create-weblinks-itexi.py
1st attempt of making weblinks to work
[lilypond.git] / scripts / build / create-weblinks-itexi.py
1 #!@PYTHON@
2 # -*- coding: utf-8 -*-
3 # create-version-itexi.py
4
5 """ when being called on lilypond.org, pass it the location of the
6 top source dir on the command-line. """
7
8 import sys
9 import os
10 import glob
11
12 # these links are relative from /website/ on lilypond.org
13 depth = "../"
14
15 ### translation data -- shouldn't be here; see issue
16 ### http://code.google.com/p/lilypond/issues/detail?id=1050
17
18 # don't add your language to this list unless you have all the
19 # items.
20 langs = ['', 'es']
21
22 # FIXME: `grep -nH -B1 translationof Documentation/<lang>/web/*'
23 # gives us the correct node names.
24 translations = {
25     'es': {
26         'Source': 'Código fuente',
27
28         'Learning': 'Aprendizaje',
29         'Music glossary': 'Glosario',
30         'Essay': 'Ensayo',
31         'Notation': 'Notación',
32         'Usage': 'Utilización',
33         'Snippets': 'Fragmentos',
34         'Web': 'Web',
35         'Changes': 'Cambios',
36         'Extending': 'Extensión',
37         'Internals': 'Funcionamiento interno',
38         'Contributor': 'Guía del colaborador',
39
40 # keep the spaces!
41         ' (split HTML)': ' (HTML seccionado)',
42         ' (big HTML)': ' (HTML monolítico)',
43
44         'Regression tests for ': 'Pruebas de regresión para ',
45         'PDF of regtests for ': 'Pruebas en PDF para ',
46         'MusicXML Regression tests for ': 'Pruebas de regresión de MusicXML para ',
47         'PDF of MusicXML regtests for ': 'Pruebas de MusicXML en PDF para ',
48
49         'Doc tarball for ': 'Tarball de la documentación para ',
50         ' (did not exist in 2.12)': ' (no existía en la versión 2.12)',
51      },
52     'fr': {
53         'Learning': 'Apprener?',
54         'Music glossary': 'Lizes ici pour les motes?',
55      },
56     'nl': {
57         'Source': 'Broncode',
58
59         'Learning': 'Beginnen',
60         'Music glossary': 'Terminologie',
61         'Essay': 'Essay',
62         'Notation': 'Notatie',
63         'Usage': 'Gebruik',
64         'Snippets': 'Snippers',
65         'Web': 'Web',
66         'Changes': 'Veranderingen',
67         'Extending': 'Uitbreidingen',
68         'Internals': 'Internals',
69         'Contributor': 'Contributor',
70
71 # keep the spaces!
72         ' (split HTML)': ' (opgesplitste HTML)',
73         ' (big HTML)': ' (grote pagina HTML)',
74
75         'Regression tests for ': 'Regressietesten voor ',
76         'PDF of regtests for ': 'PDF van regressietesten voor ',
77         'MusicXML Regression tests for ': 'MusicXML regressietesten voor ',
78         'PDF of MusicXML regtests for ': 'MusicXML regressietesten voor ',
79
80         'Doc tarball for ': 'Tarball met documentation voor ',
81         ' (did not exist in 2.12)': ' (bestond nog niet in 2.12)',
82      },
83 }
84
85
86
87 ### actual program
88
89
90 VERSION_STABLE = ""
91 VERSION_DEVEL = ""
92
93 try:
94     topDir = sys.argv[1]
95 except:
96     myDir = os.path.dirname(sys.argv[0])
97     # use two abspaths to work around some windows python bug
98     topDir = os.path.join(os.path.abspath(myDir)+os.sep+'..'+os.sep+'..'+os.sep)
99     topDir = os.path.abspath( topDir )
100
101
102 # TODO: this might be useful for other scripts; can we make it available?
103 manuals = map(lambda x: os.path.splitext(x)[0],
104               map(os.path.basename,
105                   glob.glob(os.path.join(topDir,'Documentation', '*.te??'))))
106 #manuals = map(lambda x: 'glossary' if x=='music-glossary' else x, manuals)
107 manuals.append('internals')
108
109
110 version_file_path = os.path.join(topDir, "VERSION")
111
112 version_contents = open(version_file_path).readlines()
113 major = 0
114 minor = 0
115 patch = 0
116 for line in version_contents:
117     if (line.startswith('MAJOR_VERSION')):
118         major = line[14:-1]
119     if (line.startswith('MINOR_VERSION')):
120         minor = line[14:-1]
121     if (line.startswith('PATCH_LEVEL')):
122         patch = line[12:-1]
123     if (line.startswith('VERSION_STABLE')):
124         VERSION_STABLE = line[15:-1]
125     if (line.startswith('VERSION_DEVEL')):
126         VERSION_DEVEL = line[14:-1]
127
128 VERSION = str(major)+'.'+str(minor)+'.'+str(patch)
129
130 def getTrans(text, lang):
131     if (lang != ''):
132         text = translations[lang][text]
133     return text
134
135 def macroLang(name, lang):
136     if (lang != ''):
137         return name + '-' + lang
138     return name
139
140 def make_macro(name, string):
141     print "@macro", name
142     print string
143     print "@end macro"
144     print ""
145
146 def make_download(name, osA, osB, version, revision, text):
147     string = "@uref{http://download.linuxaudio.org/lilypond/binaries/"
148     string += osA + "lilypond-"
149     string += version + "-" + revision
150     string += "." + osB + ",\n"
151     string += text
152     string += ": LilyPond "
153     string += version + "-" + revision
154     string += "}"
155     make_macro(name, string)
156
157 def make_download_source(name, vstring, version, lang):
158     string = "@uref{http://download.linuxaudio.org/lilypond/sources/"
159     string += vstring + "/"
160     string += "lilypond-" + version + ".tar.gz"
161     string += ", "
162     string += getTrans("Source", lang)
163     string += ": lilypond-" + version + ".tar.gz"
164     string += "}"
165     make_macro(macroLang(name,lang), string)
166
167 def make_all_downloads(macroName, version):
168     make_download("download"+macroName+"LinuxNormal", "linux-x86/",
169         "linux-x86.sh",    version, "1", "Linux x86")
170     make_download("download"+macroName+"LinuxBig", "linux-64/",
171         "linux-64.sh", version, "1", "Linux 64")
172     make_download("download"+macroName+"LinuxPPC", "linux-ppc/",
173         "linux-ppc.sh", version, "1", "Linux PPC")
174
175     make_download("download"+macroName+"FreeBSDNormal", "freebsd-x86/",
176         "freebsd-x86.sh", version, "1", "FreeBSD i386")
177     make_download("download"+macroName+"FreeBSDBig", "freebsd-64/",
178         "freebsd-64.sh", version, "1", "FreeBSD amd64")
179
180     make_download("download"+macroName+"DarwinNormal", "darwin-x86/",
181         "darwin-x86.tar.bz2", version, "1", "MacOS X x86")
182     make_download("download"+macroName+"DarwinPPC", "darwin-ppc/",
183         "darwin-ppc.tar.bz2", version, "1", "MacOS X PPC")
184
185     make_download("download"+macroName+"Windows", "mingw/",
186         "mingw.exe", version, "1", "Windows")
187
188 def make_ver_link(macroname, url, linktext):
189     string = "@uref{"
190     string += url
191     string += ","
192     string += linktext
193     string += "}"
194     make_macro(macroname, string)
195
196 # TODO: this kind of thing should really be in a central place for
197 # lilypond python build scripts
198 def translateNameToUrl(manual, version):
199     ver_split = version.split('.')
200     ver_minor = ver_split[0] + '.' + ver_split[1]
201     url = depth + "doc/v" + ver_minor + "/Documentation/"
202
203     if (ver_minor == '2.13'):
204         return url+manual
205     if (ver_minor == '2.12'):
206         if (manual=='learning'):
207             return url+'user/lilypond-learning'
208         elif (manual=='internals'):
209             return url+'user/lilypond-internals'
210         elif (manual=='notation'):
211             return url+'user/lilypond'
212         elif (manual=='usage'):
213             return url+'user/lilypond-program'
214         elif (manual=='snippets'):
215             return url+'../input/lsr/lilypond-snippets'
216         elif (manual=='changes'):
217             return url+'topdocs/NEWS.html'
218         elif (manual=='music-glossary'):
219             return url+'user/music-glossary'
220         elif (manual=='essay'):
221             return url+'user/lilypond-learning/Background.html'
222         elif (manual=='extending'):
223             return url+'user/lilypond/Interfaces-for-programmers.html'
224         else:
225             return ''
226
227
228 def make_manual_links(name, version, lang):
229     """Here is where all the macros manualStableLearningSplit,
230     manualStableLearningBig, manualStableLearningSplitNoName, etc. are
231     created on the fly.  Hopefully this documentation string will help
232     others a bit while grepping for those.
233     """
234     for m in manuals:
235         manual = m
236         # TODO: this is a stupid way of doing it
237         if (m=='music-glossary'):
238             mshort = 'Glossary'
239         else:
240             mshort = m.capitalize()
241         if (manual=='music-glossary'):
242             manual = 'Music glossary'
243         url = translateNameToUrl(m, version)
244
245         if (url == ''):
246             # can't have a comma here due to texinfo
247             make_ver_link(macroLang("manual"+name+mshort+'Pdf',lang),
248                 "http://lilypond.org",
249                 mshort+getTrans(" (did not exist in 2.12)",lang))
250             make_ver_link(macroLang("manual"+name+mshort+'Split',lang),
251                 "http://lilypond.org",
252                 mshort+getTrans(" (did not exist in 2.12)",lang))
253             make_ver_link(macroLang("manual"+name+mshort+'Big',lang),
254                 "http://lilypond.org",
255                 mshort+getTrans(" (did not exist in 2.12)",lang))
256             make_ver_link(macroLang("manual"+name+mshort+'SplitNoName',lang),
257                 "http://lilypond.org",
258                 mshort+getTrans(" (did not exist in 2.12)",lang))
259             continue
260         make_ver_link(macroLang("manual"+name+mshort+'Pdf',lang),
261                   url + '.pdf',
262                   getTrans(manual.capitalize(),lang) + '.pdf')
263         make_ver_link(macroLang("manual"+name+mshort+'Split',lang),
264                   url + '/index.html',
265                   getTrans(manual.capitalize(),lang) +
266                   getTrans(' (split HTML)',lang))
267         make_ver_link(macroLang("manual"+name+mshort+'Big',lang),
268                   url + '-big-page.html',
269                   getTrans(manual.capitalize(),lang) +
270                   getTrans(' (big HTML)',lang))
271         # this is stupid and I shouldn't have bothered trying
272         # to support the 2.12 docs and it will be deleted once
273         # 2.14 is out and the website won't be visible to users
274         # until 2.14 is out.  -gp
275         if (url.endswith('.html')):
276             newurl = url
277         else:
278             newurl = url + '/index.html'
279         make_ver_link(macroLang("manual"+name+mshort+'SplitNoName',lang),
280                   newurl,
281                   getTrans(manual.capitalize(),lang))
282
283 def make_regtest_links(name, version, lang):
284     ver_split = version.split('.')
285     ver_minor = ver_split[0] + '.' + ver_split[1]
286     url = depth + "doc/v" + ver_minor + "/input/regression/"
287
288     make_ver_link(macroLang("regtest"+name, lang),
289         url+"collated-files.html",
290         getTrans("Regression tests for ", lang)+version)
291     make_ver_link(macroLang("regtest"+name+"Pdf", lang),
292         url+"collated-files.pdf",
293         getTrans("PDF of regtests for ", lang)+version)
294     make_ver_link(macroLang("regtest"+name+"Xml", lang),
295         url+"musicxml/collated-files.html",
296         getTrans("MusicXML Regression tests for ", lang)+version)
297     make_ver_link(macroLang("regtest"+name+"XmlPdf", lang),
298          url+"musicxml/collated-files.html",
299         getTrans("PDF of MusicXML regtests for ", lang)+version)
300
301 def make_doctarball_links(name, version, lang):
302     url = depth + "download/binaries/documentation/lilypond-"
303     # ugly FIXME, but proper build number support isn't Critical.
304     url += version + "-1"
305     url += ".documentation.tar.bz2"
306     make_ver_link(macroLang("doctarball"+name, lang),
307         url, getTrans("Doc tarball for ", lang)+version)
308
309 print "@c ************************ Download binaries ************"
310 make_all_downloads("Stable", VERSION_STABLE)
311 make_all_downloads("Devel", VERSION_DEVEL)
312
313 print "@c ************************ Download source ************"
314 # FIXME: icky hard-coding!  -gp
315 for lang in langs:
316     print "@c *********", lang, "***"
317     make_download_source("downloadStableSource","v2.12",VERSION_STABLE,lang)
318     make_download_source("downloadDevelSource","v2.13",VERSION_DEVEL,lang)
319
320 print "@c ************************ Manual links ************"
321 for lang in langs:
322     print "@c *********", lang, "***"
323     make_manual_links("Stable", VERSION_STABLE,lang)
324     make_manual_links("Devel", VERSION_DEVEL,lang)
325
326     make_doctarball_links("Stable", VERSION_STABLE,lang)
327     make_doctarball_links("Devel", VERSION_DEVEL,lang)
328
329 print "@c ************************ Regtest links ************"
330 for lang in langs:
331     print "@c *********", lang, "***"
332     make_regtest_links("Stable", VERSION_STABLE,lang)
333     make_regtest_links("Devel", VERSION_DEVEL,lang)
334
335