2017-07-05 17:18:00 +02:00
# Contributing
2017-07-05 20:27:24 +02:00
Here's some ways to help:
2017-07-05 17:18:00 +02:00
2017-07-07 15:36:10 +02:00
* Try using gojekyll on your site. Use this as fodder for test cases.
2022-01-29 20:17:23 +01:00
* Choose an item to work on from the [issues list ](https://github.com/danog/gojekyll/issues ).
2017-07-07 15:36:10 +02:00
* Search the sources for FIXME and TODO comments.
2022-01-29 20:17:23 +01:00
* Improve the [code coverage ](https://coveralls.io/github/danog/gojekyll?branch=master ).
2017-07-05 17:18:00 +02:00
2022-01-29 20:17:23 +01:00
If you choose to contribute code, please review the [pull request template ](https://github.com/danog/gojekyll/blob/master/.github/PULL_REQUEST_TEMPLATE.md ) before you get too far along.
2017-07-05 17:18:00 +02:00
## Developer Cookbook
### Set up your machine
Fork and clone the repo.
2021-06-16 09:48:07 +02:00
[Install go ](https://golang.org/doc/install#install ). On macOS running Homebrew,
`brew install go` is easier than the linked instructions.
2017-07-05 17:18:00 +02:00
Install package dependencies and development tools:
```bash
2017-07-13 02:01:17 +02:00
make setup
2017-07-05 17:18:00 +02:00
go get -t ./...
```
2021-06-16 09:48:07 +02:00
[Install golangci-lint ](https://golangci-lint.run/usage/install/#local-installation ).
On macOS: `brew install golangci-lint`
2017-07-05 17:18:00 +02:00
### Test and Lint
```bash
make test
make lint
```
### Debugging tools
```bash
gojekyll -s path/to/site render index.md # render a file to stdout
gojekyll -s path/to/site render / # render a URL to stdout
gojekyll -s path/to/site variables / # print a file or URL's variables
gojekyll -s path/to/site variables site # print the site variables
gojekyll -s path/to/site variables site.twitter.name # print a specific site variable
```
2022-02-06 10:52:16 +01:00
`./scripts/gojekyll` is an alternative to the `gojekyll` executable, that uses
`go run` each time it's invoked.
### Benchmarks
Benchmarks are listed in the file ./docs/benchmarks.md.
As of 2022-02, I use [hyperfine ](https://github.com/sharkdp/hyperfine ) for
benchmarking. (I don't remember what I used for previous benchmarks.)
The "single-threaded" and "cached disabled" benchmarks use these settings:
* Cache disabled: Disable the cache by setting the environment variable
`GOJEKYLL_DISABLE_CACHE=1` .
* Single-threaded: Disable threading by setting `GOMAXPROCS=1` .
For example:
```sh
GOMAXPROCS=1 GOJEKYLL_DISABLE_CACHE=1 hyperfine --warmup 2 "gojekyll build -s ${SITE_SRC}"
GOMAXPROCS=1 hyperfine --warmup 2 "gojekyll build -s ${SITE_SRC}"
GOJEKYLL_DISABLE_CACHE=1 hyperfine --warmup 2 "gojekyll build -s ${SITE_SRC}"
hyperfine --warmup 2 "gojekyll build -s ${SITE_SRC}"
```
If you run into an error after a few runs, add the `--show-ouput` option to
2022-02-06 10:59:44 +01:00
`hyperfine` .
2017-07-05 17:18:00 +02:00
### Coverage
```bash
./scripts/coverage & & go tool cover -html=coverage.out
```
### Profiling
```bash
2017-07-09 21:55:12 +02:00
gojekyll -s path/to/site benchmark
go tool pprof --web gojekyll gojekyll.prof
2017-07-05 17:18:00 +02:00
```