import re
from glob import glob
-possible_documents = ("Intro", "FAQ", "Tutorial", "UserGuide", "Extended", "Customization")
+possible_documents = ("Intro", "FAQ", "Tutorial", "UserGuide", "EmbeddedObjects", "Extended", "Customization")
lang_pattern = re.compile('^([a-z]{2})_')
-def documents(prefix):
+def documents(srcdir, prefix):
result = []
for file in possible_documents:
- fname = prefix + file + '.lyx'
+ fname = srcdir + '/' + prefix + file + '.lyx'
if os.access(fname, os.F_OK):
result.append(fname)
+ else:
+ result.append(srcdir + '/' + file + '.lyx')
return result
#
# First come the rules for each xx_TOC.lyx file. Then comes the
# TOCs target, which prints all the TOC files.
-""" % argv[0]
+""" % os.path.basename(argv[0])
# What are the languages available? And its documents?
languages = {}
- for file in glob('*'):
+ srcdir = os.path.dirname(argv[0])
+ for file in glob(srcdir + '/*.lyx'):
+ file = os.path.basename(file)
lang = lang_pattern.match(file)
if lang:
if lang.group(1) not in languages:
langs.sort()
# The default language is english and doesn't need any prefix
- print 'TOC.lyx:', '.lyx '.join(possible_documents) + '.lyx'
- print '\tpython doc_toc.py'
+ print 'TOC.lyx: $(srcdir)/' + '.lyx $(srcdir)/'.join(possible_documents) + '.lyx'
+ print '\tPYTHONPATH=$(top_builddir)/lib/lyx2lyx python -tt $(srcdir)/doc_toc.py'
print
tocs = ['TOC.lyx']
toc_name = lang + '_TOC.lyx'
tocs.append(toc_name)
- languages[lang].remove(toc_name)
+ if toc_name in languages[lang]:
+ languages[lang].remove(toc_name)
+ languages[lang].sort()
- print toc_name + ':', ' '.join(languages[lang])
- print '\tpython doc_toc.py %s' % lang
+ print toc_name + ': $(srcdir)/' + ' $(srcdir)/'.join(languages[lang])
+ print '\tPYTHONPATH=$(top_builddir)/lib/lyx2lyx python -tt $(srcdir)/doc_toc.py %s' % lang
print
# Write meta-rule to call all the other rules
- print 'TOCs:', ' '.join(tocs)
- print '\t@echo Made TOCs succesfully.'
+ print 'tocfiles =', ' '.join(tocs)
if __name__ == "__main__":