mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-23 10:18:50 +00:00
89 lines
2.8 KiB
Python
89 lines
2.8 KiB
Python
|
#! /usr/bin/env python
|
|||
|
# -*- coding: iso-8859-1 -*-
|
|||
|
# This file is part of the LyX Documentation
|
|||
|
# Copyright (C) 2004 Jos<6F> 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.)
|
|||
|
|
|||
|
import sys
|
|||
|
import os
|
|||
|
|
|||
|
import re
|
|||
|
from glob import glob
|
|||
|
|
|||
|
possible_documents = ("Intro", "FAQ", "Tutorial", "UserGuide", "Extended", "Customization")
|
|||
|
lang_pattern = re.compile('^([a-z]{2})_')
|
|||
|
|
|||
|
def documents(prefix):
|
|||
|
result = []
|
|||
|
for file in possible_documents:
|
|||
|
fname = prefix + file + '.lyx'
|
|||
|
if os.access(fname, os.F_OK):
|
|||
|
result.append(fname)
|
|||
|
return result
|
|||
|
|
|||
|
|
|||
|
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.
|
|||
|
""" % argv[0]
|
|||
|
|
|||
|
# What are the languages available? And its documents?
|
|||
|
languages = {}
|
|||
|
for file in glob('*'):
|
|||
|
lang = lang_pattern.match(file)
|
|||
|
if lang:
|
|||
|
if lang.group(1) not in languages:
|
|||
|
languages[lang.group(1)] = [file]
|
|||
|
else:
|
|||
|
languages[lang.group(1)].append(file)
|
|||
|
|
|||
|
# sort languages alphabetically
|
|||
|
langs = languages.keys()
|
|||
|
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
|
|||
|
tocs = ['TOC.lyx']
|
|||
|
|
|||
|
# Write rules for other languages
|
|||
|
for lang in langs:
|
|||
|
toc_name = lang + '_TOC.lyx'
|
|||
|
tocs.append(toc_name)
|
|||
|
|
|||
|
languages[lang].remove(toc_name)
|
|||
|
|
|||
|
print toc_name + ':', ' '.join(languages[lang])
|
|||
|
print '\tpython 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.'
|
|||
|
|
|||
|
|
|||
|
if __name__ == "__main__":
|
|||
|
main(sys.argv)
|