dart-lang / yaml_edit

A library for YAML manipulation with comment and whitespace preservation.
https://pub.dev/packages/yaml_edit
BSD 3-Clause "New" or "Revised" License
27 stars 16 forks source link

Export ScalarStyle/CollectionStyle in order to be used with `wrapAsYamlNode` #13

Closed Schwusch closed 2 years ago

Schwusch commented 2 years ago

Right now it's a little hard to specify wrapAsYamlNode arguments like scalarStyle and collectionStyle, since they're not exported.

jonasfj commented 2 years ago

These are exported from package:yaml, see:

Feel free to file a PR improving the documentation.

Schwusch commented 2 years ago

Considering how I did not figure this out myself, I'd like to propose exporting package:yaml/yaml.dart in yaml_edit.dart. Either that, or exporting just the classes yaml_edit require but not provides itself, like ScalarStyle.

Requiring the user to know the underlying implementation and take further action than to just import yaml_edit is less user friendly. I added the package:yaml/yaml.dart export to yaml_edit.dart, and it works fine. Even when adding package:yaml as a dependency and importing it in the consuming code.

Just glancing quickly at the yaml_edit source code, I did not even realize that yaml_edit was dependent on yaml.

The resulting code in yaml_edit.dart would then become:

/// lot's of comments
library yaml_edit;

export 'package:yaml/yaml.dart'; // new export

export 'src/editor.dart';
export 'src/source_edit.dart';
export 'src/wrap.dart' show wrapAsYamlNode;

We do this in aws_client to improve the developer experience.