fix(commands): remove examples from command discovery

This commit is contained in:
tiennm99 committed 2026-07-21 13:52:53 +07:00
1 parent b5c7427520
commit a211b7f8b7
22 files changed
+47 -154

No files matched your search

-3
View File
@@ -50,9 +50,6 @@ func RenderHelp(reg *modules.Registry) string {
fmt.Fprintf(&sb, "\n%s %s",
html.EscapeString(command.InvocationSentence()),
html.EscapeString(command.SummarySentence()))
if example := command.ExampleInvocation(); example != "" {
fmt.Fprintf(&sb, " Eg: <code>%s</code>", html.EscapeString(example))
}
}
sections = append(sections, sb.String())
}
+3 -10
View File
@@ -74,13 +74,12 @@ func TestRenderHelp_GroupsByModuleAndSkipsNonPublic(t *testing.T) {
}
}
func TestRenderHelp_ShowsParametersAndCopyableExample(t *testing.T) {
func TestRenderHelp_ShowsParametersWithoutExample(t *testing.T) {
command := modules.Command{
Name: "buy",
Visibility: modules.VisibilityPublic,
Description: "Buy & hold",
Parameters: "<quantity> <ticker>",
Example: "/buy 100 TCB & hold",
Handler: helpTestNoop,
}
reg, err := modules.Build(
@@ -97,14 +96,8 @@ func TestRenderHelp_ShowsParametersAndCopyableExample(t *testing.T) {
if !strings.Contains(out, "/buy &lt;quantity&gt; &lt;ticker&gt;. Buy &amp; hold.") {
t.Fatalf("help missing formatted invocation and summary:\n%s", out)
}
if !strings.Contains(out, "<code>/buy 100 TCB &amp; hold</code>") {
t.Fatalf("help missing copyable example:\n%s", out)
}
if !strings.Contains(out, "Buy &amp; hold. Eg: <code>/buy 100 TCB &amp; hold</code>") {
t.Fatalf("help missing short example label:\n%s", out)
}
if strings.Contains(out, "<pre>") {
t.Fatalf("help example should use inline code, not a pre block:\n%s", out)
if strings.Contains(out, "Eg:") || strings.Contains(out, "<code>") || strings.Contains(out, "<pre>") {
t.Fatalf("help should not render examples:\n%s", out)
}
}