Skip to content

Commit

Permalink
💄 Update comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
iota9star committed Mar 22, 2023
1 parent 32c3494 commit 267e6d5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 31 deletions.
30 changes: 13 additions & 17 deletions example/env.g.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,31 @@
///
/// [Env] depends on file: .env, .env.prod
///
/// TYPE | KEY | VALUE
/// [INT] : 90898
///
/// =====================================================================================
/// [SIGNED_INT] : -8898
///
/// int | [INT] | 90898
/// [DOUBLE] : 3.1415926
///
/// int | [SIGNED_INT] | -8898
/// [SIGNED_DOUBLE] : -0.123
///
/// double | [DOUBLE] | 3.1415926
/// [BOOL] : true
///
/// double | [SIGNED_DOUBLE] | -0.123
/// [STRING] : "AAA"
///
/// bool | [BOOL] | true
/// [NO_QUOTE_STRING] : "ABC9shj\"\\'\\''';';;;'\\n\\r\\thttps://google.com"
///
/// String | [STRING] | "AAA"
/// [SINGLE_QUOTE_STRING] : "'AB\\r\\n\\ta\\'\\\"C'"
///
/// String | [NO_QUOTE_STRING] | "ABC9shj\"\\'\\''';';;;'\\n\\r\\thttps://google.com"
/// [DOUBLE_QUOTE_STRING] : "ABC"
///
/// String | [SINGLE_QUOTE_STRING] | "'AB\\r\\n\\ta\\'\\\"C'"
/// [JSON] : "{\"a\":1,\"b\":[1,true,\"hello\"]}"
///
/// String | [DOUBLE_QUOTE_STRING] | "ABC"
/// [EMPTY] : ''
///
/// String | [JSON] | "{\"a\":1,\"b\":[1,true,\"hello\"]}"
/// [EMPTY_COMMENT] : ''
///
/// String | [EMPTY] | ''
///
/// String | [EMPTY_COMMENT] | ''
///
/// double | [QWERTY] | -0.343
/// [QWERTY] : -0.343
///
abstract class Env {
const factory Env() = _Prod._;
Expand Down
23 changes: 9 additions & 14 deletions lib/env2dart.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,7 @@ void _codegen(
..returns = Reference(field.type)));
toJson.write("'${field.name}':${field.name},");
}
var columns = pairs.values
.map((e) => <Object>[e.type, "[${e.name}]", e.value])
.toList();
columns.insert(0, ["TYPE", "KEY", "VALUE"]);
var pretty = dolumnify(
columns,
columnSplitter: ' | ',
headerIncluded: true,
headerSeparator: '=',
);

var abs = Class(
(b) => b
..name = name
Expand All @@ -89,7 +80,9 @@ void _codegen(
if (active != null) '.env.$active'
].join(", ")}",
"///",
...pretty.split("\n").map((e) => ["/// $e", "///"]).expand((e) => e),
...pairs.values
.map((e) => ["/// [${e.name}] : ${e.value}", "///"])
.expand((e) => e),
])
..constructors = ListBuilder([
Constructor((b) => b
Expand All @@ -98,9 +91,10 @@ void _codegen(
..constant = true),
]),
);
columns = pairs.values.map((e) => <Object>[e.type, e.name, e.value]).toList();
var columns =
pairs.values.map((e) => <Object>[e.type, e.name, e.value]).toList();
columns.insert(0, ["TYPE", "KEY", "VALUE"]);
pretty = dolumnify(
var pretty = dolumnify(
columns,
columnSplitter: ' | ',
headerIncluded: true,
Expand All @@ -121,7 +115,8 @@ void _codegen(
..name = "toString"
..annotations = ListBuilder([CodeExpression(Code("override"))])
..returns = Reference("String")
..body = Code("return ${pretty.split("\n").map((e) => jsonEncode("$e\n")).join("\n")};"))
..body = Code(
"return ${pretty.split("\n").map((e) => jsonEncode("$e\n")).join("\n")};"))
])
..constructors = ListBuilder([
Constructor((b) => b
Expand Down

0 comments on commit 267e6d5

Please sign in to comment.