mirror of
https://github.com/mjl-/mox.git
synced 2025-07-14 05:34:38 +03:00
webadmin: make routes configurable: globally, per domain, per account
this simplifies some of the code that makes modifications to the config file. a few protected functions can make changes to the dynamic config, which webadmin can use. instead of having separate functions in mox-/admin.go for each type of change. this also exports the parsed full dynamic config to webadmin, so we need fewer functions for specific config fields too.
This commit is contained in:
26
vendor/github.com/mjl-/sherpadoc/cmd/sherpadoc/parse.go
generated
vendored
26
vendor/github.com/mjl-/sherpadoc/cmd/sherpadoc/parse.go
generated
vendored
@ -181,15 +181,21 @@ func parseSection(t *doc.Type, pp *parsedPackage) *section {
|
||||
}
|
||||
|
||||
// Ensure type "t" (used in a field or argument) defined in package pp is parsed
|
||||
// and added to the section.
|
||||
func ensureNamedType(t *doc.Type, sec *section, pp *parsedPackage) {
|
||||
typePath := pp.Path + "." + t.Name
|
||||
// and added to the section. The returned string is the name as used in the
|
||||
// sherpadoc, it may have been renamed.
|
||||
func ensureNamedType(t *doc.Type, sec *section, pp *parsedPackage) (name string) {
|
||||
if s, ok := renames[renameSrc{pp.Pkg.Name, t.Name}]; ok {
|
||||
name = s
|
||||
} else {
|
||||
name = t.Name
|
||||
}
|
||||
typePath := pp.Path + "." + name
|
||||
if _, have := sec.Typeset[typePath]; have {
|
||||
return
|
||||
}
|
||||
|
||||
tt := &namedType{
|
||||
Name: t.Name,
|
||||
Name: name,
|
||||
Text: strings.TrimSpace(t.Doc),
|
||||
}
|
||||
// add it early, so self-referencing types can't cause a loop
|
||||
@ -360,6 +366,7 @@ func ensureNamedType(t *doc.Type, sec *section, pp *parsedPackage) {
|
||||
default:
|
||||
logFatalLinef(pp, t.Decl.TokPos, "unsupported field/param/return type %T", ts.Type)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func hasOmitEmpty(tag *ast.BasicLit) bool {
|
||||
@ -407,8 +414,8 @@ func gatherFieldType(typeName string, f *field, e ast.Expr, fieldTag *ast.BasicL
|
||||
case *ast.Ident:
|
||||
tt := pp.lookupType(t.Name)
|
||||
if tt != nil {
|
||||
ensureNamedType(tt, sec, pp)
|
||||
return []string{t.Name}
|
||||
name := ensureNamedType(tt, sec, pp)
|
||||
return []string{name}
|
||||
}
|
||||
commaString := isCommaString(fieldTag)
|
||||
name := t.Name
|
||||
@ -465,8 +472,8 @@ func parseArgType(e ast.Expr, sec *section, pp *parsedPackage) typewords {
|
||||
case *ast.Ident:
|
||||
tt := pp.lookupType(t.Name)
|
||||
if tt != nil {
|
||||
ensureNamedType(tt, sec, pp)
|
||||
return []string{t.Name}
|
||||
name := ensureNamedType(tt, sec, pp)
|
||||
return []string{name}
|
||||
}
|
||||
name := t.Name
|
||||
switch name {
|
||||
@ -560,8 +567,7 @@ func parseSelector(t *ast.SelectorExpr, srcTypeName string, sec *section, pp *pa
|
||||
if tt == nil {
|
||||
logFatalLinef(pp, t.Pos(), "could not find type %q in package %q", typeName, importPath)
|
||||
}
|
||||
ensureNamedType(tt, sec, opp)
|
||||
return typeName
|
||||
return ensureNamedType(tt, sec, opp)
|
||||
}
|
||||
|
||||
type replacement struct {
|
||||
|
Reference in New Issue
Block a user