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

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: 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
OLDNEW
(Empty)
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
tonyg 2013/06/18 16:09:11 nit: 2013
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 sys
tonyg 2013/06/18 16:09:11 nit: alphabetize
8 import pkgutil
9 import pydoc
10
11 def UnlinkAllDocs(docs_dir):
tonyg 2013/06/18 16:09:11 Can we name this RemoveAllDocs and call os.remove
12 for dirname, _, filenames in os.walk(docs_dir):
13 for filename in filenames:
14 os.unlink(os.path.join(dirname, filename))
15
16 def WriteDocsFor(module):
17 pydoc.writedoc(module)
18 for _, modname, _ in pkgutil.walk_packages(
19 module.__path__, module.__name__ + '.'):
20 if modname.endswith('_unittest'):
21 logging.info("skipping %s due to being a unittest", modname)
22 continue
23
24 module = __import__(modname, fromlist=[""])
25 name, _ = os.path.splitext(module.__file__)
26 if not os.path.exists(name + '.py'):
27 logging.info("skipping %s due to being an orphan .pyc", module.__file__)
28 continue
29
30 pydoc.writedoc(module)
31
32 def Main(args):
33 parser = optparse.OptionParser()
34 parser.add_option(
35 '-v', '--verbose', action='count', default=0,
36 help='Increase verbosity level (repeat as needed)')
37 options, args = parser.parse_args(args)
38 if options.verbose >= 2:
39 logging.basicConfig(level=logging.DEBUG)
40 elif options.verbose:
41 logging.basicConfig(level=logging.INFO)
42 else:
43 logging.basicConfig(level=logging.WARNING)
44
45 toplevel_dir = os.path.abspath(
46 os.path.join(
47 os.path.dirname(__file__), '..'))
tonyg 2013/06/18 16:09:11 util.GetTelemetryDir() ?
48 docs_dir = os.path.join(toplevel_dir, 'docs')
49
50 assert os.path.isdir(docs_dir)
51 assert os.path.exists(
52 os.path.join(toplevel_dir,
53 'telemetry', '__init__.py'))
54
55 UnlinkAllDocs(docs_dir)
56
57 if toplevel_dir not in sys.path:
58 sys.path.append(toplevel_dir)
59 import telemetry
60
61 old_cwd = os.getcwd()
62 try:
63 os.chdir(docs_dir)
64 WriteDocsFor(telemetry)
65 finally:
66 os.chdir(old_cwd)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698