From 40d80f73ee35bdcc54fa300b883adb56875f593c Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Sat, 23 Sep 2017 21:01:49 +0200 Subject: [PATCH] Enhance docs search to show namespaces if names clash --- docs/generate.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/docs/generate.py b/docs/generate.py index 7b27831c..be807586 100755 --- a/docs/generate.py +++ b/docs/generate.py @@ -504,13 +504,24 @@ def generate_documentation(scheme_file): methods = sorted(methods, key=lambda m: m.name) constructors = sorted(constructors, key=lambda c: c.name) + def fmt(xs): + ys = {x: get_class_name(x) for x in xs} # cache TLObject: display + zs = {} # create a dict to hold those which have duplicated keys + for y in ys.values(): + zs[y] = y in zs + return ', '.join( + '"{}.{}"'.format(x.namespace, ys[x]) + if zs[ys[x]] and getattr(x, 'namespace', None) + else '"{}"'.format(ys[x]) for x in xs + ) + + request_names = fmt(methods) + type_names = fmt(types) + constructor_names = fmt(constructors) + def fmt(xs, formatter): return ', '.join('"{}"'.format(formatter(x)) for x in xs) - request_names = fmt(methods, get_class_name) - type_names = fmt(types, get_class_name) - constructor_names = fmt(constructors, get_class_name) - request_urls = fmt(methods, get_create_path_for) type_urls = fmt(types, get_path_for_type) constructor_urls = fmt(constructors, get_create_path_for)