未验证 提交 8ad4f1b0 编写于 作者: L Leo Chen 提交者: GitHub

Use alias name instead of original name for alias API when generating API specification (#26143)

* use alias name instead of original name for alias API

* refine log message
上级 fb72b192
...@@ -27,6 +27,7 @@ import pydoc ...@@ -27,6 +27,7 @@ import pydoc
import hashlib import hashlib
import six import six
import functools import functools
import logging
member_dict = collections.OrderedDict() member_dict = collections.OrderedDict()
...@@ -97,7 +98,10 @@ def queue_dict(member, cur_name): ...@@ -97,7 +98,10 @@ def queue_dict(member, cur_name):
member_dict[cur_name] = "({}, ('document', '{}'))".format(args, doc_md5) member_dict[cur_name] = "({}, ('document', '{}'))".format(args, doc_md5)
def visit_member(parent_name, member): def visit_member(parent_name, member, member_name=None):
if member_name:
cur_name = ".".join([parent_name, member_name])
else:
cur_name = ".".join([parent_name, member.__name__]) cur_name = ".".join([parent_name, member.__name__])
if inspect.isclass(member): if inspect.isclass(member):
queue_dict(member, cur_name) queue_dict(member, cur_name)
...@@ -162,6 +166,12 @@ def visit_all_module(mod): ...@@ -162,6 +166,12 @@ def visit_all_module(mod):
if inspect.ismodule(instance): if inspect.ismodule(instance):
visit_all_module(instance) visit_all_module(instance)
else:
if member_name != instance.__name__:
logging.warn(
"Found alias API, alias name is: {}, original name is: {}".
format(member_name, instance.__name__))
visit_member(mod.__name__, instance, member_name)
else: else:
visit_member(mod.__name__, instance) visit_member(mod.__name__, instance)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册