]> git.lyx.org Git - features.git/blob - development/tools/updatedocs.py
updatedocs.py now updates templates and examples
[features.git] / development / tools / updatedocs.py
1 #! /usr/bin/env python
2 # -*- coding: utf-8 -*-
3
4 # file updatedocs.py
5 # This file is part of LyX, the document processor.
6 # Licence details can be found in the file COPYING.
7
8 # author Georg Baum
9
10 # Full author contact details are available in file CREDITS
11
12 # This script converts documentation .lyx files to current format
13 # The old files are backuped with extension ".old"
14
15
16 import os, re, string, sys, subprocess, shutil
17
18
19 def convertdir(docdir, prefix, lyx2lyx, systemlyxdir):
20     olddir = os.getcwd()
21     os.chdir(docdir)
22     for i in os.listdir("."):
23         if os.path.isdir(i):
24             if i != 'attic':
25                 subdir = os.path.join(docdir, i)
26                 subprefix = os.path.join(prefix, i)
27                 convertdir(subdir, subprefix, lyx2lyx, systemlyxdir)
28             continue
29         (base, ext) = os.path.splitext(i)
30         if ext != ".lyx":
31             continue
32         old = i + ".old"
33         shutil.copy(i, old)
34         if sys.executable and sys.executable != '':
35             cmd = [sys.executable, lyx2lyx, old, '-s', systemlyxdir, '-o', i]
36         else:
37             # assume that python is in the path
38             cmd = [lyx2lyx, old, '-s', systemlyxdir, '-o', i]
39         sys.stderr.write('Converting %s\n' % os.path.join(prefix, i))
40         subprocess.call(cmd)
41     os.chdir(olddir)
42
43
44 def main(argv):
45
46     toolsdir = os.path.dirname(argv[0])
47     lyx2lyx = os.path.abspath(os.path.join(toolsdir, "../../lib/lyx2lyx/lyx2lyx"))
48     systemlyxdir = os.path.abspath(os.path.join(toolsdir, "../../lib"))
49     docpaths = ['../../lib/doc', '../../lib/examples', '../../lib/templates', '../../development/MacOSX/ReadMe']
50     for docpath in docpaths:
51         docdir = os.path.abspath(os.path.join(toolsdir, docpath))
52         convertdir(docdir, '', lyx2lyx, systemlyxdir)
53
54     return 0
55
56
57 if __name__ == "__main__":
58     main(sys.argv)