OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2013 The Chromium Authors. All rights reserved. | 2 # Copyright 2013 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 from __future__ import print_function | 6 from __future__ import print_function |
7 | 7 |
8 import collections | 8 import collections |
9 import inspect | 9 import inspect |
10 import os | 10 import os |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 name = '@'+name | 68 name = '@'+name |
69 if obj.fset: | 69 if obj.fset: |
70 name += '(r/w)' | 70 name += '(r/w)' |
71 p(indent_lvl, name, '', end='') | 71 p(indent_lvl, name, '', end='') |
72 if obj.__doc__: | 72 if obj.__doc__: |
73 lines = trim_doc(obj.__doc__) | 73 lines = trim_doc(obj.__doc__) |
74 p(0, '--', lines[0]) | 74 p(0, '--', lines[0]) |
75 else: | 75 else: |
76 p(0) | 76 p(0) |
77 | 77 |
78 def main(package_deps): | 78 def main(universe): |
79 common_methods = set(k for k, v in member_iter(recipe_api.RecipeApi)) | 79 common_methods = set(k for k, v in member_iter(recipe_api.RecipeApi)) |
80 p(0, 'Common Methods -- %s' % os.path.splitext(recipe_api.__file__)[0]) | 80 p(0, 'Common Methods -- %s' % os.path.splitext(recipe_api.__file__)[0]) |
81 for method in sorted(common_methods): | 81 for method in sorted(common_methods): |
82 pmethod(1, method, getattr(recipe_api.RecipeApi, method)) | 82 pmethod(1, method, getattr(recipe_api.RecipeApi, method)) |
83 | 83 |
84 universe = loader.RecipeUniverse(package_deps) | |
85 deps = universe.deps_from_spec( | 84 deps = universe.deps_from_spec( |
86 # TODO(luqui): This doesn't handle name scoping correctly (e.g. same-named | 85 # TODO(luqui): This doesn't handle name scoping correctly (e.g. same-named |
87 # modules in different packages). | 86 # modules in different packages). |
88 { modpath: modpath.split('/')[-1] | 87 { modpath: modpath.split('/')[-1] |
89 for modpath in universe.loop_over_recipe_modules() }) | 88 for modpath in universe.loop_over_recipe_modules() }) |
90 | 89 |
91 inst = loader.create_recipe_api( | 90 inst = loader.create_recipe_api( |
92 deps, recipe_run.RecipeEngine(None, {}, None)) | 91 deps, recipe_run.RecipeEngine(None, {}, None, universe)) |
93 | 92 |
94 for mod_name, mod in deps.iteritems(): | 93 for mod_name, mod in deps.iteritems(): |
95 p(0) | 94 p(0) |
96 p(0, "(%s) -- %s" % (mod_name, mod.__path__[0])) | 95 p(0, "(%s) -- %s" % (mod_name, mod.__path__[0])) |
97 if mod.LOADED_DEPS: | 96 if mod.LOADED_DEPS: |
98 p(1, 'DEPS:', list(mod.LOADED_DEPS)) | 97 p(1, 'DEPS:', list(mod.LOADED_DEPS)) |
99 | 98 |
100 subinst = getattr(inst, mod_name) | 99 subinst = getattr(inst, mod_name) |
101 bases = set(subinst.__class__.__bases__) | 100 bases = set(subinst.__class__.__bases__) |
102 base_fns = set() | 101 base_fns = set() |
103 for base in bases: | 102 for base in bases: |
104 for name, _ in inspect.getmembers(base): | 103 for name, _ in inspect.getmembers(base): |
105 base_fns.add(name) | 104 base_fns.add(name) |
106 for cool_base in bases - set((recipe_api.RecipeApi,)): | 105 for cool_base in bases - set((recipe_api.RecipeApi,)): |
107 p(1, 'behaves like %s' % map_to_cool_name(cool_base)) | 106 p(1, 'behaves like %s' % map_to_cool_name(cool_base)) |
108 | 107 |
109 if mod.API.__doc__: | 108 if mod.API.__doc__: |
110 for line in trim_doc(mod.API.__doc__): | 109 for line in trim_doc(mod.API.__doc__): |
111 p(2, '"', line) | 110 p(2, '"', line) |
112 | 111 |
113 for fn_name, obj in member_iter(subinst): | 112 for fn_name, obj in member_iter(subinst): |
114 if fn_name in base_fns: | 113 if fn_name in base_fns: |
115 continue | 114 continue |
116 pmethod(1, fn_name, obj) | 115 pmethod(1, fn_name, obj) |
OLD | NEW |