Skip to content

Commit

Permalink
Update readme, appveyor, logo...
Browse files Browse the repository at this point in the history
  • Loading branch information
xoofx committed Feb 12, 2019
1 parent dd73031 commit 762804d
Show file tree
Hide file tree
Showing 6 changed files with 139 additions and 2 deletions.
39 changes: 39 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
version: 11.0.{build}
image: Visual Studio 2017
configuration: Release
install:
- ps: >-
cd src
nuget restore Tomlyn.sln
$env:TOMLYN_BUILD_NUMBER = ([int]$env:APPVEYOR_BUILD_NUMBER).ToString("000")
$env:appveyor_nuget_push = 'false'
if(-Not $env:APPVEYOR_PULL_REQUEST_NUMBER) {
if($env:appveyor_repo_tag -eq 'True') {
if($env:appveyor_repo_tag_name -match '^v[0-9]') {
$env:appveyor_nuget_push = 'true'
}
}
}
build:
project: src/Tomlyn.sln
verbosity: minimal
before_package:
- cmd: >-
msbuild /t:pack /p:Configuration=Release Tomlyn/Tomlyn.csproj
msbuild /t:Clean Tomlyn/Tomlyn.csproj
msbuild /t:pack /p:Configuration=Release;SignAssembly=true Tomlyn/Tomlyn.csproj
artifacts:
- path: src\Tomlyn\Bin\Release\*.nupkg
name: Tomlyn Nugets
deploy:
- provider: NuGet
api_key:
secure: 7cthHh+wYWZjhqxaxR6QObRaRnstvFkQOY7MkxIsC5kpQEBlKZXuinf0IybbYxJt
on:
appveyor_nuget_push: true
5 changes: 5 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Changelog

## 0.1.0 (12 Feb 2019)

- Initial version (support for TOML 0.5)
Binary file modified img/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
71 changes: 69 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,77 @@
# Tomlyn
# Tomlyn [![Build status](https://ci.appveyor.com/api/projects/status/ig5kv8r63bqjsd9a?svg=true)](https://ci.appveyor.com/project/xoofx/Tomlyn) [![NuGet](https://img.shields.io/nuget/v/Tomlyn.svg)](https://www.nuget.org/packages/Tomlyn/)

<img align="right" width="160px" height="160px" src="img/logo.png">

Tomlyn is a TOML parser, validator and authoring library for .NET Framework and .NET Core

> NOTE: The library is under development and not available yet for public usage.
## Features

- Very fast parser, GC friendly
- Compatible with latest [TOML 0.5 specs](https://github.com/toml-lang/toml)
- Support perfect load/save roundtrip while preserving all spaces, new line, comments
- Provides a validator with the `Toml.Validate` method
- Allow to work on the syntax tree directly (preserving styles) through the `Toml.Parse`
- Allow to work with a runtime representation `Toml.ToModel` (but cannot be saved back to TOML)

## Usage

```C#
var input = @"[mytable]
key = 15
val = true
";

// Gets a syntax tree of the TOML text
var doc = Toml.Parse(input); // returns a DocumentSyntax
// Check for parsing errors with doc.HasErrors and doc.Diagnostics
// doc.HasErrors => throws an exception
// Prints the exact representation of the input
var docStr = doc.ToString();
Console.WriteLine(docStr);

// Gets a runtime representation of the syntax tree
var table = doc.ToModel();
var key = (long) ((TomlTable) table["mytable"])["key"];
var value = (bool) ((TomlTable) table["mytable"])["val"];
Console.WriteLine($"key = {key}, val = {value}");
```

Creates a TOML document programmatically:

```C#
var doc = new DocumentSyntax()
{
Tables =
{
new TableSyntax("test")
{
Items =
{
{"a", 1},
{"b", true },
{"c", "Check"},
{"d", "ToEscape\nWithAnotherChar\t" },
{"e", 12.5 },
{"f", new int[] {1,2,3,4} },
{"g", new string[] {"0", "1", "2"} },
{"key with space", 2}
}
}
}
};
Console.WriteLine(doc);
// Prints:
// [test]
// a = 1
// b = true
// c = "Check"
// d = "ToEscape\nWithAnotherChar\t"
// e = 12.5
// f = [1, 2, 3, 4]
// g = ["0", "1", "2"]
// "key with space" = 2
```

## License

Expand Down
26 changes: 26 additions & 0 deletions src/Tomlyn.Tests/SyntaxTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
// Licensed under the BSD-Clause 2 license.
// See license.txt file in the project root for full license information.

using System;
using NUnit.Framework;
using Tomlyn.Model;
using Tomlyn.Syntax;

namespace Tomlyn.Tests
Expand Down Expand Up @@ -52,5 +54,29 @@ public void TestDocument()
var newDoc = Toml.Parse(docStr);
AssertHelper.AreEqualNormalizeNewLine(expected, newDoc.ToString());
}

[Test]
public void Sample()
{
var input = @"[mytable]
key = 15
val = true
";

// Gets a syntax tree of the TOML text
var doc = Toml.Parse(input); // returns a DocumentSyntax
// Check for parsing errors with doc.HasErrors and doc.Diagnostics
// doc.HasErrors => throws an exception

// Prints the exact representation of the input
var docStr = doc.ToString();
Console.WriteLine(docStr);

// Gets a runtime representation of the syntax tree
var table = doc.ToModel();
var key = (long) ((TomlTable) table["mytable"])["key"];
var value = (bool) ((TomlTable) table["mytable"])["val"];
Console.WriteLine($"key = {key}, val = {value}");
}
}
}
Binary file added src/Tomlyn/key.snk
Binary file not shown.

0 comments on commit 762804d

Please sign in to comment.