Commit Graph

334 Commits

Author SHA1 Message Date
Paul Stemmet dacb745249
scanner/test: add complex::zero_indent_multilevel
Check an additional edge case around zero indent handling, specifically
the Zero, Normal, Zero (indent) pattern.

Issue: #54
2022-11-02 11:50:00 +00:00
Paul Stemmet a354d52d7c
scanner/test: add complex::zero_indent_multilevel_coalesce
This test reproduces a bug report, which lead to the fix in 835ceb0.

Issue: #54
2022-11-02 11:49:29 +00:00
Paul Stemmet 835ceb0b97
lib/scanner: fix missing token production for zero indents
So, the underlying bug here is caused because we check for zero indents
*before* unwinding the indentation stack. Take the following example:

```
 0|Map1:
 1|- Map2: value
 2|  Map2.1: value
 3|Map3: ...
  ----------
  0123456789
```

At (1,0) we encounter to indentation level increases -- map, sequence --
but zero actual indentation increase until (1,3) ('M' in 'Map2').

So, when we arrive at (3,0), Scanner::unroll_indent/2 only unrolls one
indent level... the second one (sequence) which contains the information
we use to determine whether an indent level has a zero indent that needs
to be added to the queue. Thus, when we hit the call to
Scanner::pop_zero_indent_sequence/2 it looks at the current indent
(map), which it correctly decides isn't zero indented.

The fix is simple, just reorder the operations to check for zero indents
before we unroll.

That said, I probably should create some additional test cases to check
that we handle these edge cases correctly.

1. Zero indent before and after real indent: (Z,N,Z)
2. Double zero indent -- not sure this is possible in YAML (Z,Z)

Issue: #54
2022-11-02 11:42:38 +00:00
Paul Stemmet 1dfa3def22
chore: release v0.1.3 2022-04-03 16:55:22 +00:00
Paul Stemmet 1c276d35c4 build/justfile: fix version prefix in bump-version 2022-04-03 17:53:07 +01:00
Paul Stemmet 1ac0685216
build/justfile: fix template name in _bump-git-version 2022-04-03 16:02:39 +00:00
Paul Stemmet 33f146b550 build: rename and improve template for git tag patchnotes
simple -> tag

Handle the strangeness in how git wants to format tag messages
2022-04-03 16:55:34 +01:00
Paul Stemmet 2b49e4068b build: explicitly select files to include in bump-version commits
and fix a typo in the output (missing 'v')
2022-04-03 16:55:34 +01:00
Paul Stemmet ec9e436037
chore: release v0.1.2 2022-04-03 11:32:15 +00:00
Paul Stemmet fcf85c98bd build: refuse to bump-version when branch is not master
and add untracked files (e.g the first CHANGELOG) to the index before
committing
2022-04-03 12:31:20 +01:00
Paul Stemmet 5c94b5802b build: ensure tag is prefixed with a 'v' in git 2022-04-03 12:31:20 +01:00
Paul Stemmet e6351d1f89 build: add changelog & patchnotes recipes, modify bump-version
bump-version has learned how to automate generation of the tag + commit
used to bump versions
2022-04-02 20:55:50 +01:00
Paul Stemmet bafd0098bd build: add simple patchnotes template for git tags 2022-04-02 20:55:50 +01:00
Paul Stemmet a2fab8db4f build: add git-cliff configuration
This tool will serve as our changelog generator
2022-04-02 20:55:50 +01:00
Paul Stemmet 6025906719 ci/github: add lint workflow 2022-04-01 22:21:54 +01:00
Paul Stemmet 7d4e270aae ci/github: refactor tests workflow to use just 2022-04-01 22:21:54 +01:00
Paul Stemmet afa2a9e504 lib/event: fix module doc intra links
enum variants should use 'type@' not 'enum@' it seems.
2022-04-01 22:15:24 +01:00
Paul Stemmet b53e7e78a9 build/justfile: add recipes for just
Just is an improvement on Make/Makefiles for people that wish to use it
as a recipe runner rather than a build system.

We are introducing a dependency on it, as it gives us easy ways to run
arbitrarily complex commands in a composable fashion.

In particular, these recipes allow us 5 major gains:

1. Setting our repo's environment consistently (fresh-system, install-bins)
2. Run comprehensive checks on the local tree's code (lint, audit, fmt,
   test, test-all, lint-docs)
3. Utility commands for inspecting dependencies (deps, rdeps, udeps),
   documentation (docs) or git hygiene (git-branch-prune)
4. Provides extra environment vairables that can be used to control
   things like features and profile used when building, which are
   missing from Cargo and/or rustc
5. Provides a uniform interface for repo tasks, abstracting over many
   different underlying tools
2022-04-01 20:38:04 +01:00
Paul Stemmet 7d74a26507
chore: update lock file 2022-04-01 19:33:53 +00:00
Paul Stemmet ee8c93eb3d chore: bump v0.1.1
This is the first published version of this crate. Quite a milestone for
me, as I have started work on this library multiple times over the last
3 years, never getting enough traction to find something that worked for
my project goals.

This version contains the lowest level API that will be supported by
this crate: lib/event; which allows callers to directly consume YAML
stream events as the occur, with no help or storage apparatus.

I have some CI/CD issues to figure out -- testing docs, automating
crates.io publishes, improving test spread and speed, adding a recipe
runner (Make/just). After which I'll start working away on the in memory
graph representation of YAML, which will allow me to provide a Value
abstraction for handling arbitrary YAML, similar to serde_json::Value.

Its secondary purpose will be as storage for aliasing trees... during
serde::Deserialization, which will be a feature gated API that may
eventually take the place of serde_yaml.
2022-03-27 16:51:52 +01:00
Paul Stemmet 44d8b82129 chore: update deps 2022-03-27 16:51:52 +01:00
Paul Stemmet 10089e376b reader/error: fix doc link error 2022-03-27 15:36:57 +01:00
Paul Stemmet 6360463435 event/flag: fix doc link error 2022-03-27 15:36:57 +01:00
Paul Stemmet 96d4531054 lib/reader: document module 2022-03-27 15:36:57 +01:00
Paul Stemmet 5c4d3c4879 event/types: document all public items 2022-03-27 15:36:57 +01:00
Paul Stemmet d247b19068 lib/error: module doc 2022-03-27 15:36:57 +01:00
Paul Stemmet 74cf9a2ad4 lib: warn on missing public docs 2022-03-27 15:36:57 +01:00
Paul Stemmet fa84377ebb event/parser: use array_iterator in tests macros 2022-03-27 12:06:14 +01:00
Paul Stemmet ab2c0fd438 event/types: hide internal types
This commit modifies the former Scalar (now know as ScalarLike) enum to
hide the internal types inside local opaque wrappers. Rather than the
previous struct variants, ScalarLike now takes Eager(Scalar) and
Lazy(ScalarLazy) variants, both of which hide internal types involved.

This commit also removes the ScanResult return types from public view,
converting them to the library level Error type.
2022-03-27 11:51:02 +01:00
Paul Stemmet 76c547717d scanner/error: add From impl for ScanError to public Error 2022-03-27 11:51:02 +01:00
Paul Stemmet 04e07125e6 lib/scanner: make most types crate private 2022-03-27 11:51:02 +01:00
Paul Stemmet 742386b177 lib/reader: hide private types in Read methods
We place a small wrapper around all of the arguments provided to
Read::drive(), and return a wrapped error, both of which are opaque to
external libraries.
2022-03-27 11:51:02 +01:00
Paul Stemmet c2f20d7883 lib: move Slice, ScalarStyle, StreamEncoding enums
from lib/token to event/types, and add Copy derives for ScalarStyle +
StreamEncoding.
2022-03-27 11:51:02 +01:00
Paul Stemmet 51c7529f75 event/parser: use array_iterator() over ArrayIter::new
as the latter has been deprecated in a future Rust version, and is
causing lots of spurious warnings in CI.
2022-03-26 15:49:50 +00:00
Paul Stemmet 4f402ee38e lib/event: use public Error type for returned errors 2022-03-26 15:29:54 +00:00
Paul Stemmet b5fa2acc9e event/error: impl From local error type to public Error 2022-03-26 15:29:54 +00:00
Paul Stemmet 62f9cf53e0 lib/event: ensure private types are private
Including the local error type -- we'll be using that which is provided
in lib/error.
2022-03-26 15:29:54 +00:00
Paul Stemmet 2793e4cc00 lib/event: add error conversion to ErrorKind 2022-03-26 15:29:54 +00:00
Paul Stemmet fe09d7aa27 lib/reader: add top level public API
- from_utf8()
- from_read()
- try_from_bytes()

These cover the major areas we expect a user to use when handing us a
(potential) YAML stream.
2022-03-26 15:29:54 +00:00
Paul Stemmet 4a48ac1735 reader/error: impl From local error type to public Error 2022-03-26 15:29:54 +00:00
Paul Stemmet 46d088fa2d lib/reader: hide local error type 2022-03-26 15:29:54 +00:00
Paul Stemmet 519482f798 lib/reader: add error conversion to ErrorKind 2022-03-26 15:29:54 +00:00
Paul Stemmet fba5f934f5 lib/scanner: add error conversion to ErrorCode 2022-03-26 15:29:54 +00:00
Paul Stemmet a2741447ac lib/scanner: fix visibility of modules
pub -> pub(crate)
2022-03-26 15:29:54 +00:00
Paul Stemmet c8496b0216 lib/error: add mkError! macro
For internal use, handles the conversion chain up to a real external
Error, from other types.
2022-03-26 15:29:54 +00:00
Paul Stemmet ff1925fdd0 lib/error: add library error type for all public APIs
This type obscures the underlying classifications, providing a stable
enum, Category, for classification.

This doesn't particularly change the various module level errors, though
will will have to implement From<Self> for yary::Error.

I'll also need to make private and public versions of the initializer
functions for fallible public methods that can be used internally, e.g
lib/reader.
2022-03-26 15:29:54 +00:00
Paul Stemmet 8d20962640 lib: clippy lints 2022-03-26 15:29:54 +00:00
Paul Stemmet 8ee7b7bff6 docs: fix rustdoc links in lib/scanner & lib/token 2022-03-26 15:29:14 +00:00
Paul Stemmet fa821cbf81 build: add pre-publish fields to Cargo.toml
- readme
- description
- repository
- keywords
- categories

and reorganize field layout, better grouping important fields together.
2022-03-19 10:04:02 +00:00
Paul Stemmet 790b9b55d5 docs: add README, explaining library purpose and status 2022-03-18 15:40:12 +00:00