lotus/node/config/doc_util.go
2022-09-09 21:40:15 -04:00

45 lines
678 B
Go

package config
import (
"fmt"
"strings"
)
func findDoc(root interface{}, section, name string) *DocField {
rt := fmt.Sprintf("%T", root)[len("*config."):]
doc := findDocSect(rt, section, name)
if doc != nil {
return doc
}
return findDocSect("Common", section, name)
}
func findDocSect(root, section, num string) *DocField {
path := strings.Split(section, ".")
docSection := Doc[root]
for _, e := range path {
if docSection == nil {
return nil
}
for _, field := range docSection {
if field.Num == e {
docSection = Doc[field.Type]
break
}
}
}
for _, df := range docSection {
if df.Num == num {
return &df
}
}
return nil
}