~njansson/dolfin/hpc

« back to all changes in this revision

Viewing changes to src/pydolfin/generate.py

  • Committer: Johannes Ring
  • Date: 2008-03-05 22:43:06 UTC
  • Revision ID: johannr@simula.no-20080305224306-2npsdyhfdpl2esji
The BIG commit!

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/env python
2
 
#
3
 
# Generate list of include files for SWIG interface file.
4
 
 
5
 
__author__ = "Anders Logg (logg@simula.no)"
6
 
__date__ = "2007-04-12 -- 2007-05-02"
7
 
__copyright__ = "Copyright (C) 2007 Anders Logg"
8
 
__license__  = "GNU LGPL Version 2.1"
9
 
 
10
 
import os
11
 
import re
12
 
 
13
 
# List of headers to exclude (add more here)
14
 
excludes = ["plot.h", "ParameterSystem.h", "ParameterList.h", \
15
 
            "ConvectionMatrix.h", "MassMatrix.h", "StiffnessMatrix.h", "LoadVector.h"]
16
 
 
17
 
# Name of SWIG interface file to be generated
18
 
interface_file = "dolfin_headers.h"
19
 
 
20
 
# Extract modules from dolfin.h
21
 
modules = []
22
 
f = open("../kernel/main/dolfin.h")
23
 
for line in f:
24
 
    if "#include <dolfin/" in line and line[:17] == "#include <dolfin/":
25
 
        module = line.split("/")[1].split(".")[0].split("_")[1]
26
 
        modules += [module]
27
 
f.close()
28
 
 
29
 
# Extract header files
30
 
headers = []
31
 
docstring_headers = [] # Added for docstring extraction
32
 
for module in modules:
33
 
    module_headers = []
34
 
    print "Processing dolfin_%s.h..." % module
35
 
    f = open("../kernel/%s/dolfin/dolfin_%s.h" % (module, module))
36
 
    module_base = "../kernel/" + module + "/"  # Added for docstring extraction
37
 
    for line in f:
38
 
        if re.search("^#include ",line):
39
 
            header = line.split()[1].replace("<", "").replace(">", "")
40
 
            if not header.split("/")[1] in excludes:
41
 
                module_headers += [header]
42
 
                docstring_headers += [module_base + header]  # Added for docstring extraction
43
 
    f.close()
44
 
    headers += [(module, module_headers)]
45
 
 
46
 
# Generate list of header files
47
 
print "Generating file %s" % interface_file
48
 
f = open(interface_file, "w")
49
 
f.write("// Generated file to include docstrings\n")  # Added for docstring extraction
50
 
f.write("%include \"dolfin_docstrings.i\"\n\n")  # Added for docstring extraction
51
 
 
52
 
f.write("// Generated list of include files for PyDOLFIN\n")
53
 
for (module, module_headers) in headers:
54
 
    f.write("\n// DOLFIN headers included from %s\n" % module)
55
 
    for header in module_headers:
56
 
        f.write("%%include \"%s\"\n" % header)
57
 
f.close()
58
 
 
59
 
# Added for docstring extraction
60
 
from generate_docstrings import DocstringGenerator
61
 
 
62
 
g = DocstringGenerator(header_files = docstring_headers, swig_directory = ".", docstring_file_base = "dolfin")
63
 
g.generate_doxygen_documentation()
64
 
g.generate_interface_file_from_index()
65
 
g.clean()