From ab95834b599467057ae23ab98aa12ae6480cf166 Mon Sep 17 00:00:00 2001 From: Matthias Date: Mon, 1 Jul 2024 20:50:47 +0800 Subject: [PATCH] Add documentation generation for nitrogen --- nitrogen/CHANGELOG.md | 4 + nitrogen/README.md | 5 + nitrogen/build.yaml | 1 + nitrogen/lib/nitrogen.dart | 15 +- .../configuration/build_configuration.dart | 14 +- .../lib/src/configuration/configuration.dart | 5 + nitrogen/lib/src/file_system.dart | 2 +- .../lib/src/generators/asset_generator.dart | 51 +++- .../lib/src/generators/theme_generator.dart | 81 +++++- nitrogen/lib/src/walker.dart | 2 +- nitrogen/pubspec.yaml | 10 +- .../build_configuration_test.dart | 29 +- .../src/configuration/configuration_test.dart | 1 + nitrogen/test/src/file_system_test.dart | 2 +- .../src/generators/asset_generator_test.dart | 125 ++++++++- .../src/generators/theme_generator_test.dart | 260 +++++++++++++++++- nitrogen/test/src/libraries_test.dart | 2 +- .../src/lints/reserved_keyword_lint_test.dart | 2 +- nitrogen/test/src/walker_test.dart | 2 +- nitrogen_flutter_svg/CHANGELOG.md | 3 + nitrogen_flutter_svg/build.yaml | 17 -- nitrogen_flutter_svg/pubspec.yaml | 6 +- nitrogen_lottie/CHANGELOG.md | 3 + nitrogen_lottie/build.yaml | 17 -- nitrogen_lottie/pubspec.yaml | 6 +- nitrogen_types/CHANGELOG.md | 5 + nitrogen_types/lib/assets.dart | 4 + nitrogen_types/lib/src/assets.dart | 10 +- nitrogen_types/pubspec.yaml | 2 +- 29 files changed, 565 insertions(+), 121 deletions(-) delete mode 100644 nitrogen_flutter_svg/build.yaml delete mode 100644 nitrogen_lottie/build.yaml create mode 100644 nitrogen_types/lib/assets.dart diff --git a/nitrogen/CHANGELOG.md b/nitrogen/CHANGELOG.md index 0ddd2b3..612c829 100644 --- a/nitrogen/CHANGELOG.md +++ b/nitrogen/CHANGELOG.md @@ -1,4 +1,8 @@ +## 0.3.0+1 +* Fix nitrogen erroneously importing Flutter and causing it to crash. + ## 0.3.0 +* Add configuration for documentation generation. * Add configuration for output locations. * Move configuration from `pubspec.yaml` to `build.yaml`. * Remove generation of `flutter_extension`. diff --git a/nitrogen/README.md b/nitrogen/README.md index 90c12c5..68f8732 100644 --- a/nitrogen/README.md +++ b/nitrogen/README.md @@ -85,6 +85,7 @@ targets: nitrogen: options: package: true + docs: false prefix: 'MyPrefix' key: file-name assets: @@ -99,6 +100,10 @@ targets: Optional. Defaults to `false`. Controls whether to generate assets as a package dependency. This should be `true` if you're bundling assets for other projects to use, i.e. [forui-assets](https://github.com/forus-labs/forui). +### `docs` + +Optional. Defaults to `true`. Controls whether to generate docs alongside the classes. + ### `prefix` Optional. Defaults to an empty string. Controls generated classes' prefixes. Given 'MyPrefix', the generated classes will diff --git a/nitrogen/build.yaml b/nitrogen/build.yaml index 5207ac9..8d3745f 100644 --- a/nitrogen/build.yaml +++ b/nitrogen/build.yaml @@ -16,6 +16,7 @@ builders: defaults: options: package: false + docs: true prefix: "" key: "file-name" assets: diff --git a/nitrogen/lib/nitrogen.dart b/nitrogen/lib/nitrogen.dart index 780b69c..c92c3e4 100644 --- a/nitrogen/lib/nitrogen.dart +++ b/nitrogen/lib/nitrogen.dart @@ -57,23 +57,30 @@ class NitrogenBuilder extends Builder { var fallbackTheme = assets; for (final segment in split(fallback).skip(1)) { themes = fallbackTheme; - fallbackTheme = fallbackTheme.children[segment]! as AssetDirectory; + + final nested = fallbackTheme.children[segment]; + if (nested == null) { + log.severe('Unable to find path to fallback theme, "$fallback". Did you specify it under flutter.assets in your pubspec.yaml?'); + return; + } + + fallbackTheme = nested as AssetDirectory; } await buildStep.writeAsString( assetsOutput, - AssetGenerator(configuration.prefix, assets, { themes }).generate(), + AssetGenerator(configuration.prefix, assets, { themes }, docs: configuration.docs).generate(), ); await buildStep.writeAsString( AssetId(buildStep.inputId.package, output), - ThemeGenerator(configuration.prefix, themes, fallbackTheme).generate(), + ThemeGenerator(configuration.prefix, themes, fallbackTheme, docs: configuration.docs).generate(), ); } else { await buildStep.writeAsString( assetsOutput, - AssetGenerator(configuration.prefix, assets, {}).generate(), + AssetGenerator(configuration.prefix, assets, {}, docs: configuration.docs).generate(), ); } diff --git a/nitrogen/lib/src/configuration/build_configuration.dart b/nitrogen/lib/src/configuration/build_configuration.dart index 46e870f..6e7d84e 100644 --- a/nitrogen/lib/src/configuration/build_configuration.dart +++ b/nitrogen/lib/src/configuration/build_configuration.dart @@ -1,6 +1,5 @@ import 'package:build/build.dart'; import 'package:meta/meta.dart'; - import 'package:nitrogen/src/configuration/key.dart'; import 'package:nitrogen/src/nitrogen_exception.dart'; @@ -8,7 +7,7 @@ import 'package:nitrogen/src/nitrogen_exception.dart'; final class BuildConfiguration { /// The Nitrogen configuration's valid keys. - static const keys = { 'package', 'prefix', 'key', 'assets', 'themes' }; + static const keys = { 'package', 'docs', 'prefix', 'key', 'assets', 'themes' }; /// Lints the pubspec. static void lint(Map configuration) { @@ -30,7 +29,8 @@ final class BuildConfiguration { /// Parses the assets configuration. @visibleForTesting static ({String output,}) parseAssets(Map configuration) { - switch (configuration) { + final copy = { 'output': 'lib/src/assets.nitrogen.dart' }..addAll(configuration); + switch (copy) { case { 'output': final String output }: return (output: output); @@ -43,7 +43,8 @@ final class BuildConfiguration { /// Parses the themes configuration. @visibleForTesting static ({String fallback, String output})? parseThemes(Map configuration) { - switch (configuration) { + final copy = { 'output': 'lib/src/asset_themes.nitrogen.dart' }..addAll(configuration); + switch (copy) { case { 'fallback': final String fallback, 'output': final String output }: return (fallback: fallback, output: output); @@ -59,6 +60,9 @@ final class BuildConfiguration { /// Whether to generate assets for a package. final bool package; + /// Whether to generate documentation. + final bool docs; + /// The prefix for generated classes. final String prefix; @@ -74,6 +78,7 @@ final class BuildConfiguration { /// Parses the build configuration. factory BuildConfiguration.parse(Map configuration) => BuildConfiguration( package: configuration['package'], + docs: configuration['docs'] ?? true, prefix: configuration['prefix'], key: Key.parse(configuration['key']), assets: parseAssets(configuration['assets']), @@ -83,6 +88,7 @@ final class BuildConfiguration { /// Creates a [BuildConfiguration]. BuildConfiguration({ required this.package, + required this.docs, required this.prefix, required this.key, required this.assets, diff --git a/nitrogen/lib/src/configuration/configuration.dart b/nitrogen/lib/src/configuration/configuration.dart index 0f3b7c1..0f352f4 100644 --- a/nitrogen/lib/src/configuration/configuration.dart +++ b/nitrogen/lib/src/configuration/configuration.dart @@ -11,6 +11,7 @@ final class Configuration { /// Parses the configuration from the project's pubspec.yaml. factory Configuration.merge(BuildConfiguration configuration, YamlMap pubspec) => Configuration( package: parsePackage(pubspec.nodes['name'], enabled: configuration.package), + docs: configuration.docs, prefix: configuration.prefix, key: configuration.key, assets: configuration.assets, @@ -53,6 +54,9 @@ final class Configuration { /// The package name. final String? package; + /// True if dart docs should be generated. + final bool docs; + /// The class prefix. final String prefix; @@ -71,6 +75,7 @@ final class Configuration { /// Creates a [Configuration]. Configuration({ required this.package, + required this.docs, required this.prefix, required this.key, required this.assets, diff --git a/nitrogen/lib/src/file_system.dart b/nitrogen/lib/src/file_system.dart index 788d364..5d047e9 100644 --- a/nitrogen/lib/src/file_system.dart +++ b/nitrogen/lib/src/file_system.dart @@ -1,6 +1,6 @@ import 'dart:collection'; -import 'package:nitrogen_types/nitrogen_types.dart'; +import 'package:nitrogen_types/assets.dart'; import 'package:path/path.dart'; /// An entity in the file system. diff --git a/nitrogen/lib/src/generators/asset_generator.dart b/nitrogen/lib/src/generators/asset_generator.dart index 1094d6a..c0a8d4e 100644 --- a/nitrogen/lib/src/generators/asset_generator.dart +++ b/nitrogen/lib/src/generators/asset_generator.dart @@ -1,5 +1,6 @@ import 'package:code_builder/code_builder.dart'; -import 'package:nitrogen_types/nitrogen_types.dart'; +import 'package:meta/meta.dart' show visibleForOverriding; +import 'package:nitrogen_types/assets.dart'; import 'package:sugar/sugar.dart'; import 'package:nitrogen/src/file_system.dart'; @@ -13,10 +14,11 @@ class AssetGenerator { final Set _excluded; /// Creates a [AssetGenerator]. - AssetGenerator(String prefix, this._assets, this._excluded): + AssetGenerator(String prefix, this._assets, this._excluded, {required bool docs}): _standardClass = AssetClass( directories: AssetDirectoryExpressions(prefix), excluded: _excluded, + docs: docs, ); /// Generates basic asset classes. @@ -48,15 +50,45 @@ class AssetClass extends BasicAssetClass { static final assetType = refer('Asset', 'package:nitrogen_types/nitrogen_types.dart'); /// Creates a [AssetClass]. - const AssetClass({required super.directories, super.excluded, super.files}); + const AssetClass({required super.directories, required super.docs, super.excluded, super.files}); + + /// Generates the documentation for [directory]. + @visibleForOverriding + String generateDocs(AssetDirectory directory) => ''' +/// Contains the assets and nested directories in the `${directory.path.join('/')}` directory. +/// +/// Besides the assets and nested directories, it also provides a [contents] for querying the assets in the current +/// directory. +/// +/// To convert an asset into a widget, [call the asset like a function](https://dart.dev/language/callable-objects]. +/// ```dart +/// final widget = ${directories.type(directory).symbol!}.path.to.asset(); +/// ``` +/// +/// The `call(...)` functions are provided by extensions. By default, only the [ImageAsset] extension is bundled. +/// +/// 3rd party packages are supported via 'extension' packages. `extension` packages contain an `extension` that provide a +/// `call(...)` function that transforms an `Asset` into a 3rd party type. +/// +/// | Type | Package | Extension Package | Version | +/// |-------------------|---------------|------------------------|----------------------------------------------------------------------------------------------------------------| +/// | SVG images | `flutter_svg` | `nitrogen_flutter_svg` | [![Pub Dev](https://img.shields.io/pub/v/nitrogen_flutter_svg)](https://pub.dev/packages/nitrogen_flutter_svg) | +/// | Lottie animations | `lottie` | `nitrogen_lottie` | [![Pub Dev](https://img.shields.io/pub/v/nitrogen_lottie)](https://pub.dev/packages/nitrogen_lottie) |'''; /// Generates a basic class that contains only nested folders and assets. @override ClassBuilder generate(AssetDirectory directory, {bool static = false}) => super.generate(directory, static: static) + ..docs.addAll([ + if (docs) + generateDocs(directory), + ]) ..methods.add(_contents(directory, static: static)); - /// Returns a Method _contents(AssetDirectory directory, {bool static = false}) => Method((builder) => builder + ..docs.addAll([ + if (docs) + '/// The contents of this directory.', + ]) ..static = static ..returns = TypeReference((builder) => builder..symbol = 'Map'..types.addAll([refer('String'), assetType])) ..type = MethodType.getter @@ -81,10 +113,13 @@ class BasicAssetClass { final AssetDirectoryExpressions directories; /// The file expressions. final AssetFileExpressions files; + /// True if dart docs should be generated. + final bool docs; /// Creates a [BasicAssetClass]. const BasicAssetClass({ required this.directories, + required this.docs, this.excluded = const {}, this.files = const AssetFileExpressions(), }); @@ -103,6 +138,10 @@ class BasicAssetClass { /// Returns a getter for the nested [directory]. Method _assetDirectoryGetter(AssetDirectory directory, {bool static = false}) => Method((builder) => builder + ..docs.addAll([ + if (docs) + '/// The `${directory.path.join('/')}` directory.' + ]) ..static = static ..returns = directories.type(directory) ..type = MethodType.getter @@ -113,6 +152,10 @@ class BasicAssetClass { /// Returns a getter for the nested [file]. Method _assetFileGetter(AssetFile file, {bool static = false}) => Method((builder) => builder + ..docs.addAll([ + if (docs) + '/// The `${file.path.join('/')}`.' + ]) ..static = static ..returns = files.type(file) ..type = MethodType.getter diff --git a/nitrogen/lib/src/generators/theme_generator.dart b/nitrogen/lib/src/generators/theme_generator.dart index c170111..0a9ae96 100644 --- a/nitrogen/lib/src/generators/theme_generator.dart +++ b/nitrogen/lib/src/generators/theme_generator.dart @@ -15,18 +15,18 @@ class ThemeGenerator { static int _name((String, int) a, (String, int) b) => a.$1.compareTo(b.$1); final ThemeExtension _extension; - final AssetClass _fallbackClass; - final AssetClass _themeSubclass; + final FallbackAssetClass _fallbackClass; + final FallbackAssetClass _themeSubclass; final ThemeClass _themeClass; final AssetDirectory _themes; final AssetDirectory _fallbackTheme; /// Creates a [ThemeGenerator]. - ThemeGenerator(String prefix, this._themes, this._fallbackTheme): + ThemeGenerator(String prefix, this._themes, this._fallbackTheme, {required bool docs}): _extension = ThemeExtension(prefix), - _fallbackClass = AssetClass(directories: FallbackAssetDirectoryExpressions(prefix, _fallbackTheme)), - _themeSubclass = AssetClass(directories: ThemeAssetDirectoryExpressions(prefix, _themes)), - _themeClass = ThemeClass(ThemeAssetDirectoryExpressions(prefix, _themes)); + _fallbackClass = FallbackAssetClass(directories: FallbackAssetDirectoryExpressions(prefix, _fallbackTheme), docs: docs), + _themeSubclass = FallbackAssetClass(directories: ThemeAssetDirectoryExpressions(prefix, _themes), docs: docs), + _themeClass = ThemeClass(ThemeAssetDirectoryExpressions(prefix, _themes), docs: docs); /// Generates themed asset classes. String generate() { @@ -103,21 +103,83 @@ class ThemeExtension { } +/// Contains functions for generating a standard class representation of a directory with theme-specific documentation. +class FallbackAssetClass extends AssetClass { + + /// Creates a [FallbackAssetClass]. + FallbackAssetClass({required super.directories, required super.docs}); + + @override + String generateDocs(AssetDirectory directory) => ''' +/// The fallback theme's assets. +/// +/// Contains the assets in the `${directory.path.join('/')}` directory that serve as a fallback for when a theme does not +/// contain those specific assets. +/// +/// To convert an asset into a widget, [call the asset like a function](https://dart.dev/language/callable-objects]. +/// ```dart +/// final widget = ${directories.type(directory).symbol!}.path.to.asset(); +/// ``` +/// +/// The `call(...)` functions are provided by extensions. By default, only the [ImageAsset] extension is bundled. +/// +/// 3rd party packages are supported via 'extension' packages. `extension` packages contain an `extension` that provide a +/// `call(...)` function that transforms an `Asset` into a 3rd party type. +/// +/// | Type | Package | Extension Package | Version | +/// |-------------------|---------------|------------------------|----------------------------------------------------------------------------------------------------------------| +/// | SVG images | `flutter_svg` | `nitrogen_flutter_svg` | [![Pub Dev](https://img.shields.io/pub/v/nitrogen_flutter_svg)](https://pub.dev/packages/nitrogen_flutter_svg) | +/// | Lottie animations | `lottie` | `nitrogen_lottie` | [![Pub Dev](https://img.shields.io/pub/v/nitrogen_lottie)](https://pub.dev/packages/nitrogen_lottie) |'''; + +} + /// Contains functions for generating a theme class representation of a directory. class ThemeClass { + final ThemeAssetDirectoryExpressions _directories; final BasicAssetClass _assets; + final bool _docs; /// Creates a [ThemeClass]. - ThemeClass(AssetDirectoryExpressions directories): _assets = BasicAssetClass(directories: directories); + ThemeClass(ThemeAssetDirectoryExpressions directories, {required bool docs}): + _directories = directories, + _assets = BasicAssetClass(directories: directories, docs: docs), + _docs = docs; /// Generates a theme class that extends [fallback]. ClassBuilder generate(AssetDirectory directory, Class fallback) => _assets.generate(directory) + ..docs.addAll([ + if (_docs) + ''' +/// A `${_directories.theme(directory)}` theme's directory. +/// +/// Contains the assets in the `${directory.path.join('/')}` directory that serve as a fallback for when a theme does not +/// contain those specific assets. +/// +/// To convert an asset into a widget, [call the asset like a function](https://dart.dev/language/callable-objects]. +/// ```dart +/// final widget = ${_directories.type(directory).symbol!}.path.to.asset(); +/// ``` +/// +/// The `call(...)` functions are provided by extensions. By default, only the [ImageAsset] extension is bundled. +/// +/// 3rd party packages are supported via 'extension' packages. `extension` packages contain an `extension` that provide a +/// `call(...)` function that transforms an `Asset` into a 3rd party type. +/// +/// | Type | Package | Extension Package | Version | +/// |-------------------|---------------|------------------------|----------------------------------------------------------------------------------------------------------------| +/// | SVG images | `flutter_svg` | `nitrogen_flutter_svg` | [![Pub Dev](https://img.shields.io/pub/v/nitrogen_flutter_svg)](https://pub.dev/packages/nitrogen_flutter_svg) | +/// | Lottie animations | `lottie` | `nitrogen_lottie` | [![Pub Dev](https://img.shields.io/pub/v/nitrogen_lottie)](https://pub.dev/packages/nitrogen_lottie) |''', + ]) ..extend = refer(fallback.name) ..modifier = ClassModifier.final$ ..methods.add(_contents(directory, fallback)); Method _contents(AssetDirectory directory, Class fallback, {bool static = false}) => Method((builder) => builder + ..docs.addAll([ + if (_docs) + '/// The contents of this directory.', + ]) ..static = static ..returns = TypeReference((builder) => builder..symbol = 'Map'..types.addAll([refer('String'), AssetClass.assetType])) ..type = MethodType.getter @@ -161,7 +223,10 @@ class ThemeAssetDirectoryExpressions extends AssetDirectoryExpressions { @override Reference type(AssetDirectory directory) { final path = directory.path.sublist(_themes.path.length + 1); - return refer('${path.isEmpty ? '' : r'$'}${directory.path[_themes.path.length].toPascalCase()}${prefix}ThemeAssets${path.join('-').toPascalCase()}'); + return refer('${path.isEmpty ? '' : r'$'}${theme(directory).toPascalCase()}${prefix}ThemeAssets${path.join('-').toPascalCase()}'); } + /// The theme. + String theme(AssetDirectory directory) => directory.path[_themes.path.length]; + } diff --git a/nitrogen/lib/src/walker.dart b/nitrogen/lib/src/walker.dart index d371d27..8487174 100644 --- a/nitrogen/lib/src/walker.dart +++ b/nitrogen/lib/src/walker.dart @@ -1,7 +1,7 @@ import 'dart:collection'; import 'package:build/build.dart'; -import 'package:nitrogen_types/nitrogen_types.dart'; +import 'package:nitrogen_types/assets.dart'; import 'package:nitrogen/src/file_system.dart'; diff --git a/nitrogen/pubspec.yaml b/nitrogen/pubspec.yaml index 653ae12..74867a1 100644 --- a/nitrogen/pubspec.yaml +++ b/nitrogen/pubspec.yaml @@ -2,13 +2,13 @@ name: nitrogen description: Type safe Flutter asset generation. topics: [assets, generation] -version: 0.2.0 +version: 0.3.0+1 homepage: https://github.com/forus-labs/cauldron/tree/master/nitrogen repository: https://github.com/forus-labs/cauldron/ environment: sdk: '>=3.3.0 <4.0.0' - flutter: ">=3.3.0" + flutter: ">=3.22.0" dependencies: build: ^2.4.1 @@ -19,7 +19,7 @@ dependencies: sdk: flutter glob: ^2.1.2 meta: ^1.9.1 - nitrogen_types: ^0.2.0 + nitrogen_types: ^0.3.0+1 path: ^1.9.0 sugar: ^3.0.0 yaml: ^3.1.2 @@ -30,9 +30,5 @@ dev_dependencies: import_sorter: ^4.6.0 test: ^1.25.2 -dependency_overrides: - nitrogen_types: - path: ../nitrogen_types - import_sorter: comments: false diff --git a/nitrogen/test/src/configuration/build_configuration_test.dart b/nitrogen/test/src/configuration/build_configuration_test.dart index a0ac110..054305a 100644 --- a/nitrogen/test/src/configuration/build_configuration_test.dart +++ b/nitrogen/test/src/configuration/build_configuration_test.dart @@ -1,14 +1,13 @@ import 'package:build/build.dart'; import 'package:build_test/build_test.dart'; -import 'package:test/test.dart'; -import 'package:yaml/yaml.dart'; - import 'package:nitrogen/src/configuration/build_configuration.dart'; import 'package:nitrogen/src/configuration/key.dart'; -import 'package:nitrogen/src/nitrogen_exception.dart'; +import 'package:test/test.dart'; +import 'package:yaml/yaml.dart'; const valid = ''' package: true +docs: false prefix: 'MyPrefix' key: grpc-enum assets: @@ -49,14 +48,7 @@ void main() { group('parseAssets(...)', () { test('valid configuration', () => expect(BuildConfiguration.parseAssets({ 'output': 'valid' }).output, 'valid')); - test('invalid configuration', () { - expectLater( - log.onRecord, - emits(severeLogOf(contains("Unable to read assets configuration in build.yaml's nitrogen configuration. See https://github.com/forus-labs/cauldron/tree/master/nitrogen#assets."))), - ); - - expect(() => BuildConfiguration.parseAssets({}), throwsA(isA())); - }); + test('empty configuration', () => expect(BuildConfiguration.parseAssets({}).output, 'lib/src/assets.nitrogen.dart')); }); group('parseThemes(...)', () { @@ -68,14 +60,10 @@ void main() { test('no fallback', () => expect(BuildConfiguration.parseThemes({ 'output': 'valid-output' }), null)); - test('invalid configuration', () { - expectLater( - log.onRecord, - emits(severeLogOf(contains("Unable to read themes configuration in build.yaml's nitrogen configuration. See https://github.com/forus-labs/cauldron/tree/master/nitrogen#themes."))), - ); - - expect(() => BuildConfiguration.parseThemes({}), throwsA(isA())); - }); + test('no output', () => expect( + BuildConfiguration.parseThemes({ 'fallback': 'valid-fallback'})?.output, + 'lib/src/asset_themes.nitrogen.dart', + )); }); group('parse(...)', () { @@ -83,6 +71,7 @@ void main() { final configuration = BuildConfiguration.parse(loadYaml(valid)); expect(configuration.package, true); + expect(configuration.docs, false); expect(configuration.prefix, 'MyPrefix'); expect(configuration.key, Key.grpcEnum); expect(configuration.assets.output, 'foo-output'); diff --git a/nitrogen/test/src/configuration/configuration_test.dart b/nitrogen/test/src/configuration/configuration_test.dart index 6549e0f..09738dd 100644 --- a/nitrogen/test/src/configuration/configuration_test.dart +++ b/nitrogen/test/src/configuration/configuration_test.dart @@ -27,6 +27,7 @@ assets: void main() { final buildConfiguration = BuildConfiguration( package: true, + docs: false, prefix: 'MyPrefix', key: Key.grpcEnum, assets: (output: 'foo-output'), diff --git a/nitrogen/test/src/file_system_test.dart b/nitrogen/test/src/file_system_test.dart index cc5aeb6..ba6fd69 100644 --- a/nitrogen/test/src/file_system_test.dart +++ b/nitrogen/test/src/file_system_test.dart @@ -1,4 +1,4 @@ -import 'package:nitrogen_types/nitrogen_types.dart'; +import 'package:nitrogen_types/assets.dart'; import 'package:test/test.dart'; import 'package:nitrogen/src/file_system.dart'; diff --git a/nitrogen/test/src/generators/asset_generator_test.dart b/nitrogen/test/src/generators/asset_generator_test.dart index 042a352..87e8449 100644 --- a/nitrogen/test/src/generators/asset_generator_test.dart +++ b/nitrogen/test/src/generators/asset_generator_test.dart @@ -1,13 +1,107 @@ import 'package:code_builder/code_builder.dart'; import 'package:dart_style/dart_style.dart'; -import 'package:nitrogen_types/nitrogen_types.dart'; +import 'package:nitrogen_types/assets.dart'; import 'package:test/test.dart'; import 'package:nitrogen/src/file_system.dart'; import 'package:nitrogen/src/generators/asset_generator.dart'; -const _classes = r''' -import 'package:nitrogen_types/nitrogen_types.dart'; +const _classesDocs = r''' +import 'package:nitrogen_types/assets.dart'; + +// GENERATED CODE - DO NOT MODIFY BY HAND +// +// ************************************************************************** +// nitrogen +// ************************************************************************** +// +// ignore_for_file: type=lint +// ignore_for_file: deprecated_member_use + +/// Contains the assets and nested directories in the `path/to/directory` directory. +/// +/// Besides the assets and nested directories, it also provides a [contents] for querying the assets in the current +/// directory. +/// +/// To convert an asset into a widget, [call the asset like a function](https://dart.dev/language/callable-objects]. +/// ```dart +/// final widget = $PrefixPathToDirectory.path.to.asset(); +/// ``` +/// +/// The `call(...)` functions are provided by extensions. By default, only the [ImageAsset] extension is bundled. +/// +/// 3rd party packages are supported via 'extension' packages. `extension` packages contain an `extension` that provide a +/// `call(...)` function that transforms an `Asset` into a 3rd party type. +/// +/// | Type | Package | Extension Package | Version | +/// |-------------------|---------------|------------------------|----------------------------------------------------------------------------------------------------------------| +/// | SVG images | `flutter_svg` | `nitrogen_flutter_svg` | [![Pub Dev](https://img.shields.io/pub/v/nitrogen_flutter_svg)](https://pub.dev/packages/nitrogen_flutter_svg) | +/// | Lottie animations | `lottie` | `nitrogen_lottie` | [![Pub Dev](https://img.shields.io/pub/v/nitrogen_lottie)](https://pub.dev/packages/nitrogen_lottie) | +class $PrefixPathToDirectory { + const $PrefixPathToDirectory(); + + /// The `path/to/directory/subdirectory` directory. + static $PrefixPathToDirectorySubdirectory get subdirectory => const $PrefixPathToDirectorySubdirectory(); + + /// The `path/to/directory/bar.txt`. + static GenericAsset get bar => const GenericAsset( + 'test_package', + 'bar', + 'path/to/directory/bar.txt', + ); + + /// The contents of this directory. + static Map get contents => const { + 'bar': const GenericAsset( + 'test_package', + 'bar', + 'path/to/directory/bar.txt', + ), + }; +} + +/// Contains the assets and nested directories in the `path/to/directory/subdirectory` directory. +/// +/// Besides the assets and nested directories, it also provides a [contents] for querying the assets in the current +/// directory. +/// +/// To convert an asset into a widget, [call the asset like a function](https://dart.dev/language/callable-objects]. +/// ```dart +/// final widget = $PrefixPathToDirectorySubdirectory.path.to.asset(); +/// ``` +/// +/// The `call(...)` functions are provided by extensions. By default, only the [ImageAsset] extension is bundled. +/// +/// 3rd party packages are supported via 'extension' packages. `extension` packages contain an `extension` that provide a +/// `call(...)` function that transforms an `Asset` into a 3rd party type. +/// +/// | Type | Package | Extension Package | Version | +/// |-------------------|---------------|------------------------|----------------------------------------------------------------------------------------------------------------| +/// | SVG images | `flutter_svg` | `nitrogen_flutter_svg` | [![Pub Dev](https://img.shields.io/pub/v/nitrogen_flutter_svg)](https://pub.dev/packages/nitrogen_flutter_svg) | +/// | Lottie animations | `lottie` | `nitrogen_lottie` | [![Pub Dev](https://img.shields.io/pub/v/nitrogen_lottie)](https://pub.dev/packages/nitrogen_lottie) | +class $PrefixPathToDirectorySubdirectory { + const $PrefixPathToDirectorySubdirectory(); + + /// The `path/to/directory/subdirectory/foo.png`. + ImageAsset get foo => const ImageAsset( + 'test_package', + 'foo', + 'path/to/directory/subdirectory/foo.png', + ); + + /// The contents of this directory. + Map get contents => const { + 'foo': const ImageAsset( + 'test_package', + 'foo', + 'path/to/directory/subdirectory/foo.png', + ), + }; +} +'''; + +const _classesNoDocs = r''' +import 'package:nitrogen_types/assets.dart'; // GENERATED CODE - DO NOT MODIFY BY HAND // @@ -178,29 +272,36 @@ void main() { const GenericAsset('test_package', 'bar', 'path/to/directory/bar.txt'), ); - test('AssetGenerator', () { - final generator = AssetGenerator('Prefix', directory, {}); - expect(formatter.format(generator.generate()), _classes); + group('AssetGenerator', () { + test('docs', () { + final generator = AssetGenerator('Prefix', directory, {}, docs: true); + expect(formatter.format(generator.generate()), _classesDocs); + }); + + test('no docs', () { + final generator = AssetGenerator('Prefix', directory, {}, docs: false); + expect(formatter.format(generator.generate()), _classesNoDocs); + }); }); group('AssetClass', () { group('generate(...)', () { test('non static', () { - const basic = AssetClass(directories: AssetDirectoryExpressions('Prefix')); + const basic = AssetClass(docs: false, directories: AssetDirectoryExpressions('Prefix')); final type = basic.generate(directory).build(); expect(formatter.format(type.accept(emitter).toString()), formatter.format(_nonStaticAssetClass)); }); test('static', () { - const basic = AssetClass(directories: AssetDirectoryExpressions('Prefix')); + const basic = AssetClass(docs: false, directories: AssetDirectoryExpressions('Prefix')); final type = basic.generate(directory, static: true).build(); expect(formatter.format(type.accept(emitter).toString()), formatter.format(_staticAssetClass)); }); test('excluded', () { - final basic = AssetClass(directories: const AssetDirectoryExpressions('Prefix'), excluded: { subdirectory }); + final basic = AssetClass(docs: false, directories: const AssetDirectoryExpressions('Prefix'), excluded: { subdirectory }); final type = basic.generate(directory).build(); expect(formatter.format(type.accept(emitter).toString()), formatter.format(_excludedAssetClass)); @@ -211,21 +312,21 @@ void main() { group('BasicAssetClass', () { group('generate(...)', () { test('non static', () { - const basic = BasicAssetClass(directories: AssetDirectoryExpressions('Prefix')); + const basic = BasicAssetClass(docs: false, directories: AssetDirectoryExpressions('Prefix')); final type = basic.generate(directory).build(); expect(formatter.format(type.accept(emitter).toString()), formatter.format(_nonStaticBasicClass)); }); test('static', () { - const basic = BasicAssetClass(directories: AssetDirectoryExpressions('Prefix')); + const basic = BasicAssetClass(docs: false, directories: AssetDirectoryExpressions('Prefix')); final type = basic.generate(directory, static: true).build(); expect(formatter.format(type.accept(emitter).toString()), formatter.format(_staticBasicClass)); }); test('excluded', () { - final basic = BasicAssetClass(directories: const AssetDirectoryExpressions('Prefix'), excluded: { subdirectory }); + final basic = BasicAssetClass(docs: false, directories: const AssetDirectoryExpressions('Prefix'), excluded: { subdirectory }); final type = basic.generate(directory).build(); expect(formatter.format(type.accept(emitter).toString()), formatter.format(_excludedBasicClass)); diff --git a/nitrogen/test/src/generators/theme_generator_test.dart b/nitrogen/test/src/generators/theme_generator_test.dart index 5f221f7..01175df 100644 --- a/nitrogen/test/src/generators/theme_generator_test.dart +++ b/nitrogen/test/src/generators/theme_generator_test.dart @@ -1,12 +1,252 @@ import 'package:code_builder/code_builder.dart'; -import 'package:nitrogen_types/nitrogen_types.dart'; +import 'package:nitrogen_types/assets.dart'; import 'package:test/test.dart'; import 'package:nitrogen/src/file_system.dart'; import 'package:nitrogen/src/generators/theme_generator.dart'; -const _classes = r''' -import 'package:nitrogen_types/nitrogen_types.dart'; +const _classesDocs = r''' +import 'package:nitrogen_types/assets.dart'; + +// GENERATED CODE - DO NOT MODIFY BY HAND +// +// ************************************************************************** +// nitrogen +// ************************************************************************** +// +// ignore_for_file: type=lint +// ignore_for_file: deprecated_member_use + +extension PrefixAssetTheme on Never { + static DarkPrefixThemeAssets get dark => DarkPrefixThemeAssets(); + static LightPrefixThemeAssets get light => LightPrefixThemeAssets(); +} + +/// The fallback theme's assets. +/// +/// Contains the assets in the `path/to/themes/light` directory that serve as a fallback for when a theme does not +/// contain those specific assets. +/// +/// To convert an asset into a widget, [call the asset like a function](https://dart.dev/language/callable-objects]. +/// ```dart +/// final widget = PrefixThemeAssets.path.to.asset(); +/// ``` +/// +/// The `call(...)` functions are provided by extensions. By default, only the [ImageAsset] extension is bundled. +/// +/// 3rd party packages are supported via 'extension' packages. `extension` packages contain an `extension` that provide a +/// `call(...)` function that transforms an `Asset` into a 3rd party type. +/// +/// | Type | Package | Extension Package | Version | +/// |-------------------|---------------|------------------------|----------------------------------------------------------------------------------------------------------------| +/// | SVG images | `flutter_svg` | `nitrogen_flutter_svg` | [![Pub Dev](https://img.shields.io/pub/v/nitrogen_flutter_svg)](https://pub.dev/packages/nitrogen_flutter_svg) | +/// | Lottie animations | `lottie` | `nitrogen_lottie` | [![Pub Dev](https://img.shields.io/pub/v/nitrogen_lottie)](https://pub.dev/packages/nitrogen_lottie) | +class PrefixThemeAssets { + const PrefixThemeAssets(); + + /// The `path/to/themes/light/subdirectory` directory. + $PrefixThemeAssetsSubdirectory get subdirectory => const $PrefixThemeAssetsSubdirectory(); + + /// The `path/to/themes/light/foo.png`. + ImageAsset get foo => const ImageAsset( + 'test_package', + 'foo', + 'path/to/themes/light/foo.png', + ); + + /// The contents of this directory. + Map get contents => const { + 'foo': const ImageAsset( + 'test_package', + 'foo', + 'path/to/themes/light/foo.png', + ), + }; +} + +/// The fallback theme's assets. +/// +/// Contains the assets in the `path/to/themes/light/subdirectory` directory that serve as a fallback for when a theme does not +/// contain those specific assets. +/// +/// To convert an asset into a widget, [call the asset like a function](https://dart.dev/language/callable-objects]. +/// ```dart +/// final widget = $PrefixThemeAssetsSubdirectory.path.to.asset(); +/// ``` +/// +/// The `call(...)` functions are provided by extensions. By default, only the [ImageAsset] extension is bundled. +/// +/// 3rd party packages are supported via 'extension' packages. `extension` packages contain an `extension` that provide a +/// `call(...)` function that transforms an `Asset` into a 3rd party type. +/// +/// | Type | Package | Extension Package | Version | +/// |-------------------|---------------|------------------------|----------------------------------------------------------------------------------------------------------------| +/// | SVG images | `flutter_svg` | `nitrogen_flutter_svg` | [![Pub Dev](https://img.shields.io/pub/v/nitrogen_flutter_svg)](https://pub.dev/packages/nitrogen_flutter_svg) | +/// | Lottie animations | `lottie` | `nitrogen_lottie` | [![Pub Dev](https://img.shields.io/pub/v/nitrogen_lottie)](https://pub.dev/packages/nitrogen_lottie) | +class $PrefixThemeAssetsSubdirectory { + const $PrefixThemeAssetsSubdirectory(); + + /// The contents of this directory. + Map get contents => const {}; +} + +/// A `dark` theme's directory. +/// +/// Contains the assets in the `path/to/themes/dark` directory that serve as a fallback for when a theme does not +/// contain those specific assets. +/// +/// To convert an asset into a widget, [call the asset like a function](https://dart.dev/language/callable-objects]. +/// ```dart +/// final widget = DarkPrefixThemeAssets.path.to.asset(); +/// ``` +/// +/// The `call(...)` functions are provided by extensions. By default, only the [ImageAsset] extension is bundled. +/// +/// 3rd party packages are supported via 'extension' packages. `extension` packages contain an `extension` that provide a +/// `call(...)` function that transforms an `Asset` into a 3rd party type. +/// +/// | Type | Package | Extension Package | Version | +/// |-------------------|---------------|------------------------|----------------------------------------------------------------------------------------------------------------| +/// | SVG images | `flutter_svg` | `nitrogen_flutter_svg` | [![Pub Dev](https://img.shields.io/pub/v/nitrogen_flutter_svg)](https://pub.dev/packages/nitrogen_flutter_svg) | +/// | Lottie animations | `lottie` | `nitrogen_lottie` | [![Pub Dev](https://img.shields.io/pub/v/nitrogen_lottie)](https://pub.dev/packages/nitrogen_lottie) | +final class DarkPrefixThemeAssets extends PrefixThemeAssets { + const DarkPrefixThemeAssets(); + + /// The `path/to/themes/dark/subdirectory` directory. + $DarkPrefixThemeAssetsSubdirectory get subdirectory => const $DarkPrefixThemeAssetsSubdirectory(); + + /// The `path/to/themes/dark/bar.txt`. + GenericAsset get bar => const GenericAsset( + 'test_package', + 'bar', + 'path/to/themes/dark/bar.txt', + ); + + /// The `path/to/themes/dark/foo.png`. + GenericAsset get foo => const GenericAsset( + 'test_package', + 'foo', + 'path/to/themes/dark/foo.png', + ); + + /// The contents of this directory. + Map get contents => Map.unmodifiable({ + ...const PrefixThemeAssets().contents, + 'bar': const GenericAsset( + 'test_package', + 'bar', + 'path/to/themes/dark/bar.txt', + ), + 'foo': const GenericAsset( + 'test_package', + 'foo', + 'path/to/themes/dark/foo.png', + ), + }); +} + +/// A `dark` theme's directory. +/// +/// Contains the assets in the `path/to/themes/dark/subdirectory` directory that serve as a fallback for when a theme does not +/// contain those specific assets. +/// +/// To convert an asset into a widget, [call the asset like a function](https://dart.dev/language/callable-objects]. +/// ```dart +/// final widget = $DarkPrefixThemeAssetsSubdirectory.path.to.asset(); +/// ``` +/// +/// The `call(...)` functions are provided by extensions. By default, only the [ImageAsset] extension is bundled. +/// +/// 3rd party packages are supported via 'extension' packages. `extension` packages contain an `extension` that provide a +/// `call(...)` function that transforms an `Asset` into a 3rd party type. +/// +/// | Type | Package | Extension Package | Version | +/// |-------------------|---------------|------------------------|----------------------------------------------------------------------------------------------------------------| +/// | SVG images | `flutter_svg` | `nitrogen_flutter_svg` | [![Pub Dev](https://img.shields.io/pub/v/nitrogen_flutter_svg)](https://pub.dev/packages/nitrogen_flutter_svg) | +/// | Lottie animations | `lottie` | `nitrogen_lottie` | [![Pub Dev](https://img.shields.io/pub/v/nitrogen_lottie)](https://pub.dev/packages/nitrogen_lottie) | +final class $DarkPrefixThemeAssetsSubdirectory extends $PrefixThemeAssetsSubdirectory { + const $DarkPrefixThemeAssetsSubdirectory(); + + /// The contents of this directory. + Map get contents => Map.unmodifiable({ + ...const $PrefixThemeAssetsSubdirectory().contents, + }); +} + +/// A `light` theme's directory. +/// +/// Contains the assets in the `path/to/themes/light` directory that serve as a fallback for when a theme does not +/// contain those specific assets. +/// +/// To convert an asset into a widget, [call the asset like a function](https://dart.dev/language/callable-objects]. +/// ```dart +/// final widget = LightPrefixThemeAssets.path.to.asset(); +/// ``` +/// +/// The `call(...)` functions are provided by extensions. By default, only the [ImageAsset] extension is bundled. +/// +/// 3rd party packages are supported via 'extension' packages. `extension` packages contain an `extension` that provide a +/// `call(...)` function that transforms an `Asset` into a 3rd party type. +/// +/// | Type | Package | Extension Package | Version | +/// |-------------------|---------------|------------------------|----------------------------------------------------------------------------------------------------------------| +/// | SVG images | `flutter_svg` | `nitrogen_flutter_svg` | [![Pub Dev](https://img.shields.io/pub/v/nitrogen_flutter_svg)](https://pub.dev/packages/nitrogen_flutter_svg) | +/// | Lottie animations | `lottie` | `nitrogen_lottie` | [![Pub Dev](https://img.shields.io/pub/v/nitrogen_lottie)](https://pub.dev/packages/nitrogen_lottie) | +final class LightPrefixThemeAssets extends PrefixThemeAssets { + const LightPrefixThemeAssets(); + + /// The `path/to/themes/light/subdirectory` directory. + $LightPrefixThemeAssetsSubdirectory get subdirectory => const $LightPrefixThemeAssetsSubdirectory(); + + /// The `path/to/themes/light/foo.png`. + ImageAsset get foo => const ImageAsset( + 'test_package', + 'foo', + 'path/to/themes/light/foo.png', + ); + + /// The contents of this directory. + Map get contents => Map.unmodifiable({ + ...const PrefixThemeAssets().contents, + 'foo': const ImageAsset( + 'test_package', + 'foo', + 'path/to/themes/light/foo.png', + ), + }); +} + +/// A `light` theme's directory. +/// +/// Contains the assets in the `path/to/themes/light/subdirectory` directory that serve as a fallback for when a theme does not +/// contain those specific assets. +/// +/// To convert an asset into a widget, [call the asset like a function](https://dart.dev/language/callable-objects]. +/// ```dart +/// final widget = $LightPrefixThemeAssetsSubdirectory.path.to.asset(); +/// ``` +/// +/// The `call(...)` functions are provided by extensions. By default, only the [ImageAsset] extension is bundled. +/// +/// 3rd party packages are supported via 'extension' packages. `extension` packages contain an `extension` that provide a +/// `call(...)` function that transforms an `Asset` into a 3rd party type. +/// +/// | Type | Package | Extension Package | Version | +/// |-------------------|---------------|------------------------|----------------------------------------------------------------------------------------------------------------| +/// | SVG images | `flutter_svg` | `nitrogen_flutter_svg` | [![Pub Dev](https://img.shields.io/pub/v/nitrogen_flutter_svg)](https://pub.dev/packages/nitrogen_flutter_svg) | +/// | Lottie animations | `lottie` | `nitrogen_lottie` | [![Pub Dev](https://img.shields.io/pub/v/nitrogen_lottie)](https://pub.dev/packages/nitrogen_lottie) | +final class $LightPrefixThemeAssetsSubdirectory extends $PrefixThemeAssetsSubdirectory { + const $LightPrefixThemeAssetsSubdirectory(); + + /// The contents of this directory. + Map get contents => Map.unmodifiable({ + ...const $PrefixThemeAssetsSubdirectory().contents, + }); +} +'''; + +const _classesNoDocs = r''' +import 'package:nitrogen_types/assets.dart'; // GENERATED CODE - DO NOT MODIFY BY HAND // @@ -143,11 +383,19 @@ void main() { themes.children['light'] = light; themes.children['dark'] = dark; - test('ThemeGenerator', () { - final generator = ThemeGenerator('Prefix', themes, light); - expect(generator.generate(), _classes); + group('ThemeGenerator', () { + test('docs', () { + final generator = ThemeGenerator('Prefix', themes, light, docs: true); + expect(generator.generate(), _classesDocs); + }); + + test('no docs', () { + final generator = ThemeGenerator('Prefix', themes, light, docs: false); + expect(generator.generate(), _classesNoDocs); + }); }); + group('FallbackAssetDirectoryExpressions', () { group('type(...)', () { test('root fallback theme directory', () { diff --git a/nitrogen/test/src/libraries_test.dart b/nitrogen/test/src/libraries_test.dart index 8575b5d..6554e15 100644 --- a/nitrogen/test/src/libraries_test.dart +++ b/nitrogen/test/src/libraries_test.dart @@ -12,7 +12,7 @@ void main() { expect(library.format(), equals( ''' -import 'package:nitrogen_types/nitrogen_types.dart'; +import 'package:nitrogen_types/assets.dart'; // GENERATED CODE - DO NOT MODIFY BY HAND // diff --git a/nitrogen/test/src/lints/reserved_keyword_lint_test.dart b/nitrogen/test/src/lints/reserved_keyword_lint_test.dart index f853963..48e010a 100644 --- a/nitrogen/test/src/lints/reserved_keyword_lint_test.dart +++ b/nitrogen/test/src/lints/reserved_keyword_lint_test.dart @@ -1,6 +1,6 @@ import 'package:build/build.dart'; import 'package:build_test/build_test.dart'; -import 'package:nitrogen_types/nitrogen_types.dart'; +import 'package:nitrogen_types/assets.dart'; import 'package:test/test.dart'; import 'package:nitrogen/src/file_system.dart'; diff --git a/nitrogen/test/src/walker_test.dart b/nitrogen/test/src/walker_test.dart index be491d3..c20f039 100644 --- a/nitrogen/test/src/walker_test.dart +++ b/nitrogen/test/src/walker_test.dart @@ -1,5 +1,5 @@ import 'package:build/build.dart'; -import 'package:nitrogen_types/nitrogen_types.dart'; +import 'package:nitrogen_types/assets.dart'; import 'package:test/test.dart'; import 'package:nitrogen/src/file_system.dart'; diff --git a/nitrogen_flutter_svg/CHANGELOG.md b/nitrogen_flutter_svg/CHANGELOG.md index 1a2a33a..125fce8 100644 --- a/nitrogen_flutter_svg/CHANGELOG.md +++ b/nitrogen_flutter_svg/CHANGELOG.md @@ -1,3 +1,6 @@ +## 0.3.0+1 +Fix outdated dependency on `nitrogen_types`. + ## 0.3.0 Export instead of generate extension. diff --git a/nitrogen_flutter_svg/build.yaml b/nitrogen_flutter_svg/build.yaml deleted file mode 100644 index 18d2223..0000000 --- a/nitrogen_flutter_svg/build.yaml +++ /dev/null @@ -1,17 +0,0 @@ -# Configuration for build runners. See https://github.com/dart-lang/build/blob/master/build_config/README.md - -targets: - $default: - sources: - - assets/** - - lib/$lib$ - - pubspec.* - - $package$ - -builders: - nitrogen_flutter_svg: - import: "package:nitrogen_flutter_svg/nitrogen_flutter_svg.dart" - builder_factories: [ "nitrogenFlutterSvgBuilder" ] - build_extensions: { "$package$": [ "lib/src/svg_extension.nitrogen.dart" ] } - auto_apply: dependents - build_to: source diff --git a/nitrogen_flutter_svg/pubspec.yaml b/nitrogen_flutter_svg/pubspec.yaml index 4f5db0c..abaff3f 100644 --- a/nitrogen_flutter_svg/pubspec.yaml +++ b/nitrogen_flutter_svg/pubspec.yaml @@ -12,11 +12,7 @@ dependencies: flutter: sdk: flutter flutter_svg: ^2.0.9 - nitrogen_types: ^0.2.0 + nitrogen_types: ^0.3.0+1 dev_dependencies: flint: ^2.7.0 - -dependency_overrides: - nitrogen_types: - path: ../nitrogen_types diff --git a/nitrogen_lottie/CHANGELOG.md b/nitrogen_lottie/CHANGELOG.md index 1a2a33a..125fce8 100644 --- a/nitrogen_lottie/CHANGELOG.md +++ b/nitrogen_lottie/CHANGELOG.md @@ -1,3 +1,6 @@ +## 0.3.0+1 +Fix outdated dependency on `nitrogen_types`. + ## 0.3.0 Export instead of generate extension. diff --git a/nitrogen_lottie/build.yaml b/nitrogen_lottie/build.yaml deleted file mode 100644 index 86c7598..0000000 --- a/nitrogen_lottie/build.yaml +++ /dev/null @@ -1,17 +0,0 @@ -# Configuration for build runners. See https://github.com/dart-lang/build/blob/master/build_config/README.md - -targets: - $default: - sources: - - assets/** - - lib/$lib$ - - pubspec.* - - $package$ - -builders: - nitrogen_flutter_svg: - import: "package:nitrogen_lottie/nitrogen_lottie.dart" - builder_factories: [ "nitrogenLottieBuilder" ] - build_extensions: { "$package$": [ "lib/src/lottie_extension.nitrogen.dart" ] } - auto_apply: dependents - build_to: source diff --git a/nitrogen_lottie/pubspec.yaml b/nitrogen_lottie/pubspec.yaml index 39a5be8..943d433 100644 --- a/nitrogen_lottie/pubspec.yaml +++ b/nitrogen_lottie/pubspec.yaml @@ -13,11 +13,7 @@ dependencies: flutter: sdk: flutter lottie: ^3.1.0 - nitrogen_types: ^0.2.0 + nitrogen_types: ^0.3.0+1 dev_dependencies: flint: ^2.7.0 - -dependency_overrides: - nitrogen: - path: ../nitrogen diff --git a/nitrogen_types/CHANGELOG.md b/nitrogen_types/CHANGELOG.md index 2fd725a..cc1112c 100644 --- a/nitrogen_types/CHANGELOG.md +++ b/nitrogen_types/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.3.0+1 + +Fix missing `assets` library. + + ## 0.3.0 Export `ImageAssetExtension`. diff --git a/nitrogen_types/lib/assets.dart b/nitrogen_types/lib/assets.dart new file mode 100644 index 0000000..4a25288 --- /dev/null +++ b/nitrogen_types/lib/assets.dart @@ -0,0 +1,4 @@ +/// This library exports only the assets. It is used by Nitrogen since builders cannot import Flutter. +library nitrogen_types.assets; + +export 'src/assets.dart'; \ No newline at end of file diff --git a/nitrogen_types/lib/src/assets.dart b/nitrogen_types/lib/src/assets.dart index d2fcec0..bd958b1 100644 --- a/nitrogen_types/lib/src/assets.dart +++ b/nitrogen_types/lib/src/assets.dart @@ -1,6 +1,6 @@ /// An asset in a Flutter project's assets directory. /// -/// **Note: ** +/// ## Note: /// This type should with [Nitrogen](https://github.com/forus-labs/cauldron/nitrogen), a type-safe asset generation tool. sealed class Asset { /// The containing package's name. @@ -16,7 +16,7 @@ sealed class Asset { /// An image. /// -/// **Note: ** +/// ## Note: /// This type should with [Nitrogen](https://github.com/forus-labs/cauldron/nitrogen), a type-safe asset generation tool. final class ImageAsset extends Asset { /// Creates a [ImageAsset]. @@ -40,7 +40,7 @@ final class ImageAsset extends Asset { /// A Lottie animation. /// -/// **Note: ** +/// ## Note: /// This type should with [Nitrogen](https://github.com/forus-labs/cauldron/nitrogen), a type-safe asset generation tool. final class LottieAsset extends Asset { /// Creates a [LottieAsset]. @@ -64,7 +64,7 @@ final class LottieAsset extends Asset { /// An SVG file. /// -/// **Note: ** +/// ## Note: /// This type should with [Nitrogen](https://github.com/forus-labs/cauldron/nitrogen), a type-safe asset generation tool. final class SvgAsset extends Asset { /// Creates a [SvgAsset]. @@ -89,7 +89,7 @@ final class SvgAsset extends Asset { /// A default asset for file extensions not directly supported by the other [Asset]s. /// -/// **Note: ** +/// ## Note: /// This type should with [Nitrogen](https://github.com/forus-labs/cauldron/nitrogen), a type-safe asset generation tool. final class GenericAsset extends Asset { /// Creates a [GenericAsset]. diff --git a/nitrogen_types/pubspec.yaml b/nitrogen_types/pubspec.yaml index 1af2ae2..9887399 100644 --- a/nitrogen_types/pubspec.yaml +++ b/nitrogen_types/pubspec.yaml @@ -1,7 +1,7 @@ name: nitrogen_types description: Companion library for Nitrogen. Provides shared types that generated bindings use. -version: 0.3.0 +version: 0.3.0+1 homepage: https://github.com/forus-labs/cauldron/tree/master/nitrogen repository: https://github.com/forus-labs/cauldron/