File: split_cmdref

package info (click to toggle)
getfem%2B%2B 5.3%2Bdfsg1-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 35,604 kB
  • sloc: cpp: 117,991; ansic: 73,600; fortran: 16,046; python: 7,403; sh: 3,624; perl: 1,722; makefile: 1,548
file content (91 lines) | stat: -rwxr-xr-x 3,005 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/usr/bin/python3
# -*- python -*-
#
# Copyright (C) 2004-2017 Yves Renard.
#                                                       
# This file is a part of GetFEM++                                         
#                                                                         
# GetFEM++  is  free software;  you  can  redistribute  it  and/or modify it
# under  the  terms  of the  GNU  Lesser General Public License as published
# by  the  Free Software Foundation;  either version 3 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 Lesser General Public
# License for more details.
# You  should  have received a copy of the GNU Lesser General Public License
# along  with  this program;  if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA.
#
############################################################################
"""  Autofunc and autodoc for Python, Matlab and Scilab interfaces.

  This program is used to the command ref documentation produced by the
  script extract_doc.

  $Id: extract_doc 3304 2009-11-03 13:17:46Z renard $
"""
import re
import string
import os
import textwrap
import sys

class ParseError(Exception):
    def __init__(self, value):
      self.value = value
    def __str__(self):
      return repr(self.value)



if (len(sys.argv) != 2):
    raise SystemExit, 'Format : split_cmdref directory'

directory = sys.argv[1]

os.system('rm -f ' + directory + '/cmdref_*.rst')

fl = open(directory + '/cmdref.rst')
flw = open(directory + '/cmdref_new.rst', 'w')
flcom = 0;
state = 0 # 0 = preambule, 1 = read a command
old_l = '';
for l in fl:
    if (l[0:21] == "---------------------"):
        command_name = old_l.strip();
        if (state == 0):
            flw.write('\n');
            flw.write('.. toctree::\n');
            flw.write('   :maxdepth: 3\n\n');
        flw.write('   cmdref_' + command_name + '\n');    
        state = 1
        if (flcom):
            flcom.close()
        flcom = open(directory + '/cmdref_' + command_name + '.rst', 'w')
        flcom.write('.. Automatically generated file, do not edit it.\n')
        flcom.write('.. If some modification are necessary, please modify\n')
        flcom.write('.. the corresponding C++ source or the python program extract_doc.\n\n')
        flcom.write('.. include:: ../replaces.txt\n\n')        
        flcom.write(command_name+'\n')
    else:
        if (state == 0):
            flw.write(old_l)
        else:
            flcom.write(old_l)
    old_l = l

 
if (state == 0):
    flw.write(l)
else:
    flcom.write(l)


flw.close()
if (flcom):
    flcom.close()

os.system('mv -f '+directory+'/cmdref.rst '+directory+'/cmdref.rst.org')
os.system('mv -f '+directory+'/cmdref_new.rst '+directory+'/cmdref.rst')