From 6465ee25bce866d652151aad29bab3ed44db2b30 Mon Sep 17 00:00:00 2001 From: Arsen Musayelyan Date: Sat, 7 Jan 2023 15:15:49 -0800 Subject: [PATCH] Add generation instructions to README --- README.md | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 27ad7c8..bb8e3dc 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![Go Reference](https://pkg.go.dev/badge/go.arsenm.dev/go-lemmy.svg)](https://pkg.go.dev/go.arsenm.dev/go-lemmy) -Go bindings to the [Lemmy](https://join-lemmy.org) API +Go bindings to the [Lemmy](https://join-lemmy.org) API, automatically generated directly from Lemmy's source code using the generator in [cmd/gen](cmd/gen). Example: @@ -28,4 +28,32 @@ _, err = c.SaveUserSettings(ctx, types.SaveUserSettings{ if err != nil { panic(err) } -``` \ No newline at end of file +``` + +### How to generate + +First, build the generator: + +```bash +go build ./cmd/gen +``` + +Clone Lemmy's source code at whatever version you need: + +```bash +git clone https://github.com/LemmyNet/lemmy -b 0.16.7 +``` + +Remove all the existing generated code: + +```bash +rm **/*.gen.go +``` + +Execute the generator: + +```bash +./gen -out-dir . +``` + +And that's it! Your generated code should be ready for use. \ No newline at end of file