forked from jessevdk/cldoc
-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.py
164 lines (131 loc) · 3.65 KB
/
setup.py
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
#!/usr/bin/env python
from setuptools import setup, Command
import subprocess, os, shutil, glob, sys
coffee_files = [
'cldoc.coffee',
'page.coffee',
'sidebar.coffee',
'node.coffee',
'type.coffee',
'doc.coffee',
'category.coffee',
'enum.coffee',
'templated.coffee',
'struct.coffee',
'structtemplate.coffee',
'class.coffee',
'classtemplate.coffee',
'namespace.coffee',
'typedef.coffee',
'variable.coffee',
'function.coffee',
'functiontemplate.coffee',
'field.coffee',
'method.coffee',
'methodtemplate.coffee',
'constructor.coffee',
'destructor.coffee',
'base.coffee',
'implements.coffee',
'subclass.coffee',
'implementedby.coffee',
'templatetypeparameter.coffee',
'coverage.coffee',
'arguments.coffee',
'report.coffee',
'references.coffee',
'union.coffee',
'gobjectclass.coffee',
'gobjectinterface.coffee',
'gobjectboxed.coffee',
'gobjectproperty.coffee',
]
class cldoc_generate(Command):
description = "generate css, js and html files"
user_options = [
('coffee=', None, 'path to coffeescript compiler'),
('sass=', None, 'path to sass compiler'),
('inline=', None, 'path to inline')
]
def initialize_options(self):
self.coffee = 'coffee'
self.sass = 'sass'
self.inline = 'scripts/inline'
def finalize_options(self):
pass
def run_coffee(self):
print('running {0}'.format(self.coffee))
for d in ('html/javascript', 'cldoc/data/javascript'):
try:
os.makedirs(d)
except:
pass
args = [self.coffee, '--bare', '--stdio', '--compile']
try:
sp = subprocess.Popen(args, stdout=subprocess.PIPE, stdin=subprocess.PIPE)
except Exception as e:
sys.stderr.write("Failed to run coffee (please make sure it is installed)\n")
sys.exit(1)
for f in coffee_files:
with open(os.path.join('html', 'coffee', f)) as ff:
sp.stdin.write(ff.read())
sp.stdin.close()
with open('html/javascript/cldoc.js', 'w') as out:
out.write(sp.stdout.read())
sp.wait()
for js in glob.glob('html/javascript/*.js'):
shutil.copyfile(js, 'cldoc/data/javascript/' + os.path.basename(js))
def run_sass(self):
print('running {0}'.format(self.sass))
for d in ('html/styles', 'cldoc/data/styles'):
try:
os.makedirs(d)
except:
pass
args = [self.sass, '--output-style', 'compressed']
files = ['html/sass/cldoc.scss', 'html/styles/cldoc.css']
subprocess.call(args + files)
for css in glob.glob('html/styles/*.css'):
shutil.copyfile(css, 'cldoc/data/styles/' + os.path.basename(css))
def run_inline(self):
if self.inline == '':
shutil.copyfile('html/index.html', 'cldoc/data/index.html')
return
print('running {0}'.format(self.inline))
args = [self.inline, 'html/index.html']
try:
os.makedirs('cldoc/data')
except:
pass
fout = file('cldoc/data/index.html', 'w')
proc = subprocess.Popen(args, stdout=fout)
proc.wait()
def run(self):
self.run_coffee()
self.run_sass()
self.run_inline()
cmdclass = {
'generate': cldoc_generate
}
datafiles = []
dataprefix = 'cldoc'
for dirpath, dirnames, filenames in os.walk(os.path.join(dataprefix, 'data')):
datafiles += [os.path.join(dirpath[len(dataprefix)+1:], f) for f in filenames]
setup(name='cldoc',
version='1.11',
description='clang based documentation generator for C/C++',
author='Jesse van den Kieboom',
author_email='[email protected]',
url='http://jessevdk.github.com/cldoc',
license='GPLv2',
keywords=['clang', 'c++', 'documentation'],
packages=['cldoc', 'cldoc.clang', 'cldoc.nodes', 'cldoc.generators'],
entry_points = {
'console_scripts': [
'cldoc = cldoc:run'
]
},
package_data={'cldoc': datafiles},
cmdclass=cmdclass,
install_requires=['pyparsing == 2.2.0'])
# vi:ts=4:et