X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=lib%2Fdoc%2Fdepend.py;h=4a5b585f6687fd72855527adefc9231d5e61b896;hb=ea74988acc29767d2d34d9e4466e4993eb544171;hp=bddb36b8b6d3d87bfec741a8fcc9c7d6962c15db;hpb=673da6c01c86e68bebfc29e25c44667571458b72;p=lyx.git diff --git a/lib/doc/depend.py b/lib/doc/depend.py index bddb36b8b6..4a5b585f66 100644 --- a/lib/doc/depend.py +++ b/lib/doc/depend.py @@ -1,7 +1,7 @@ #! /usr/bin/env python -# -*- coding: iso-8859-1 -*- +# -*- coding: utf-8 -*- # This file is part of the LyX Documentation -# Copyright (C) 2004 José Matos +# Copyright (C) 2004 José Matos # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -21,6 +21,9 @@ # 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 @@ -29,29 +32,33 @@ import re possible_documents = ("Intro", "FAQ", "Tutorial", "UserGuide", "EmbeddedObjects", "Extended", "Customization") -def documents(srcdir, lang): +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(fname) + result.append(os.path.join(dir_prefix, lang, file + '.lyx')) else: - result.append(os.path.join(srcdir, file + '.lyx')) + result.append(os.path.join(dir_prefix, file + '.lyx')) return result -def all_documents(srcdir): +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) + languages[dir] = documents(srcdir, dir, dir_prefix) # general, English language if 'en' not in languages.keys(): - languages['en'] = documents(srcdir, 'en') + languages['en'] = documents(srcdir, 'en', dir_prefix) return languages @@ -64,7 +71,7 @@ def main(argv): """ % os.path.basename(argv[0]) # What are the languages available? And its documents? - languages = all_documents(os.path.dirname(argv[0])) + languages = all_documents(os.path.dirname(argv[0]), '') # sort languages alphabetically langs = languages.keys() @@ -74,7 +81,7 @@ def main(argv): # Write rules for other languages for lang in langs: - if os.path.isdir(lang): + if lang != 'en': toc_name = os.path.join(lang, 'TOC.lyx') else: # for English, because there is no 'en' directory