Jose' Matos wrote:

>   Passing as destination dir as argument is enough to fix this, right?

No, it was a bit more.
The attached patch should fix bug 2027 and does the following:
- fix wrong syntax in de_Userguide and it_Userguide
- change the build system so that the TOC files are generated automatically
when doing a 'make dist'. They can also be generated by hand with 'make
TOCs'.
- include untranslated documents in TOC files
- make TOC file generation work with srcdir != builddir.

python is now required if building from CVS, because I included
Makefile.depend in Makefile.am. Python is not needed if building from the
tarball, because 'make dist' creates the TOC files and makes sure that
Makefile.depend is up to date.
If really needed I could also play with dist-hook and not require python for
CVS builds, but I'd like to avoid that.

If you want to try it out you should delete lib/doc/*TOC.lyx.

Comments?


Georg
Index: lib/doc/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/lib/doc/ChangeLog,v
retrieving revision 1.34
diff -u -p -r1.34 ChangeLog
--- lib/doc/ChangeLog	19 Sep 2005 09:52:49 -0000	1.34
+++ lib/doc/ChangeLog	21 Sep 2005 13:38:54 -0000
@@ -1,3 +1,13 @@
+2005-09-21  Georg Baum  <[EMAIL PROTECTED]>
+
+	* 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-19  Jürgen Spitzmüller  <[EMAIL PROTECTED]>
 
 	* UserGuide.lyx: document new space inset, correct some
Index: lib/doc/Makefile.am
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/lib/doc/Makefile.am,v
retrieving revision 1.6
diff -u -p -r1.6 Makefile.am
--- lib/doc/Makefile.am	17 Oct 2004 19:12:32 -0000	1.6
+++ lib/doc/Makefile.am	21 Sep 2005 13:45:10 -0000
@@ -1,31 +1,26 @@
 include $(top_srcdir)/config/common.am
 
-DISTCLEANFILES += LyXConfig.lyx LaTeXConfig.lyx Makefile.depend
+DISTCLEANFILES += LyXConfig.lyx LaTeXConfig.lyx $(DEPENDFILE) $(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 = \
-	cs_TOC.lyx \
+docfiles = $(TOCs) \
 	cs_Tutorial.lyx \
 	Customization.lyx \
 	da_Intro.lyx \
-	da_TOC.lyx \
 	de_Customization.lyx \
 	de_Extended.lyx \
 	de_FAQ.lyx \
 	de_Intro.lyx \
-	de_TOC.lyx \
 	de_Tutorial.lyx \
 	de_UserGuide.lyx \
 	DocStyle.lyx \
 	es_Intro.lyx \
-	es_TOC.lyx \
 	es_Tutorial.lyx \
 	eu_Customization.lyx \
 	eu_Extended.lyx \
 	eu_FAQ.lyx \
 	eu_Intro.lyx \
-	eu_TOC.lyx \
 	eu_Tutorial.lyx \
 	eu_UserGuide.lyx \
 	Extended.lyx \
@@ -34,50 +29,36 @@ docfiles = \
 	fr_Extended.lyx \
 	fr_FAQ.lyx \
 	fr_Intro.lyx \
-	fr_TOC.lyx \
 	fr_Tutorial.lyx \
 	fr_UserGuide.lyx \
 	he_Intro.lyx \
-	he_TOC.lyx \
 	he_Tutorial.lyx \
 	hu_Intro.lyx \
-	hu_TOC.lyx \
 	Intro.lyx \
 	it_Customization.lyx \
 	it_Intro.lyx \
-	it_TOC.lyx \
 	it_Tutorial.lyx \
 	it_UserGuide.lyx \
 	LaTeXConfig.lyx.in \
 	nl_Intro.lyx \
-	nl_TOC.lyx \
 	nl_Tutorial.lyx \
 	no_Intro.lyx \
-	no_TOC.lyx \
 	pl_Extended.lyx \
 	pl_Intro.lyx \
-	pl_TOC.lyx \
 	pl_Tutorial.lyx \
 	pt_Intro.lyx \
-	pt_TOC.lyx \
 	pt_Tutorial.lyx \
 	Reference.lyx \
 	ro_Intro.lyx \
-	ro_TOC.lyx \
 	ru_FAQ.lyx \
 	ru_Intro.lyx \
-	ru_TOC.lyx \
 	ru_Tutorial.lyx \
-	sk_TOC.lyx \
 	sk_Tutorial.lyx \
 	sk_UserGuide.lyx \
 	sl_Intro.lyx \
-	sl_TOC.lyx \
 	sl_Tutorial.lyx \
 	sv_Intro.lyx \
-	sv_TOC.lyx \
 	sv_Tutorial.lyx \
-	TOC.lyx \
 	Tutorial.lyx \
 	UserGuide.lyx \
 	escher-lsd.eps \
@@ -89,16 +70,17 @@ doc_DATA = \
 	$(docfiles) \
 	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
+include $(DEPENDFILE)
+
+TOCs : $(TOCs)
+	@echo Made TOCs succesfully.
 
-TOCs : depend
-	make -f $(DEPENDFILE) TOCs
+# Force regeneration of $(DEPENDFILE) when Makefile.am changes because
+# new doc files might have been added
+$(DEPENDFILE): Makefile.am
 
 depend:
-	python depend.py > $(DEPENDFILE)
+	python $(srcdir)/depend.py > $(DEPENDFILE)
 
 .PHONY: depend
Index: lib/doc/de_UserGuide.lyx
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/lib/doc/de_UserGuide.lyx,v
retrieving revision 1.4
diff -u -p -r1.4 de_UserGuide.lyx
--- lib/doc/de_UserGuide.lyx	18 Jul 2005 09:41:53 -0000	1.4
+++ lib/doc/de_UserGuide.lyx	21 Sep 2005 13:38:57 -0000
@@ -10653,8 +10653,6 @@ Umschalt+Alt\InsetSpace ~
 \end_layout
 
 \begin_deeper
-\end_layout
-
 \begin_deeper
 \begin_layout Standard
 
Index: lib/doc/depend.py
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/lib/doc/depend.py,v
retrieving revision 1.1
diff -u -p -r1.1 depend.py
--- lib/doc/depend.py	17 Oct 2004 19:12:32 -0000	1.1
+++ lib/doc/depend.py	21 Sep 2005 13:38:57 -0000
@@ -31,12 +31,14 @@ from glob import glob
 possible_documents = ("Intro", "FAQ", "Tutorial", "UserGuide", "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
 
 
@@ -50,8 +52,9 @@ def main(argv):
 
     # What are the languages available? And its documents?
     languages = {}
-    for file in glob('*'):
-        lang = lang_pattern.match(file)
+    srcdir = os.path.dirname(argv[0])
+    for file in glob(srcdir + '/*'):
+        lang = lang_pattern.match(os.path.basename(file))
         if lang:
             if lang.group(1) not in languages:
                 languages[lang.group(1)] = [file]
@@ -63,8 +66,8 @@ def main(argv):
     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:', ('.lyx ' + srcdir + '/').join(possible_documents) + '.lyx'
+    print '\tpython %s/doc_toc.py' % srcdir
     print
     tocs = ['TOC.lyx']
 
@@ -73,15 +76,17 @@ def main(argv):
         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)
+        if srcdir + '/' + toc_name in languages[lang]:
+            languages[lang].remove(srcdir + '/' + toc_name)
 
         print toc_name + ':', ' '.join(languages[lang])
-        print '\tpython doc_toc.py %s' % lang
+        print '\tpython %s/doc_toc.py %s' % (srcdir, lang)
         print
 
     # Write meta-rule to call all the other rules
-    print 'TOCs:', ' '.join(tocs)
-    print '[EMAIL PROTECTED] Made TOCs succesfully.'
+    print 'TOCs =', ' '.join(tocs)
 
 
 if __name__ == "__main__":
Index: lib/doc/doc_toc.py
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/lib/doc/doc_toc.py,v
retrieving revision 1.2
diff -u -p -r1.2 doc_toc.py
--- lib/doc/doc_toc.py	9 Jun 2005 09:58:02 -0000	1.2
+++ lib/doc/doc_toc.py	21 Sep 2005 13:38:57 -0000
@@ -25,7 +25,7 @@
 import sys
 import os
 
-sys.path.insert(0,"../lyx2lyx")
+sys.path.insert(0, os.path.dirname(sys.argv[0]) + "/../lyx2lyx")
 import parser_tools
 import LyX
 import depend
@@ -105,9 +105,11 @@ def main(argv):
         if lang not in info:
             lang = 'en'
 
+    srcdir = os.path.dirname(sys.argv[0])
+
     # Determine existing translated documents for that language.
     toc_general = []
-    for file in depend.documents(pref):
+    for file in depend.documents(srcdir, pref):
         file = LyX.File(input= file)
         file.convert()
         toc_general.extend(file.get_toc())
Index: lib/doc/it_UserGuide.lyx
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/lib/doc/it_UserGuide.lyx,v
retrieving revision 1.2
diff -u -p -r1.2 it_UserGuide.lyx
--- lib/doc/it_UserGuide.lyx	18 Jul 2005 09:42:08 -0000	1.2
+++ lib/doc/it_UserGuide.lyx	21 Sep 2005 13:38:59 -0000
@@ -23257,8 +23257,6 @@ paragrafo
 
 
 \begin_deeper
-\end_layout
-
 \begin_deeper
 \begin_layout Standard
 

Reply via email to