1
0
mirror of https://github.com/danog/liquid.git synced 2025-01-22 16:51:19 +01:00

Add contribution guidelines

This commit is contained in:
Oliver Steele 2017-07-05 09:51:00 -04:00
parent 9714544301
commit 1b7564dbfb
2 changed files with 64 additions and 55 deletions

54
CONTRIBUTING.md Normal file
View File

@ -0,0 +1,54 @@
# Contributing
Refer to the [(original) Liquid contribution guidelines](https://github.com/Shopify/liquid/blob/master/CONTRIBUTING.md).
In addition to those checklists, I also won't merge:
- [ ] Performance improvements that don't include a benchmark.
- [ ] Meager (<3%) performance improvements that increase code verbosity or complexity.
A caveat: The cyclomatic complexity checks on generated functions, hand-written parsers, and some of the generic interpreter functions, have been disabled (via `nolint: gocyclo`). IMO this check isn't appropriate for those classes of functions. This isn't a license to disable cyclomatic complexity or lint in general.
## Cookbook
### Set up your machine
Fork and clone the repo.
[Install go](https://golang.org/doc/install#install). On macOS running Homebrew, `brew install go` is easier than the linked instructions.
Install package dependencies and development tools:
* `make install-dev-tools`
* `go get -t ./...`
### Test and Lint
```bash
go test ./...
make lint
```
### Preview the Documentation
```bash
godoc -http=:6060
open http://localhost:6060/pkg/github.com/osteele/liquid/
```
### Work on the Expression Parser and Lexer
To work on the lexer, install Ragel. On macOS: `brew install ragel`.
Do this after editing `scanner.rl` or `expressions.y`:
```bash
go generate ./...
```
Test just the scanner:
```bash
cd expression
ragel -Z scanner.rl && go test
```

View File

@ -9,18 +9,14 @@
`liquid` ports [Shopify Liquid templates](https://shopify.github.io/liquid) to Go. It was developed for use in [gojekyll](https://github.com/osteele/gojekyll). `liquid` ports [Shopify Liquid templates](https://shopify.github.io/liquid) to Go. It was developed for use in [gojekyll](https://github.com/osteele/gojekyll).
`liquid` provides a functional API for defining tags and filters. See examples [here](https://github.com/osteele/liquid/blob/master/filters/filters.go), [here](https://github.com/osteele/gojekyll/blob/master/filters/filters.go), and [here](https://github.com/osteele/gojekyll/blob/master/tags/tags.go). On the one hand, this isn't idiomatic Go. On the other hand, this made it possible to implement a boatload of Liquid and Jekyll filters without an onerous amount of boilerplate in some cases, simply by passing a reference to a function from the standard library. `liquid` provides a functional API for defining tags and filters. See examples [here](https://github.com/osteele/liquid/blob/master/filters/filters.go), [here](https://github.com/osteele/gojekyll/blob/master/filters/filters.go), and [here](https://github.com/osteele/gojekyll/blob/master/tags/tags.go).
<!-- TOC --> <!-- TOC -->
- [Go Liquid Template Parser](#go-liquid-template-parser) - [Go Liquid Template Parser](#go-liquid-template-parser)
- [Status](#status) - [Status](#status)
- [Install](#install) - [Install](#install)
- [Contribute](#contribute) - [Contributing](#contributing)
- [Setup](#setup)
- [Workflow](#workflow)
- [Style Guide](#style-guide)
- [Working on the Parser and Lexer](#working-on-the-parser-and-lexer)
- [References](#references) - [References](#references)
- [Attribution](#attribution) - [Attribution](#attribution)
- [Other Implementations](#other-implementations) - [Other Implementations](#other-implementations)
@ -32,13 +28,13 @@
## Status ## Status
This library is in its early days. IMO it's not sufficiently mature to be worth snapping off a [versioned URL](http://labix.org/gopkg.in). In particular, the tag and filter extension API is likely to change. This library is in its early days. The API may still change.
- [ ] Basics - [ ] Basics
- [x] Literals - [x] Literals
- [ ] String Escapes - [ ] String Escapes
- [x] Variables - [x] Variables
- [ ] Operators (partial) - [x] Operators
- [x] Arrays - [x] Arrays
- [ ] Whitespace Control - [ ] Whitespace Control
- [ ] Tags - [ ] Tags
@ -51,7 +47,7 @@ This library is in its early days. IMO it's not sufficiently mature to be worth
- [ ] `else` - [ ] `else`
- [ ] Iteration - [ ] Iteration
- [x] modifiers (`limit`, `reversed`, `offset`) - [x] modifiers (`limit`, `reversed`, `offset`)
- [ ] `range` - [ ] range
- [x] `break`, `continue` - [x] `break`, `continue`
- [x] loop variables - [x] loop variables
- [ ] `tablerow` - [ ] `tablerow`
@ -69,49 +65,10 @@ This library is in its early days. IMO it's not sufficiently mature to be worth
`go get -u github.com/osteele/goliquid` `go get -u github.com/osteele/goliquid`
## Contribute ## Contributing
### Setup Bug reports, test cases, and code contributions are more than welcome.
Please refer to the [contribution guidelines](./CONTRIBUTING.md).
```bash
make install-dev-tools
```
### Workflow
```bash
go test ./...
```
Test just the scanner:
```bash
cd expressions
ragel -Z scanner.rl && go test
```
Preview the documentation:
```bash
godoc -http=:6060&
open http://localhost:6060/pkg/github.com/osteele/liquid/
```
### Style Guide
`make test` and `make lint` should pass.
The cyclomatic complexity checks on generated functions, hand-written parsers, and some of the generic interpreter functions, have been disabled (via `nolint: gocyclo`). IMO this check isn't appropriate for those classes of functions. This isn't a license to disable cyclomatic complexity or lint in general willy nilly.
### Working on the Parser and Lexer
To work on the lexer, install Ragel. On macOS: `brew install ragel`.
Do this after editing `scanner.rl` or `expressions.y`:
```bash
go generate ./...
```
## References ## References
@ -137,10 +94,8 @@ The [original Liquid engine](https://shopify.github.io/liquid), of course, for t
### Go ### Go
* [karlseguin/liquid](https://github.com/karlseguin/liquid) is a dormant implementation that inspired a lot of forks. * [karlseguin/liquid](https://github.com/karlseguin/liquid) is a dormant implementation that inspired a lot of forks.
* [acstech/liquid](https://github.com/acstech/liquid) is a more active fork of Karl Seguin's implementation. I submitted a couple of pull requests there. * [acstech/liquid](https://github.com/acstech/liquid) is a more active fork of Karl Seguin's implementation.
* [hownowstephen/go-liquid](https://github.com/hownowstephen/go-liquid) is a more recent entry. * [hownowstephen/go-liquid](https://github.com/hownowstephen/go-liquid)
After trying each of these, and looking at how to extend them, I concluded that I wasn't going to get very far without a parser generator. I also wanted an easy API for writing filters.
### Other Languages ### Other Languages