From 303a5b77e4b55aeb86845c0f25b6506974ac9bb0 Mon Sep 17 00:00:00 2001 From: Kishor Mainali Date: Tue, 28 Nov 2023 10:16:25 +0545 Subject: [PATCH] docs: added comments on generated code --- CHANGELOG.md | 3 +++ example/lib/src/core/register_adapters.dart | 6 ++++++ lib/src/type_register_builder.dart | 13 +++++++++++++ pubspec.yaml | 2 +- 4 files changed, 23 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 33d2168..ba30ea1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +# 1.0.2 +- added comments on generated code + # 1.0.1 - remove duplicate imports from generated code diff --git a/example/lib/src/core/register_adapters.dart b/example/lib/src/core/register_adapters.dart index bfd71b8..758aec4 100644 --- a/example/lib/src/core/register_adapters.dart +++ b/example/lib/src/core/register_adapters.dart @@ -1,7 +1,13 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: lines_longer_than_80_chars + import 'package:example/another_model.dart'; import 'package:example/model.dart'; import 'package:hive_local_storage/hive_local_storage.dart'; +// ***************************************************************************** +// Type Adapters +//***************************************************************************** void registerAdapters() { Hive.registerAdapter(AnotherModelAdapter()); Hive.registerAdapter(AnothorAModelAdapter()); diff --git a/lib/src/type_register_builder.dart b/lib/src/type_register_builder.dart index 3c3cadb..8d4ba24 100644 --- a/lib/src/type_register_builder.dart +++ b/lib/src/type_register_builder.dart @@ -79,9 +79,22 @@ class TypeRegisterBuilder implements Builder { var library = Library( (builder) => builder + ..comments.addAll([ + 'GENERATED CODE - DO NOT MODIFY BY HAND', + 'ignore_for_file: lines_longer_than_80_chars', + ]) ..directives.addAll(imports) ..body.addAll( [ + const Code('\n'), + const Code( + '//*****************************************************************************'), + const Code('\n'), + const Code('// Type Adapters'), + const Code('\n'), + const Code( + '//*****************************************************************************'), + const Code('\n'), const Code('void registerAdapters(){'), ...files .map((e) => Code('Hive.registerAdapter(${e.adapterName}());')), diff --git a/pubspec.yaml b/pubspec.yaml index 9dca188..9640035 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: type_register description: Generator which generates method named registerAdapters with all the hive adapters for the types annotated with @HiveType. -version: 1.0.1 +version: 1.0.2 topics: - type-register-generator - dart