refactor(api): clarify APIError message usage and fix legacy lint error (#38012)

Avoid unclear & fragile "any" tricks, fix various abuses

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
Copilot
2026-06-07 06:19:39 +00:00
committed by GitHub
co-authored by wxiaoguang
parent c43eb7c33a
commit 5fe4f962e8
64 changed files with 395 additions and 384 deletions
+14 -3
View File
@@ -95,13 +95,13 @@ type Icon struct {
// ColorPreview is an inline for a color preview
type ColorPreview struct {
ast.BaseInline
Color []byte
Color string
}
// Dump implements Node.Dump.
func (n *ColorPreview) Dump(source []byte, level int) {
m := map[string]string{}
m["Color"] = string(n.Color)
m["Color"] = n.Color
ast.DumpHelper(n, source, level, m, nil)
}
@@ -114,7 +114,7 @@ func (n *ColorPreview) Kind() ast.NodeKind {
}
// NewColorPreview returns a new Span node.
func NewColorPreview(color []byte) *ColorPreview {
func NewColorPreview(color string) *ColorPreview {
return &ColorPreview{
BaseInline: ast.BaseInline{},
Color: color,
@@ -170,3 +170,14 @@ func (n *RawHTML) Kind() ast.NodeKind {
func NewRawHTML(rawHTML template.HTML) *RawHTML {
return &RawHTML{rawHTML: rawHTML}
}
func childSingleText(node ast.Node, source []byte) (string, bool) {
if node.FirstChild() == nil || node.FirstChild() != node.LastChild() {
return "", false
}
c, ok := node.FirstChild().(*ast.Text)
if !ok {
return "", false
}
return string(c.Segment.Value(source)), true
}