Clone this repo:
  1. eb2078f Bump the github-actions group with 2 updates (#102) by dependabot[bot] · 4 months ago main
  2. 4e1e9e5 Update README.md before archiving (#101) by Moritz · 5 months ago
  3. fbdc70a Bump dart-lang/setup-dart in the github-actions group (#100) by dependabot[bot] · 6 months ago
  4. 8bd0fdf Fix unused param in a private ctor lint (#99) by Kevin Moore · 6 months ago
  5. 3d1421b Bump the github-actions group across 1 directory with 2 updates (#98) by dependabot[bot] · 7 months ago

[!IMPORTANT]
This repo has moved to https://github.com/dart-lang/tools/tree/main/pkgs/yaml_edit

Dart CI pub package package publisher Coverage Status

A library for YAML manipulation while preserving comments.

Usage

A simple usage example:

import 'package:yaml_edit/yaml_edit.dart';

void main() {
  final yamlEditor = YamlEditor('{YAML: YAML}');
  yamlEditor.update(['YAML'], "YAML Ain't Markup Language");
  print(yamlEditor);
  // Expected output:
  // {YAML: YAML Ain't Markup Language}
}

Example: Converting JSON to YAML (block formatted)

void main() {
  final jsonString = r'''
{
  "key": "value",
  "list": [
    "first",
    "second",
    "last entry in the list"
  ],
  "map": {
    "multiline": "this is a fairly long string with\nline breaks..."
  }
}
''';
  final jsonValue = json.decode(jsonString);

  // Convert jsonValue to YAML
  final yamlEditor = YamlEditor('');
  yamlEditor.update([], jsonValue);
  print(yamlEditor.toString());
}

Testing

Testing is done in two strategies: Unit testing (/test/editor_test.dart) and Golden testing (/test/golden_test.dart). More information on Golden testing and the input/output format can be found at /test/testdata/README.md.

These tests are automatically run with pub run test.

Limitations

  1. Users are not allowed to define tags in the modifications.
  2. Map keys will always be added in the flow style.