From 235e7b51f8791848b3be73c06e9617610533347e Mon Sep 17 00:00:00 2001 From: wineguo Date: Mon, 15 Jan 2024 11:12:24 +0800 Subject: [PATCH] apidocs: trim extraneous for summary --- util/apidocs/path.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/util/apidocs/path.go b/util/apidocs/path.go index 83fab1f..f3ac2ae 100644 --- a/util/apidocs/path.go +++ b/util/apidocs/path.go @@ -110,7 +110,18 @@ func (args methodArgs) summary() string { if len(args.RPC.SwaggerInfo.Title) != 0 { summary = args.RPC.SwaggerInfo.Title } - return summary + return trimExtraneous(summary) +} + +func trimExtraneous(input string) string { + const marker = "@alias=" + s := strings.Split(input, marker) + // Remove the alias if had any. + output := s[0] + // Remove comment slashes. + output = strings.ReplaceAll(output, "\n//", " ") + output = strings.ReplaceAll(output, "//", " ") + return strings.Trim(output, " \"'") } func (args methodArgs) method() *MethodStruct {