#!/usr/bin/env python3 import sys from json import loads def format(name, comment, signature): def parse_sig(sig): def parse_arg(arg): def parse_type(ty): i = ty.find("(") ty, name = ty[:i].strip().lower(), ty[i+1:].strip(" )") if name == "": return "()" return f"{name}:{ty}" i = arg.find("(") pre, arg_list = arg[:i], arg[i+1:].split(",") args = ", ".join(map(parse_type, arg_list)) if args.count(",") >= 1: args = f"({args})" return f"{args}" def parse_ret(ret): return ret.replace("Type :: ", "").lower() args, ret = sig.split("->") args = ", ".join(map(parse_arg, args[1:-2].split(")),"))) ret = parse_ret(ret) return f"