generate TOC files on the fly and fix broken documents (bug 2027)

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10491 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Georg Baum 2005-09-28 13:47:03 +00:00
parent 82765345ac
commit 58380ba97a
6 changed files with 43 additions and 47 deletions

View File

@ -1,3 +1,13 @@
2005-09-28 Georg Baum <Georg.Baum@post.rwth-aachen.de>
* de_UserGuide.lyx, it_UserGuide.lyx: repair invalid syntax, maybe
caused by a lyx2lyx bug
* Makefile.am: generate TOC files automatically
* Makefile.am: rework TOC generation rules to work with srcdir != builddir
* depend.py: make it work with srcdir != builddir
* depend.py: adjust generated TOCs rule to Makefile.am changes
* doc_toc.py: make it work with srcdir != builddir
2005-09-28 Jürgen Spitzmüller <j.spitzmueller@gmx.de> 2005-09-28 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
* UserGuide.lyx: * UserGuide.lyx:

View File

@ -1,31 +1,26 @@
include $(top_srcdir)/config/common.am include $(top_srcdir)/config/common.am
DISTCLEANFILES += LyXConfig.lyx LaTeXConfig.lyx Makefile.depend DISTCLEANFILES += LyXConfig.lyx LaTeXConfig.lyx $(TOCs)
EXTRA_DIST = depend.py doc_toc.py LyXConfig.lyx.in README.Documentation $(docfiles) EXTRA_DIST = depend.py doc_toc.py LyXConfig.lyx.in README.Documentation $(DEPENDFILE) $(docfiles)
docfiles = \ docfiles = $(TOCs) \
cs_TOC.lyx \
cs_Tutorial.lyx \ cs_Tutorial.lyx \
Customization.lyx \ Customization.lyx \
da_Intro.lyx \ da_Intro.lyx \
da_TOC.lyx \
de_Customization.lyx \ de_Customization.lyx \
de_Extended.lyx \ de_Extended.lyx \
de_FAQ.lyx \ de_FAQ.lyx \
de_Intro.lyx \ de_Intro.lyx \
de_TOC.lyx \
de_Tutorial.lyx \ de_Tutorial.lyx \
de_UserGuide.lyx \ de_UserGuide.lyx \
DocStyle.lyx \ DocStyle.lyx \
es_Intro.lyx \ es_Intro.lyx \
es_TOC.lyx \
es_Tutorial.lyx \ es_Tutorial.lyx \
eu_Customization.lyx \ eu_Customization.lyx \
eu_Extended.lyx \ eu_Extended.lyx \
eu_FAQ.lyx \ eu_FAQ.lyx \
eu_Intro.lyx \ eu_Intro.lyx \
eu_TOC.lyx \
eu_Tutorial.lyx \ eu_Tutorial.lyx \
eu_UserGuide.lyx \ eu_UserGuide.lyx \
Extended.lyx \ Extended.lyx \
@ -34,50 +29,36 @@ docfiles = \
fr_Extended.lyx \ fr_Extended.lyx \
fr_FAQ.lyx \ fr_FAQ.lyx \
fr_Intro.lyx \ fr_Intro.lyx \
fr_TOC.lyx \
fr_Tutorial.lyx \ fr_Tutorial.lyx \
fr_UserGuide.lyx \ fr_UserGuide.lyx \
he_Intro.lyx \ he_Intro.lyx \
he_TOC.lyx \
he_Tutorial.lyx \ he_Tutorial.lyx \
hu_Intro.lyx \ hu_Intro.lyx \
hu_TOC.lyx \
Intro.lyx \ Intro.lyx \
it_Customization.lyx \ it_Customization.lyx \
it_Intro.lyx \ it_Intro.lyx \
it_TOC.lyx \
it_Tutorial.lyx \ it_Tutorial.lyx \
it_UserGuide.lyx \ it_UserGuide.lyx \
LaTeXConfig.lyx.in \ LaTeXConfig.lyx.in \
nl_Intro.lyx \ nl_Intro.lyx \
nl_TOC.lyx \
nl_Tutorial.lyx \ nl_Tutorial.lyx \
no_Intro.lyx \ no_Intro.lyx \
no_TOC.lyx \
pl_Extended.lyx \ pl_Extended.lyx \
pl_Intro.lyx \ pl_Intro.lyx \
pl_TOC.lyx \
pl_Tutorial.lyx \ pl_Tutorial.lyx \
pt_Intro.lyx \ pt_Intro.lyx \
pt_TOC.lyx \
pt_Tutorial.lyx \ pt_Tutorial.lyx \
Reference.lyx \ Reference.lyx \
ro_Intro.lyx \ ro_Intro.lyx \
ro_TOC.lyx \
ru_FAQ.lyx \ ru_FAQ.lyx \
ru_Intro.lyx \ ru_Intro.lyx \
ru_TOC.lyx \
ru_Tutorial.lyx \ ru_Tutorial.lyx \
sk_TOC.lyx \
sk_Tutorial.lyx \ sk_Tutorial.lyx \
sk_UserGuide.lyx \ sk_UserGuide.lyx \
sl_Intro.lyx \ sl_Intro.lyx \
sl_TOC.lyx \
sl_Tutorial.lyx \ sl_Tutorial.lyx \
sv_Intro.lyx \ sv_Intro.lyx \
sv_TOC.lyx \
sv_Tutorial.lyx \ sv_Tutorial.lyx \
TOC.lyx \
Tutorial.lyx \ Tutorial.lyx \
UserGuide.lyx \ UserGuide.lyx \
escher-lsd.eps \ escher-lsd.eps \
@ -89,16 +70,18 @@ doc_DATA = \
$(docfiles) \ $(docfiles) \
LaTeXConfig.lyx LaTeXConfig.lyx
# TODO can we instead just #include the DEPENDFILE in this Makefile?
# problem with this is that the DEPENDFILE that's included won't be the updated
# one. JMarc should know how to handle this.
DEPENDFILE = Makefile.depend DEPENDFILE = Makefile.depend
include $(DEPENDFILE)
TOCs : depend TOCs : $(DEPENDFILE) $(TOCs)
make -f $(DEPENDFILE) TOCs @echo Made TOCs succesfully.
depend: # Force regeneration of $(DEPENDFILE) when Makefile.am changes because
python depend.py > $(DEPENDFILE) # new doc files might have been added
$(DEPENDFILE): Makefile.am
python $(srcdir)/depend.py > $(DEPENDFILE)
.PHONY: depend # Force generation of the TOC files for 'make dist'
distdir: TOCs
.PHONY: TOCs

View File

@ -10653,8 +10653,6 @@ Umschalt+Alt\InsetSpace ~
\end_layout \end_layout
\begin_deeper \begin_deeper
\end_layout
\begin_deeper \begin_deeper
\begin_layout Standard \begin_layout Standard

View File

@ -31,12 +31,14 @@ from glob import glob
possible_documents = ("Intro", "FAQ", "Tutorial", "UserGuide", "Extended", "Customization") possible_documents = ("Intro", "FAQ", "Tutorial", "UserGuide", "Extended", "Customization")
lang_pattern = re.compile('^([a-z]{2})_') lang_pattern = re.compile('^([a-z]{2})_')
def documents(prefix): def documents(srcdir, prefix):
result = [] result = []
for file in possible_documents: for file in possible_documents:
fname = prefix + file + '.lyx' fname = srcdir + '/' + prefix + file + '.lyx'
if os.access(fname, os.F_OK): if os.access(fname, os.F_OK):
result.append(fname) result.append(fname)
else:
result.append(srcdir + '/' + file + '.lyx')
return result return result
@ -50,8 +52,9 @@ def main(argv):
# What are the languages available? And its documents? # What are the languages available? And its documents?
languages = {} languages = {}
for file in glob('*'): srcdir = os.path.dirname(argv[0])
lang = lang_pattern.match(file) for file in glob(srcdir + '/*'):
lang = lang_pattern.match(os.path.basename(file))
if lang: if lang:
if lang.group(1) not in languages: if lang.group(1) not in languages:
languages[lang.group(1)] = [file] languages[lang.group(1)] = [file]
@ -63,8 +66,8 @@ def main(argv):
langs.sort() langs.sort()
# The default language is english and doesn't need any prefix # The default language is english and doesn't need any prefix
print 'TOC.lyx:', '.lyx '.join(possible_documents) + '.lyx' print 'TOC.lyx:', ('.lyx ' + srcdir + '/').join(possible_documents) + '.lyx'
print '\tpython doc_toc.py' print '\tpython %s/doc_toc.py' % srcdir
print print
tocs = ['TOC.lyx'] tocs = ['TOC.lyx']
@ -73,15 +76,17 @@ def main(argv):
toc_name = lang + '_TOC.lyx' toc_name = lang + '_TOC.lyx'
tocs.append(toc_name) tocs.append(toc_name)
if toc_name in languages[lang]:
languages[lang].remove(toc_name) languages[lang].remove(toc_name)
if srcdir + '/' + toc_name in languages[lang]:
languages[lang].remove(srcdir + '/' + toc_name)
print toc_name + ':', ' '.join(languages[lang]) print toc_name + ':', ' '.join(languages[lang])
print '\tpython doc_toc.py %s' % lang print '\tpython %s/doc_toc.py %s' % (srcdir, lang)
print print
# Write meta-rule to call all the other rules # Write meta-rule to call all the other rules
print 'TOCs:', ' '.join(tocs) print 'TOCs =', ' '.join(tocs)
print '\t@echo Made TOCs succesfully.'
if __name__ == "__main__": if __name__ == "__main__":

View File

@ -25,7 +25,7 @@
import sys import sys
import os import os
sys.path.insert(0,"../lyx2lyx") sys.path.insert(0, os.path.dirname(sys.argv[0]) + "/../lyx2lyx")
import parser_tools import parser_tools
import LyX import LyX
import depend import depend
@ -105,9 +105,11 @@ def main(argv):
if lang not in info: if lang not in info:
lang = 'en' lang = 'en'
srcdir = os.path.dirname(sys.argv[0])
# Determine existing translated documents for that language. # Determine existing translated documents for that language.
toc_general = [] toc_general = []
for file in depend.documents(pref): for file in depend.documents(srcdir, pref):
file = LyX.File(input= file) file = LyX.File(input= file)
file.convert() file.convert()
toc_general.extend(file.get_toc()) toc_general.extend(file.get_toc())

View File

@ -23257,8 +23257,6 @@ paragrafo
\begin_deeper \begin_deeper
\end_layout
\begin_deeper \begin_deeper
\begin_layout Standard \begin_layout Standard