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

Unified 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, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/pyautolib/generate_docs.py
===================================================================
--- chrome/test/pyautolib/generate_docs.py (revision 0)
+++ chrome/test/pyautolib/generate_docs.py (revision 0)
@@ -0,0 +1,54 @@
+#!/usr/bin/python
+# Copyright (c) 2011 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import optparse
+import os
+import pydoc
+import shutil
+import sys
+
Nirnimesh 2011/08/26 00:50:17 2 lines at global scope please
+def main():
+ parser = optparse.OptionParser()
+ parser.add_option('-w', '--write', dest='dir', metavar='FILE',
+ default=os.path.join(os.getcwd(), 'pyauto_docs'),
+ help='Directory path to write all of the documentation')
Nirnimesh 2011/08/26 00:50:17 Add: Defaults to "pyauto_docs" in current director
+ parser.add_option('-p', '--pyauto', dest='pyauto', metavar='FILE',
Nirnimesh 2011/08/26 00:50:17 recommend renaming pyauto to pyautolib
+ default=os.getcwd(),
+ help='Location of pyautolib directory')
+ (options, args) = parser.parse_args()
+
+ if not os.path.isdir(options.dir):
+ os.makedirs(options.dir)
+
+ # Add these paths so pydoc can find everything
+ sys.path.append(os.path.join(options.pyauto,
+ '../../../third_party/'))
+ sys.path.append(options.pyauto)
+
+ # Get a snapshot of the current directory where pydoc will export the files
+ previous_contents = set(os.listdir(os.getcwd()))
+ pydoc.writedocs(options.pyauto)
+ current_contents = set(os.listdir(os.getcwd()))
+
+ if options.dir == os.getcwd():
+ print('Export complete, files are located in %s' % options.dir)
+ return
+
+ new_files = current_contents.difference(previous_contents)
+ for file_name in new_files:
+ basename, extension = os.path.splitext(file_name)
+ if extension == '.html':
+ # Build the complete path
+ full_path = os.path.join(os.getcwd(), file_name)
+ existing_file_path = os.path.join(options.dir, file_name)
+ if os.path.isfile(existing_file_path):
+ os.remove(existing_file_path)
+ shutil.move(full_path, options.dir)
+
+ print('Export complete, files are located in %s' % options.dir)
Nirnimesh 2011/08/26 00:50:17 Remove the parens in all print statements
+
Nirnimesh 2011/08/26 00:50:17 need 2 lines here
+if __name__ == '__main__':
+ main()
+
« 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