mirror of
https://github.com/zap-proto/zip.git
synced 2026-10-19 15:38:57 +00:00
zipdoc drops the handler's own name in any case
An unexported handler documented with its exported spelling -- `list` carrying "List returns the caller org's live bot runs" -- named itself as exactly as "list returns" would, and kept the identifier: "List" is one hump, so the shape rule cannot read it as a symbol. 136 lifted comments across the cloud fleet open this way, and each reached the document, the CLI help, the MCP tool and the SDK docstring as "List returns ...". The case-folded name takes the shape rule's verb guard, so "Health is a liveness probe" keeps its subject. Co-authored-by: Hanzo Dev <[email protected]>
This commit is contained in:
@@ -830,6 +830,16 @@ func (e *extractor) commentAbove(pos token.Pos) string {
|
||||
// MCP tool and a CLI help line opening with a Go symbol the reader cannot see,
|
||||
// cannot call, and already has in operationId.
|
||||
//
|
||||
// The name in another CASE is the same evidence. An unexported handler documented
|
||||
// the way its exported spelling would be — `list` carrying "List returns the
|
||||
// caller org's live bot runs", `stop` carrying "Stop terminates one run" — names
|
||||
// itself as exactly as "list returns" would; Go's convention asks for the
|
||||
// identifier and the author capitalised it because it opens a sentence. Measured
|
||||
// across one fleet, 136 lifted comments open this way, and a one-hump word is the
|
||||
// one shape the rule below cannot read as a symbol ("List" is also a verb). It
|
||||
// takes the same verb guard as the shape rule, so "Health is a liveness probe"
|
||||
// keeps its subject.
|
||||
//
|
||||
// So failing an exact match, Go's own SENTENCE SHAPE is the evidence: a strict
|
||||
// CamelCase word followed by a lowercase verb, which is the form the convention
|
||||
// itself prescribes. Both halves are deliberately narrow, because a wrong strip
|
||||
@@ -849,7 +859,7 @@ func stripSelf(text, name string) string {
|
||||
return recapitalize(rest, text)
|
||||
}
|
||||
word, rest, spaced := strings.Cut(text, " ")
|
||||
if !spaced || !camelCase(word) {
|
||||
if !spaced || !(camelCase(word) || name != "" && strings.EqualFold(word, name)) {
|
||||
return text
|
||||
}
|
||||
verb, _, _ := strings.Cut(rest, " ")
|
||||
|
||||
@@ -219,6 +219,19 @@ func TestStripSelf(t *testing.T) {
|
||||
"Removes one of your org's load balancers.\n"},
|
||||
{"D1DatabaseList lists the databases on the account.\n", "list",
|
||||
"Lists the databases on the account.\n"},
|
||||
// The name in another case: an unexported handler documented with its
|
||||
// exported spelling. "List" is one hump, so only the name can speak for it.
|
||||
{"List returns the caller org's live bot runs.\n", "list",
|
||||
"Returns the caller org's live bot runs.\n"},
|
||||
{"Stop terminates one of the caller org's own bot runs.\n", "stop",
|
||||
"Terminates one of the caller org's own bot runs.\n"},
|
||||
{"KVNamespaceList lists the Workers KV namespaces.\n", "kvNamespaceList",
|
||||
"Lists the Workers KV namespaces.\n"},
|
||||
// ... and it keeps the verb guard: the name as the SUBJECT stays.
|
||||
{"Health is a pure liveness probe.\n", "health", "Health is a pure liveness probe.\n"},
|
||||
// A one-hump word that is NOT the handler's name is prose, not a symbol.
|
||||
{"List every agent in your org.\n", "agents", "List every agent in your org.\n"},
|
||||
{"Get returns one key.\n", "put", "Get returns one key.\n"},
|
||||
// An inline handler names no function; only the shape can speak for it.
|
||||
{"ListAgents returns every agent in your org.\n", "", "Returns every agent in your org.\n"},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user