mirror of
https://github.com/status-im/nim-confutils.git
synced 2025-03-04 05:40:53 +00:00
Don't use fully qualified enum values as the names of TOML file sections - use the short enum name instead
This commit is contained in:
parent
0a88d30e00
commit
375b6276ca
@ -69,6 +69,12 @@ proc traversePostfix(postfix: NimNode, typ: NimNode, isDiscriminator: bool,
|
|||||||
traverseIdent(postfix[1], typ, isDiscriminator, isCommandOrArgument,
|
traverseIdent(postfix[1], typ, isDiscriminator, isCommandOrArgument,
|
||||||
defaultValue, namePragma)
|
defaultValue, namePragma)
|
||||||
|
|
||||||
|
proc shortEnumName(n: NimNode): NimNode =
|
||||||
|
if n.kind == nnkDotExpr:
|
||||||
|
n[1]
|
||||||
|
else:
|
||||||
|
n
|
||||||
|
|
||||||
proc traversePragma(pragma: NimNode):
|
proc traversePragma(pragma: NimNode):
|
||||||
tuple[isCommandOrArgument: bool, defaultValue, namePragma: string] =
|
tuple[isCommandOrArgument: bool, defaultValue, namePragma: string] =
|
||||||
pragma.expectKind nnkPragma
|
pragma.expectKind nnkPragma
|
||||||
@ -81,7 +87,7 @@ proc traversePragma(pragma: NimNode):
|
|||||||
of nnkExprColonExpr:
|
of nnkExprColonExpr:
|
||||||
let pragma = $child[0]
|
let pragma = $child[0]
|
||||||
if pragma == "defaultValue":
|
if pragma == "defaultValue":
|
||||||
result.defaultValue = child[1].repr
|
result.defaultValue = repr(shortEnumName(child[1]))
|
||||||
elif pragma == "name":
|
elif pragma == "name":
|
||||||
result.namePragma = $child[1]
|
result.namePragma = $child[1]
|
||||||
else:
|
else:
|
||||||
@ -124,7 +130,7 @@ proc traverseRecList(recList: NimNode, parent: ConfFileSection): seq[ConfFileSec
|
|||||||
|
|
||||||
proc traverseOfBranch(ofBranch: NimNode, parent: ConfFileSection): ConfFileSection =
|
proc traverseOfBranch(ofBranch: NimNode, parent: ConfFileSection): ConfFileSection =
|
||||||
ofBranch.expectKind nnkOfBranch
|
ofBranch.expectKind nnkOfBranch
|
||||||
result = ConfFileSection(fieldName: repr(ofBranch[0]), isCaseBranch: true)
|
result = ConfFileSection(fieldName: repr(shortEnumName(ofBranch[0])), isCaseBranch: true)
|
||||||
for child in ofBranch:
|
for child in ofBranch:
|
||||||
case child.kind:
|
case child.kind:
|
||||||
of nnkIdent, nnkDotExpr:
|
of nnkIdent, nnkDotExpr:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user