Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: chrome/test/pyautolib/generate_docs.py

Issue 7745039: Script to generate pyauto documentation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/python
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 import optparse
7 import os
8 import pydoc
9 import shutil
10 import sys
11
Nirnimesh 2011/08/26 00:50:17 2 lines at global scope please
12 def main():
13 parser = optparse.OptionParser()
14 parser.add_option('-w', '--write', dest='dir', metavar='FILE',
15 default=os.path.join(os.getcwd(), 'pyauto_docs'),
16 help='Directory path to write all of the documentation')
Nirnimesh 2011/08/26 00:50:17 Add: Defaults to "pyauto_docs" in current director
17 parser.add_option('-p', '--pyauto', dest='pyauto', metavar='FILE',
Nirnimesh 2011/08/26 00:50:17 recommend renaming pyauto to pyautolib
18 default=os.getcwd(),
19 help='Location of pyautolib directory')
20 (options, args) = parser.parse_args()
21
22 if not os.path.isdir(options.dir):
23 os.makedirs(options.dir)
24
25 # Add these paths so pydoc can find everything
26 sys.path.append(os.path.join(options.pyauto,
27 '../../../third_party/'))
28 sys.path.append(options.pyauto)
29
30 # Get a snapshot of the current directory where pydoc will export the files
31 previous_contents = set(os.listdir(os.getcwd()))
32 pydoc.writedocs(options.pyauto)
33 current_contents = set(os.listdir(os.getcwd()))
34
35 if options.dir == os.getcwd():
36 print('Export complete, files are located in %s' % options.dir)
37 return
38
39 new_files = current_contents.difference(previous_contents)
40 for file_name in new_files:
41 basename, extension = os.path.splitext(file_name)
42 if extension == '.html':
43 # Build the complete path
44 full_path = os.path.join(os.getcwd(), file_name)
45 existing_file_path = os.path.join(options.dir, file_name)
46 if os.path.isfile(existing_file_path):
47 os.remove(existing_file_path)
48 shutil.move(full_path, options.dir)
49
50 print('Export complete, files are located in %s' % options.dir)
Nirnimesh 2011/08/26 00:50:17 Remove the parens in all print statements
51
Nirnimesh 2011/08/26 00:50:17 need 2 lines here
52 if __name__ == '__main__':
53 main()
54
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698