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

Side by Side Diff: recipe_engine/doc.py

Issue 2845923002: [recipes.py] use argparse to set command automatically. (Closed)
Patch Set: rebase Created 3 years, 7 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
« no previous file with comments | « recipe_engine/depgraph.py ('k') | recipe_engine/fetch.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2013 The LUCI Authors. All rights reserved. 2 # Copyright 2013 The LUCI Authors. All rights reserved.
3 # Use of this source code is governed under the Apache License, Version 2.0 3 # Use of this source code is governed under the Apache License, Version 2.0
4 # that can be found in the LICENSE file. 4 # that can be found in the LICENSE file.
5 5
6 from __future__ import print_function, absolute_import 6 from __future__ import print_function, absolute_import
7 7
8 import ast 8 import ast
9 import inspect 9 import inspect
10 import json 10 import json
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 'List all known modules reachable from the current package, with their ' 464 'List all known modules reachable from the current package, with their '
465 'documentation.' 465 'documentation.'
466 ) 466 )
467 doc_p = parser.add_parser( 467 doc_p = parser.add_parser(
468 'doc', help=helpstr, description=helpstr) 468 'doc', help=helpstr, description=helpstr)
469 doc_p.add_argument('recipe', nargs='?', 469 doc_p.add_argument('recipe', nargs='?',
470 help='Restrict documentation to this recipe') 470 help='Restrict documentation to this recipe')
471 doc_p.add_argument('--kind', default='jsonpb', choices=doc_kinds, 471 doc_p.add_argument('--kind', default='jsonpb', choices=doc_kinds,
472 help='Output this kind of documentation') 472 help='Output this kind of documentation')
473 473
474 doc_p.set_defaults(command='doc', func=main) 474 doc_p.set_defaults(func=main)
475 475
476 476
477 def main(package_deps, args): 477 def main(package_deps, args):
478 universe = loader.RecipeUniverse(package_deps, args.package) 478 universe = loader.RecipeUniverse(package_deps, args.package)
479 universe_view = loader.UniverseView(universe, package_deps.root_package) 479 universe_view = loader.UniverseView(universe, package_deps.root_package)
480 480
481 logging.basicConfig() 481 logging.basicConfig()
482 482
483 spec = universe_view.package.repo_spec.spec_pb() 483 spec = universe_view.package.repo_spec.spec_pb()
484 base_dir = universe_view.package.repo_root 484 base_dir = universe_view.package.repo_root
(...skipping 12 matching lines...) Expand all
497 if args.kind == 'jsonpb': 497 if args.kind == 'jsonpb':
498 sys.stdout.write(jsonpb.MessageToJson( 498 sys.stdout.write(jsonpb.MessageToJson(
499 node, including_default_value_fields=True, 499 node, including_default_value_fields=True,
500 preserving_proto_field_name=True)) 500 preserving_proto_field_name=True))
501 elif args.kind == 'binarypb': 501 elif args.kind == 'binarypb':
502 sys.stdout.write(node.SerializeToString()) 502 sys.stdout.write(node.SerializeToString())
503 elif args.kind == 'textpb': 503 elif args.kind == 'textpb':
504 sys.stdout.write(textpb.MessageToString(node)) 504 sys.stdout.write(textpb.MessageToString(node))
505 else: 505 else:
506 raise NotImplementedError('--kind=%s' % args.kind) 506 raise NotImplementedError('--kind=%s' % args.kind)
OLDNEW
« no previous file with comments | « recipe_engine/depgraph.py ('k') | recipe_engine/fetch.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698