| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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) |
| OLD | NEW |