@@ -388,6 +388,7 @@ struct Sections {
388
388
const auto indent = std::string (current_indent, ' ' );
389
389
const auto indent_next = std::string (current_indent + 2 , ' ' );
390
390
const bool push_name{outer_type == OuterType::OBJ}; // Dictionary keys must have a name
391
+ const bool is_top_level_arg{outer_type == OuterType::NONE}; // True on the first recursion
391
392
392
393
switch (arg.m_type ) {
393
394
case RPCArg::Type::STR_HEX:
@@ -396,7 +397,7 @@ struct Sections {
396
397
case RPCArg::Type::AMOUNT:
397
398
case RPCArg::Type::RANGE:
398
399
case RPCArg::Type::BOOL: {
399
- if (outer_type == OuterType::NONE ) return ; // Nothing more to do for non-recursive types on first recursion
400
+ if (is_top_level_arg ) return ; // Nothing more to do for non-recursive types on first recursion
400
401
auto left = indent;
401
402
if (arg.m_opts .type_str .size () != 0 && push_name) {
402
403
left += " \" " + arg.GetName () + " \" : " + arg.m_opts .type_str .at (0 );
@@ -409,28 +410,28 @@ struct Sections {
409
410
}
410
411
case RPCArg::Type::OBJ:
411
412
case RPCArg::Type::OBJ_USER_KEYS: {
412
- const auto right = outer_type == OuterType::NONE ? " " : arg.ToDescriptionString ();
413
+ const auto right = is_top_level_arg ? " " : arg.ToDescriptionString ();
413
414
PushSection ({indent + (push_name ? " \" " + arg.GetName () + " \" : " : " " ) + " {" , right});
414
415
for (const auto & arg_inner : arg.m_inner ) {
415
416
Push (arg_inner, current_indent + 2 , OuterType::OBJ);
416
417
}
417
418
if (arg.m_type != RPCArg::Type::OBJ) {
418
419
PushSection ({indent_next + " ..." , " " });
419
420
}
420
- PushSection ({indent + " }" + (outer_type != OuterType::NONE ? " , " : " " ), " " });
421
+ PushSection ({indent + " }" + (is_top_level_arg ? " " : " , " ), " " });
421
422
break ;
422
423
}
423
424
case RPCArg::Type::ARR: {
424
425
auto left = indent;
425
426
left += push_name ? " \" " + arg.GetName () + " \" : " : " " ;
426
427
left += " [" ;
427
- const auto right = outer_type == OuterType::NONE ? " " : arg.ToDescriptionString ();
428
+ const auto right = is_top_level_arg ? " " : arg.ToDescriptionString ();
428
429
PushSection ({left, right});
429
430
for (const auto & arg_inner : arg.m_inner ) {
430
431
Push (arg_inner, current_indent + 2 , OuterType::ARR);
431
432
}
432
433
PushSection ({indent_next + " ..." , " " });
433
- PushSection ({indent + " ]" + (outer_type != OuterType::NONE ? " , " : " " ), " " });
434
+ PushSection ({indent + " ]" + (is_top_level_arg ? " " : " , " ), " " });
434
435
break ;
435
436
}
436
437
} // no default case, so the compiler can warn about missing cases
0 commit comments