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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tools/telemetry/build/__init__.py ('k') | tools/telemetry/docs/telemetry.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4 import logging
5 import optparse
6 import os
7 import pkgutil
8 import pydoc
9 import sys
10
11 from telemetry.core import util
12
13 def RemoveAllDocs(docs_dir):
14 for dirname, _, filenames in os.walk(docs_dir):
15 for filename in filenames:
16 os.remove(os.path.join(dirname, filename))
17
18 def WriteDocsFor(module):
19 pydoc.writedoc(module)
20 for _, modname, _ in pkgutil.walk_packages(
21 module.__path__, module.__name__ + '.'):
22 if modname.endswith('_unittest'):
23 logging.info("skipping %s due to being a unittest", modname)
24 continue
25
26 module = __import__(modname, fromlist=[""])
27 name, _ = os.path.splitext(module.__file__)
28 if not os.path.exists(name + '.py'):
29 logging.info("skipping %s due to being an orphan .pyc", module.__file__)
30 continue
31
32 pydoc.writedoc(module)
33
34 def Main(args):
35 parser = optparse.OptionParser()
36 parser.add_option(
37 '-v', '--verbose', action='count', default=0,
38 help='Increase verbosity level (repeat as needed)')
39 options, args = parser.parse_args(args)
40 if options.verbose >= 2:
41 logging.basicConfig(level=logging.DEBUG)
42 elif options.verbose:
43 logging.basicConfig(level=logging.INFO)
44 else:
45 logging.basicConfig(level=logging.WARNING)
46
47
48 telemetry_dir = util.GetTelemetryDir()
49 docs_dir = os.path.join(telemetry_dir, 'docs')
50
51 assert os.path.isdir(docs_dir)
52
53 RemoveAllDocs(docs_dir)
54
55 if telemetry_dir not in sys.path:
56 sys.path.append(telemetry_dir)
57 import telemetry
58
59 old_cwd = os.getcwd()
60 try:
61 os.chdir(docs_dir)
62 WriteDocsFor(telemetry)
63 finally:
64 os.chdir(old_cwd)
OLDNEW
« 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