| 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 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 453 elif isinstance(node, ast.FunctionDef) and node.name == target: | 453 elif isinstance(node, ast.FunctionDef) and node.name == target: |
| 454 base.known_objects[k].func.CopyFrom(parse_func(node, relpath, {})) | 454 base.known_objects[k].func.CopyFrom(parse_func(node, relpath, {})) |
| 455 break | 455 break |
| 456 else: | 456 else: |
| 457 raise ValueError('could not find %r in %r' % (k, relpath)) | 457 raise ValueError('could not find %r in %r' % (k, relpath)) |
| 458 | 458 |
| 459 | 459 |
| 460 def add_subparser(parser): | 460 def add_subparser(parser): |
| 461 doc_kinds=('binarypb', 'jsonpb', 'textpb', 'markdown(github)', | 461 doc_kinds=('binarypb', 'jsonpb', 'textpb', 'markdown(github)', |
| 462 'markdown(gitiles)') | 462 'markdown(gitiles)') |
| 463 helpstr = ( |
| 464 'List all known modules reachable from the current package, with their ' |
| 465 'documentation.' |
| 466 ) |
| 463 doc_p = parser.add_parser( | 467 doc_p = parser.add_parser( |
| 464 'doc', | 468 'doc', help=helpstr, description=helpstr) |
| 465 description='List all known modules reachable from the current package, ' | |
| 466 'with their documentation') | |
| 467 doc_p.add_argument('recipe', nargs='?', | 469 doc_p.add_argument('recipe', nargs='?', |
| 468 help='Restrict documentation to this recipe') | 470 help='Restrict documentation to this recipe') |
| 469 doc_p.add_argument('--kind', default='jsonpb', choices=doc_kinds, | 471 doc_p.add_argument('--kind', default='jsonpb', choices=doc_kinds, |
| 470 help='Output this kind of documentation') | 472 help='Output this kind of documentation') |
| 471 | 473 |
| 472 doc_p.set_defaults(command='doc', func=main) | 474 doc_p.set_defaults(command='doc', func=main) |
| 473 | 475 |
| 474 | 476 |
| 475 def main(package_deps, args): | 477 def main(package_deps, args): |
| 476 universe = loader.RecipeUniverse(package_deps, args.package) | 478 universe = loader.RecipeUniverse(package_deps, args.package) |
| (...skipping 18 matching lines...) Expand all Loading... |
| 495 if args.kind == 'jsonpb': | 497 if args.kind == 'jsonpb': |
| 496 sys.stdout.write(jsonpb.MessageToJson( | 498 sys.stdout.write(jsonpb.MessageToJson( |
| 497 node, including_default_value_fields=True, | 499 node, including_default_value_fields=True, |
| 498 preserving_proto_field_name=True)) | 500 preserving_proto_field_name=True)) |
| 499 elif args.kind == 'binarypb': | 501 elif args.kind == 'binarypb': |
| 500 sys.stdout.write(node.SerializeToString()) | 502 sys.stdout.write(node.SerializeToString()) |
| 501 elif args.kind == 'textpb': | 503 elif args.kind == 'textpb': |
| 502 sys.stdout.write(textpb.MessageToString(node)) | 504 sys.stdout.write(textpb.MessageToString(node)) |
| 503 else: | 505 else: |
| 504 raise NotImplementedError('--kind=%s' % args.kind) | 506 raise NotImplementedError('--kind=%s' % args.kind) |
| OLD | NEW |