Skip to content

Commit ef16336

Browse files
committed
docs: clarify usage and security boundaries
1 parent d9eeb7e commit ef16336

6 files changed

Lines changed: 399 additions & 1220 deletions

File tree

CONTRIBUTING.md

Lines changed: 54 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -1,152 +1,97 @@
11
# Contributing
22

3-
Here's some ways to help:
3+
Bug reports, focused test cases, documentation fixes, and code contributions
4+
are welcome. Before starting a large change, open an issue to confirm the
5+
approach.
46

5-
* Select an item from the [issues list](https://github.com/osteele/liquid/issues)
6-
* Search the sources for FIXME and TODO comments using `make list-todo`
7-
* Improve the code coverage - run `make coverage` to see current coverage (currently ~84%)
7+
Review the
8+
[pull request template](https://github.com/osteele/liquid/blob/main/.github/PULL_REQUEST_TEMPLATE.md)
9+
before writing the final description.
810

9-
Review the [pull request template](https://github.com/osteele/liquid/blob/master/.github/PULL_REQUEST_TEMPLATE.md) before you get too far along on coding.
11+
## Set up the repository
1012

11-
A note on lint: `nolint: gocyclo` has been used to disable cyclomatic complexity checks on generated functions, hand-written parsers, and some of the generic interpreter functions. IMO this check isn't appropriate for those classes of functions. This isn't a license to disable cyclomatic complexity checks or lint in general.
12-
13-
## Cookbook
14-
15-
### Set up your machine
16-
17-
Fork and clone the repo.
18-
19-
[Install go](https://golang.org/doc/install#install). On macOS running Homebrew, `brew install go` is easier than the linked instructions.
20-
21-
Install package dependencies and development tools:
13+
Install [Go](https://go.dev/doc/install), then fork and clone the repository.
14+
Download the pinned tools and module dependencies:
2215

2316
```bash
24-
make tools # Download the versions pinned in go.mod
25-
make deps # Download Go dependencies
17+
make tools
18+
make deps
2619
```
2720

28-
The lint target runs the golangci-lint version pinned in `go.mod`; a separate
29-
global installation is not required.
30-
31-
#### Set up Git Hooks (Recommended)
21+
The lint target uses the `golangci-lint` version pinned in `go.mod`. You do not
22+
need a global installation.
3223

33-
This project uses pre-commit hooks to automatically run formatting, linting, and tests before commits and pushes:
24+
Optional pre-commit hooks run formatting, lint, tests, and basic repository
25+
checks:
3426

3527
```bash
36-
make install-hooks # Install pre-commit hooks
28+
make install-hooks
3729
```
3830

39-
This will:
40-
- Install pre-commit if not already installed
41-
- Set up hooks to run automatically on `git commit` and `git push`
42-
- Run formatting (`go fmt`)
43-
- Run linting (`golangci-lint`)
44-
- Run tests (`go test -short`)
45-
- Check for common issues (trailing whitespace, large files, merge conflicts)
31+
Run all hooks manually with `make run-hooks`. Update the hook definitions with
32+
`make update-hooks`.
4633

47-
To test the hooks manually:
48-
```bash
49-
make run-hooks # Run all hooks on all files
50-
```
34+
## Develop and test
5135

52-
To update hooks to latest versions:
53-
```bash
54-
make update-hooks # Update pre-commit hooks
55-
```
56-
57-
### Development Workflow
58-
59-
Quick start for development:
36+
Run the standard pre-commit checks before opening a pull request:
6037

6138
```bash
62-
make all # Clean, lint, test, and build everything
63-
make pre-commit # Run formatter, linter, and tests before committing
39+
make pre-commit
6440
```
6541

66-
### Testing
42+
Useful targets include:
6743

6844
```bash
69-
make test # Run all tests
70-
make test-short # Run short tests only
71-
make coverage # Generate test coverage report
72-
make benchmark # Run performance benchmarks
45+
make test # Run all tests
46+
make test-short # Run short tests
47+
make coverage # Write coverage.out and print package coverage
48+
make benchmark # Run benchmarks
49+
make fmt # Format Go source
50+
make lint # Run golangci-lint
51+
make lint-fix # Apply supported lint fixes
52+
make vet # Run go vet
53+
make build # Build the command
54+
make ci # Run the local CI sequence
7355
```
7456

75-
**Coverage Reporting**: Code coverage is tracked automatically via GitHub Actions. When you push to the main branch, the CI pipeline:
76-
- Generates a coverage report using Go's native coverage tools
77-
- Extracts the coverage percentage
78-
- Displays coverage details in the workflow summary
79-
- Optionally creates a coverage badge (if `GIST_SECRET` is configured)
57+
Use `make help` to list every target.
8058

81-
To view coverage locally, run `make coverage`. This generates `coverage.out` and displays per-package coverage percentages. The coverage data is generated without external SaaS services, using only Go's built-in tooling.
59+
Do not suppress a lint finding without a specific reason. Existing
60+
`nolint:gocyclo` directives cover generated functions, hand-written parsers,
61+
and generic interpreter functions where the complexity metric is not useful.
8262

83-
### Code Quality
63+
## Manage dependencies
8464

8565
```bash
86-
make fmt # Format code
87-
make lint # Run linter
88-
make lint-fix # Run linter with auto-fix
89-
make vet # Run go vet
66+
make deps # Download dependencies
67+
make deps-update # Update dependencies
68+
make deps-list # List dependencies
69+
make mod-tidy # Run go mod tidy
70+
make mod-verify # Verify downloaded modules
71+
make check-mod # Check whether go.mod and go.sum are current
9072
```
9173

92-
### Building
74+
## Generate the parser
9375

94-
```bash
95-
make build # Build the binary
96-
make install # Build and install to GOPATH/bin
97-
make clean # Remove build artifacts
98-
```
76+
The expression lexer uses Ragel, and the parser uses `goyacc`. Install Ragel
77+
before editing `expressions/scanner.rl`. On macOS, run `brew install ragel`.
9978

100-
### Dependencies
79+
After changing `expressions/scanner.rl` or `expressions/expressions.y`,
80+
regenerate the checked-in Go files:
10181

10282
```bash
103-
make deps # Download dependencies
104-
make deps-update # Update dependencies to latest versions
105-
make deps-list # List all dependencies
106-
make mod-tidy # Clean up go.mod and go.sum
107-
make mod-verify # Verify dependencies are correct
108-
make check-mod # Check if go.mod is up to date
83+
make generate
10984
```
11085

111-
### Utilities
86+
The generation target downloads the pinned Go tools and checks for Ragel.
11287

113-
```bash
114-
make list-todo # Find all TODO and FIXME comments
115-
make list-imports # List all package imports
116-
make ci # Run full CI suite locally
117-
make help # Show all available commands
118-
```
88+
## Preview API documentation
11989

120-
### Preview the Documentation
90+
Run a local documentation server:
12191

12292
```bash
93+
go install golang.org/x/tools/cmd/godoc@latest
12394
godoc -http=:6060
124-
open http://localhost:6060/pkg/github.com/osteele/liquid/
125-
```
126-
127-
### Work on the Expression Parser and Lexer
128-
129-
To work on the lexer, install Ragel. On macOS: `brew install ragel`.
130-
131-
The Go code-generation tools are pinned in `go.mod` and downloaded by `make tools`:
132-
- `goyacc` for parser generation
133-
- `stringer` for string method generation
134-
135-
After editing `scanner.rl` or `expressions.y`:
136-
137-
```bash
138-
make generate # Re-generate lexers and parsers
13995
```
14096

141-
Or directly:
142-
143-
```bash
144-
go generate ./...
145-
```
146-
147-
Test just the scanner:
148-
149-
```bash
150-
cd expressions
151-
ragel -Z scanner.rl && go test
152-
```
97+
Then open <http://localhost:6060/pkg/github.com/osteele/liquid/>.

0 commit comments

Comments
 (0)