lotus/node/config/doc_util.go

45 lines
678 B
Go
Raw Normal View History

2021-07-23 13:16:07 +00:00
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)
}
2022-09-08 01:25:28 +00:00
func findDocSect(root, section, num string) *DocField {
2021-07-23 13:16:07 +00:00
path := strings.Split(section, ".")
docSection := Doc[root]
for _, e := range path {
if docSection == nil {
return nil
}
for _, field := range docSection {
2022-09-08 01:25:28 +00:00
if field.Num == e {
2021-07-23 13:16:07 +00:00
docSection = Doc[field.Type]
break
}
}
}
for _, df := range docSection {
2022-09-08 01:25:28 +00:00
if df.Num == num {
2021-07-23 13:16:07 +00:00
return &df
}
}
return nil
}