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

Unified Diff: tools/telemetry/build/update_docs.py

Issue 17150002: [telemetry] Initial (autogenerated) documentation plus support scripts (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: update with nits Created 7 years, 6 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 | « tools/telemetry/build/__init__.py ('k') | tools/telemetry/docs/telemetry.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/telemetry/build/update_docs.py
diff --git a/tools/telemetry/build/update_docs.py b/tools/telemetry/build/update_docs.py
new file mode 100644
index 0000000000000000000000000000000000000000..49bfee28268b4a887faa06748d68b488c968869d
--- /dev/null
+++ b/tools/telemetry/build/update_docs.py
@@ -0,0 +1,64 @@
+# Copyright (c) 2013 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 logging
+import optparse
+import os
+import pkgutil
+import pydoc
+import sys
+
+from telemetry.core import util
+
+def RemoveAllDocs(docs_dir):
+ for dirname, _, filenames in os.walk(docs_dir):
+ for filename in filenames:
+ os.remove(os.path.join(dirname, filename))
+
+def WriteDocsFor(module):
+ pydoc.writedoc(module)
+ for _, modname, _ in pkgutil.walk_packages(
+ module.__path__, module.__name__ + '.'):
+ if modname.endswith('_unittest'):
+ logging.info("skipping %s due to being a unittest", modname)
+ continue
+
+ module = __import__(modname, fromlist=[""])
+ name, _ = os.path.splitext(module.__file__)
+ if not os.path.exists(name + '.py'):
+ logging.info("skipping %s due to being an orphan .pyc", module.__file__)
+ continue
+
+ pydoc.writedoc(module)
+
+def Main(args):
+ parser = optparse.OptionParser()
+ parser.add_option(
+ '-v', '--verbose', action='count', default=0,
+ help='Increase verbosity level (repeat as needed)')
+ options, args = parser.parse_args(args)
+ if options.verbose >= 2:
+ logging.basicConfig(level=logging.DEBUG)
+ elif options.verbose:
+ logging.basicConfig(level=logging.INFO)
+ else:
+ logging.basicConfig(level=logging.WARNING)
+
+
+ telemetry_dir = util.GetTelemetryDir()
+ docs_dir = os.path.join(telemetry_dir, 'docs')
+
+ assert os.path.isdir(docs_dir)
+
+ RemoveAllDocs(docs_dir)
+
+ if telemetry_dir not in sys.path:
+ sys.path.append(telemetry_dir)
+ import telemetry
+
+ old_cwd = os.getcwd()
+ try:
+ os.chdir(docs_dir)
+ WriteDocsFor(telemetry)
+ finally:
+ os.chdir(old_cwd)
« no previous file with comments | « tools/telemetry/build/__init__.py ('k') | tools/telemetry/docs/telemetry.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698