-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate_doc.py
executable file
·48 lines (38 loc) · 1.36 KB
/
generate_doc.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
#!/usr/bin/env python
'''
script for generating documentation automatically
using rosdoc_lite, given a collection of ros packages
USAGE: ./generate_doc.py <path_to_root_of_pkgs> <output dir>
Author: Chris Zalidis
'''
import os
import sys
import commands
import argparse
from publish_doc import publish_doc
parser = argparse.ArgumentParser(description='Generate documentation')
parser.add_argument('root_of_pkgs', help='The root directory of packages')
parser.add_argument('output_dir', help='The directory to put html files')
args = parser.parse_args()
rosdoc = 'rosdoc_lite '
package_dirs = {}
for root, dirs, files in os.walk(args.root_of_pkgs):
if 'package.xml' in files:
package_dirs[os.path.basename(root)] = root
if not os.path.isdir(args.output_dir):
os.mkdir(args.output_dir)
for package in package_dirs:
out_path = os.path.join(args.output_dir, package)
cmd = rosdoc + '-o ' + out_path + ' '+ package_dirs[package]
print '+', cmd
(status, output) = commands.getstatusoutput(cmd)
if status:
sys.stderr.write(output)
sys.exit(1)
print output
# make index-msg.html default page for packages containing msgs
if 'communications' in package or 'msgs' in package:
file = open(os.path.join(out_path,'html/.htaccess'), 'w')
file.write('DirectoryIndex index-msg.html\n')
file.close()
publish_doc(package_dirs.keys(), args.output_dir)