mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 01:59:02 +00:00
get rid of the makefile machinery that was used to build TOCs
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@27084 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
754ead5010
commit
4789edde52
@ -68,9 +68,6 @@ else
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Building lib/doc/Makefile.depend..."
|
|
||||||
python lib/doc/depend.py > lib/doc/Makefile.depend
|
|
||||||
|
|
||||||
echo "Building Makefile templates..."
|
echo "Building Makefile templates..."
|
||||||
if ( $AUTOMAKE --version ) < /dev/null > /dev/null 2>&1; then
|
if ( $AUTOMAKE --version ) < /dev/null > /dev/null 2>&1; then
|
||||||
$AUTOMAKE
|
$AUTOMAKE
|
||||||
|
@ -2075,10 +2075,7 @@ lib_doc_clipart_files = Split('''
|
|||||||
|
|
||||||
lib_doc_extra_files = Split('''
|
lib_doc_extra_files = Split('''
|
||||||
Makefile.am
|
Makefile.am
|
||||||
Makefile.depend
|
|
||||||
README.Documentation
|
README.Documentation
|
||||||
depend.py
|
|
||||||
doc_toc.py
|
|
||||||
''')
|
''')
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
include $(top_srcdir)/config/common.am
|
include $(top_srcdir)/config/common.am
|
||||||
|
|
||||||
DISTCLEANFILES += $(tocfiles)
|
EXTRA_DIST = README.Documentation
|
||||||
|
|
||||||
EXTRA_DIST = depend.py doc_toc.py README.Documentation $(DEPENDFILE)
|
|
||||||
|
|
||||||
docdir = $(pkgdatadir)/doc
|
docdir = $(pkgdatadir)/doc
|
||||||
dist_doc_DATA = \
|
dist_doc_DATA = \
|
||||||
@ -282,37 +280,7 @@ doc_files = \
|
|||||||
$(dist_svdoc_DATA) \
|
$(dist_svdoc_DATA) \
|
||||||
$(dist_ukdoc_DATA)
|
$(dist_ukdoc_DATA)
|
||||||
|
|
||||||
DEPENDFILE = $(srcdir)/Makefile.depend
|
install-data-hook:
|
||||||
# include $(DEPENDFILE) does not work because automake is too limited.
|
|
||||||
include $(srcdir)/Makefile.depend
|
|
||||||
|
|
||||||
TOCs : $(DEPENDFILE) $(tocfiles)
|
|
||||||
@echo Made TOCs succesfully.
|
|
||||||
|
|
||||||
# Force regeneration of $(DEPENDFILE) when Makefile.am changes because
|
|
||||||
# new doc files might have been added
|
|
||||||
$(DEPENDFILE): $(srcdir)/Makefile.am $(srcdir)/depend.py
|
|
||||||
python $(srcdir)/depend.py > $(DEPENDFILE)
|
|
||||||
|
|
||||||
# The TOCs are not built for the install and dist targets if they don't exist
|
|
||||||
# for some weird reason.
|
|
||||||
# Make complains although we have rules for them in $(DEPENDFILE), so we
|
|
||||||
# must not include the TOCs in $(docfiles) and have to use the install and
|
|
||||||
# dist hooks below.
|
|
||||||
dist-hook: $(tocfiles)
|
|
||||||
for i in $(tocfiles); \
|
|
||||||
do \
|
|
||||||
if test -f "$(srcdir)/$$i"; then file="$(srcdir)/$$i"; \
|
|
||||||
else file="$$i"; fi; \
|
|
||||||
cp -p "$$file" "$(distdir)"; \
|
|
||||||
done
|
|
||||||
install-data-hook: $(tocfiles)
|
|
||||||
for i in $(tocfiles); \
|
|
||||||
do \
|
|
||||||
if test -f "$(srcdir)/$$i"; then file="$(srcdir)/$$i"; \
|
|
||||||
else file="$$i"; fi; \
|
|
||||||
$(INSTALL_DATA) "$$file" "$(DESTDIR)$(docdir)/$$i"; \
|
|
||||||
done
|
|
||||||
for i in $(doc_files); \
|
for i in $(doc_files); \
|
||||||
do \
|
do \
|
||||||
if $(EGREP) -q "LYX_DIR_VER|LYX_USERDIR_VER" "$(DESTDIR)$(docdir)/$$i"; then \
|
if $(EGREP) -q "LYX_DIR_VER|LYX_USERDIR_VER" "$(DESTDIR)$(docdir)/$$i"; then \
|
||||||
@ -323,11 +291,3 @@ install-data-hook: $(tocfiles)
|
|||||||
chmod 644 "$(DESTDIR)$(docdir)/$$i"; \
|
chmod 644 "$(DESTDIR)$(docdir)/$$i"; \
|
||||||
fi; \
|
fi; \
|
||||||
done
|
done
|
||||||
|
|
||||||
uninstall-local:
|
|
||||||
for i in $(tocfiles); \
|
|
||||||
do \
|
|
||||||
$(RM) "$(DESTDIR)$(docdir)/$$i" ; \
|
|
||||||
done
|
|
||||||
|
|
||||||
.PHONY: TOCs
|
|
||||||
|
@ -1,104 +0,0 @@
|
|||||||
#! /usr/bin/env python
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
# This file is part of the LyX Documentation
|
|
||||||
# Copyright (C) 2004 José Matos <jamatos@lyx.org>
|
|
||||||
#
|
|
||||||
# This program is free software; you can redistribute it and/or
|
|
||||||
# modify it under the terms of the GNU General Public License
|
|
||||||
# as published by the Free Software Foundation; either version 2
|
|
||||||
# of the License, or (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with this program; if not, write to the Free Software
|
|
||||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
|
|
||||||
# This script creates a "master table of contents" for a set of LyX docs.
|
|
||||||
# It does so by going through the files and printing out all of the
|
|
||||||
# chapter, section, and sub(sub)section headings out. (It numbers the
|
|
||||||
# sections sequentially; hopefully noone's using Section* in the docs.)
|
|
||||||
# It calls the script doc_toc.py using this syntax:
|
|
||||||
# depend.py doc_toc.py SetOfDocuments
|
|
||||||
# where SetOfDocuments is a set of documents
|
|
||||||
|
|
||||||
import sys
|
|
||||||
import os
|
|
||||||
|
|
||||||
import re
|
|
||||||
|
|
||||||
possible_documents = ("Intro", "Tutorial", "UserGuide", "EmbeddedObjects", "Extended", "Math", "Customization")
|
|
||||||
|
|
||||||
def documents(srcdir, lang, dir_prefix = None):
|
|
||||||
'''Return documents for specified language. Translated files are in lang
|
|
||||||
directory.
|
|
||||||
'''
|
|
||||||
result = []
|
|
||||||
if dir_prefix is None:
|
|
||||||
dir_prefix = srcdir
|
|
||||||
for file in possible_documents:
|
|
||||||
fname = os.path.join(srcdir, lang, file + '.lyx')
|
|
||||||
if os.access(fname, os.F_OK):
|
|
||||||
result.append(os.path.join(dir_prefix, lang, file + '.lyx'))
|
|
||||||
else:
|
|
||||||
result.append(os.path.join(dir_prefix, file + '.lyx'))
|
|
||||||
return result
|
|
||||||
|
|
||||||
|
|
||||||
def all_documents(srcdir, dir_prefix = None):
|
|
||||||
'''Return available languages and its documents'''
|
|
||||||
languages = {}
|
|
||||||
if dir_prefix is None:
|
|
||||||
dir_prefix = srcdir
|
|
||||||
for dir in os.listdir(srcdir):
|
|
||||||
if os.path.isdir(os.path.join(srcdir, dir)) and len(dir) == 2:
|
|
||||||
languages[dir] = documents(srcdir, dir, dir_prefix)
|
|
||||||
# general, English language
|
|
||||||
if 'en' not in languages.keys():
|
|
||||||
languages['en'] = documents(srcdir, 'en', dir_prefix)
|
|
||||||
return languages
|
|
||||||
|
|
||||||
|
|
||||||
def main(argv):
|
|
||||||
print """# This is a Makefile for the TOC.lyx files.
|
|
||||||
# It was automatically generated by %s
|
|
||||||
#
|
|
||||||
# First come the rules for each xx/TOC.lyx file. Then comes the
|
|
||||||
# TOCs target, which prints all the TOC files.
|
|
||||||
""" % os.path.basename(argv[0])
|
|
||||||
|
|
||||||
# What are the languages available? And its documents?
|
|
||||||
languages = all_documents(os.path.dirname(argv[0]), '')
|
|
||||||
|
|
||||||
# sort languages alphabetically
|
|
||||||
langs = languages.keys()
|
|
||||||
langs.sort()
|
|
||||||
|
|
||||||
tocs = []
|
|
||||||
|
|
||||||
# Write rules for other languages
|
|
||||||
for lang in langs:
|
|
||||||
if lang != 'en':
|
|
||||||
toc_name = os.path.join(lang, 'TOC.lyx')
|
|
||||||
else:
|
|
||||||
# for English, because there is no 'en' directory
|
|
||||||
toc_name = 'TOC.lyx'
|
|
||||||
tocs.append(toc_name)
|
|
||||||
|
|
||||||
if toc_name in languages[lang]:
|
|
||||||
languages[lang].remove(toc_name)
|
|
||||||
languages[lang].sort()
|
|
||||||
|
|
||||||
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 'tocfiles =', ' '.join(tocs)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main(sys.argv)
|
|
@ -1,154 +0,0 @@
|
|||||||
#! /usr/bin/env python
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
# This file is part of the LyX Documentation
|
|
||||||
# Copyright (C) 2004 José Matos <jamatos@lyx.org>
|
|
||||||
#
|
|
||||||
# This program is free software; you can redistribute it and/or
|
|
||||||
# modify it under the terms of the GNU General Public License
|
|
||||||
# as published by the Free Software Foundation; either version 2
|
|
||||||
# of the License, or (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with this program; if not, write to the Free Software
|
|
||||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
|
|
||||||
# This script is called by the script depend.py to create a "master table of contents"
|
|
||||||
# for a set of LyX docs.
|
|
||||||
# It does so by going through the files and printing out all of the
|
|
||||||
# chapter, section, and sub(sub)section headings out. (It numbers the
|
|
||||||
# sections sequentially; hopefully noone's using Section* in the docs.)
|
|
||||||
# It is called using this syntax:
|
|
||||||
# depend.py doc_toc.py SetOfDocuments
|
|
||||||
# where SetOfDocuments is a set of documents
|
|
||||||
|
|
||||||
import sys
|
|
||||||
import os
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
srcdir = os.path.dirname(sys.argv[0])
|
|
||||||
if srcdir == '':
|
|
||||||
srcdir = '.'
|
|
||||||
sys.path.insert(0, srcdir + "/../lyx2lyx")
|
|
||||||
|
|
||||||
# when doc_toc is imported by scons, sys.path is set over there
|
|
||||||
import parser_tools
|
|
||||||
import LyX
|
|
||||||
import depend
|
|
||||||
|
|
||||||
# Specific language information
|
|
||||||
# info["isoname"] = (language, language_quotes, TOC_translated)
|
|
||||||
info = { 'cs' : ('czech', 'german', u"Obsah dokumentace LyXu"),
|
|
||||||
'da' : ('danish', 'german', u"Indholdsfortegnelse over LyX's dokumentation"),
|
|
||||||
'de' : ('german', 'german', u"Inhaltsverzeichnis LyX Dokumentation"),
|
|
||||||
'es' : ('spanish', 'spanish', u"Índice general LyX documentation"),
|
|
||||||
'fr' : ('french', 'french', u"Plan de la documentation LyX"),
|
|
||||||
'ja' : ('japanese', 'japanese', u"LyX取扱説明書目次"),
|
|
||||||
'ru' : ('russian', 'english', u"LyX Documentation Table of Contents"),
|
|
||||||
'sl' : ('slovene', 'german', u"Kazalo dokumentacije LyXa"),
|
|
||||||
'en' : ('english', 'english', u"LyX Documentation Table of Contents")}
|
|
||||||
|
|
||||||
def usage(pname):
|
|
||||||
print """Usage: %s lang output
|
|
||||||
|
|
||||||
lang is the language to build the TOC file,
|
|
||||||
""" % pname
|
|
||||||
|
|
||||||
|
|
||||||
transform_table = {'Title' : 'Section*', 'Chapter': 'Enumerate',
|
|
||||||
'Section':'Enumerate', 'Subsection': 'Enumerate',
|
|
||||||
'Subsubsection' : 'Enumerate'}
|
|
||||||
|
|
||||||
def build_from_toc(par_list):
|
|
||||||
if not par_list:
|
|
||||||
return []
|
|
||||||
|
|
||||||
if par_list[0].name == 'Title':
|
|
||||||
par = par_list[0]
|
|
||||||
par.name = transform_table[par.name]
|
|
||||||
|
|
||||||
if len(par_list) == 1:
|
|
||||||
return par_list
|
|
||||||
|
|
||||||
for i in range(1, len(par_list)):
|
|
||||||
if par_list[i].name == 'Title':
|
|
||||||
return [par] + \
|
|
||||||
build_from_toc(par_list[1:i]) + \
|
|
||||||
build_from_toc(par_list[i:])
|
|
||||||
|
|
||||||
return [par] + build_from_toc(par_list[1:])
|
|
||||||
|
|
||||||
if par_list[0].name in ('Chapter', 'Section', 'Subsection', 'Subsubsection'):
|
|
||||||
return nest_struct(par_list[0].name, par_list)
|
|
||||||
|
|
||||||
|
|
||||||
def nest_struct(name, par_list):
|
|
||||||
if par_list[0].name == name:
|
|
||||||
par = par_list[0]
|
|
||||||
par.name = transform_table[par.name]
|
|
||||||
|
|
||||||
if len(par_list) == 1:
|
|
||||||
return par_list
|
|
||||||
|
|
||||||
for i in range(1, len(par_list)):
|
|
||||||
if par_list[i].name == name:
|
|
||||||
par.child = build_from_toc(par_list[1:i])
|
|
||||||
return [par] + build_from_toc(par_list[i:])
|
|
||||||
par.child = build_from_toc(par_list[1:])
|
|
||||||
return [ par ]
|
|
||||||
|
|
||||||
|
|
||||||
def build_toc(output, documents, lang=None):
|
|
||||||
# Determine existing translated documents for that language.
|
|
||||||
toc_general = []
|
|
||||||
for file in documents:
|
|
||||||
file = LyX.File(input= file)
|
|
||||||
file.convert()
|
|
||||||
toc_general.extend(file.get_toc())
|
|
||||||
|
|
||||||
# if lang is not given, guess from document names. (Used in scons build)
|
|
||||||
if lang is None:
|
|
||||||
lang = 'en'
|
|
||||||
for file in documents:
|
|
||||||
dir = file.split(os.sep)[-2]
|
|
||||||
if dir in info.keys():
|
|
||||||
lang = dir
|
|
||||||
file = LyX.NewFile(output = output)
|
|
||||||
data = info[lang]
|
|
||||||
file.set_header(language = data[0], language_quotes = data[1], inputencoding = "auto")
|
|
||||||
file.language = data[0]
|
|
||||||
file.encoding = "utf-8"
|
|
||||||
body = [ LyX.Paragraph('Title', [data[2]])]
|
|
||||||
body.extend(build_from_toc(toc_general))
|
|
||||||
file.set_body(body)
|
|
||||||
file.write()
|
|
||||||
|
|
||||||
|
|
||||||
def main(argv):
|
|
||||||
if len(argv) != 3:
|
|
||||||
usage(argv[0])
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
lang = argv[1]
|
|
||||||
if not os.path.isdir(os.path.join(argv[2], lang)):
|
|
||||||
# need to create lang dir if build dir != src dir
|
|
||||||
os.mkdir(os.path.join(argv[2], lang))
|
|
||||||
|
|
||||||
# choose language files
|
|
||||||
if lang == 'en':
|
|
||||||
output = os.path.join(argv[2], 'TOC.lyx')
|
|
||||||
else:
|
|
||||||
output = os.path.join(argv[2], lang, 'TOC.lyx')
|
|
||||||
# fallback
|
|
||||||
if lang not in info:
|
|
||||||
lang = 'en'
|
|
||||||
|
|
||||||
build_toc(output, depend.documents(srcdir, lang), lang)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main(sys.argv)
|
|
Loading…
Reference in New Issue
Block a user