From 06e5151ab13de31a226630d967d8972ae34c0a17 Mon Sep 17 00:00:00 2001 From: Geoffrey Ragot Date: Wed, 2 Oct 2024 15:44:30 +0200 Subject: [PATCH] feat: add gomarkdoc --- Earthfile | 3 + README.md | 44 +++++++++------ cmd/README.md | 149 ++++++++++++++++++++++++++++++++++++++++++++++++++ go.mod | 1 + go.sum | 2 + main.go | 32 +++++++++++ 6 files changed, 213 insertions(+), 18 deletions(-) create mode 100644 cmd/README.md diff --git a/Earthfile b/Earthfile index a8c55b67a..bfcaf080a 100644 --- a/Earthfile +++ b/Earthfile @@ -25,12 +25,14 @@ generate: FROM core+builder-image RUN apk update && apk add openjdk11 RUN go install go.uber.org/mock/mockgen@latest + RUN go install github.com/princjef/gomarkdoc/cmd/gomarkdoc@latest COPY (+sources/*) /src WORKDIR /src RUN go generate ./... SAVE ARTIFACT internal AS LOCAL internal SAVE ARTIFACT pkg AS LOCAL pkg SAVE ARTIFACT cmd AS LOCAL cmd + SAVE ARTIFACT README.md AS LOCAL README.md compile: FROM +sources @@ -117,6 +119,7 @@ pre-commit: BUILD +tidy BUILD +lint BUILD +openapi + BUILD +generate BUILD +generate-client BUILD +export-docs-events diff --git a/README.md b/README.md index 6cd4118b9..93e9fbb60 100644 --- a/README.md +++ b/README.md @@ -1,24 +1,30 @@ -# Formance Ledger + -Formance Ledger (fka numary) is a programmable financial ledger that provides a foundation for money-moving applications. The ledger provides atomic multi-postings transactions and is programmable in [Numscript](doc:machine-instructions), a built-in language dedicated to money movements. It can be used either as a standalone micro-service or as part of the greater Formance Stack, and will shine for apps that require a lot of custom, money-moving code, e.g: +# src -* E-commerce with complex payments flows, payments splitting, such as marketplaces -* Company-issued currencies systems, e.g. Twitch Bits -* In-game currencies, inventories and trading systems, e.g. Fortnite V-Bucks -* Payment gateways using non-standard assets, e.g. learning credits -* Local currencies and complementary finance +```go +import "github.com/formancehq/ledger" +``` + +### Formance Ledger + +Formance Ledger \(fka numary\) is a programmable financial ledger that provides a foundation for money\-moving applications. The ledger provides atomic multi\-postings transactions and is programmable in \[Numscript\]\(doc:machine\-instructions\), a built\-in language dedicated to money movements. It can be used either as a standalone micro\-service or as part of the greater Formance Stack, and will shine for apps that require a lot of custom, money\-moving code, e.g: -# Getting started +- E\-commerce with complex payments flows, payments splitting, such as marketplaces +- Company\-issued currencies systems, e.g. Twitch Bits +- In\-game currencies, inventories and trading systems, e.g. Fortnite V\-Bucks +- Payment gateways using non\-standard assets, e.g. learning credits +- Local currencies and complementary finance -Formance Ledger works as a standalone binary, the latest of which can be downloaded from the [releases page](https://github.com/formancehq/ledger/releases). You can move the binary to any executable path, such as to `/usr/local/bin`. Installations using brew, apt, yum or docker are also [available](https://docs.formance.com/docs/installation-1). +### Getting started -```SHELL +Formance Ledger works as a standalone binary, the latest of which can be downloaded from the \[releases page\]\(https://github.com/formancehq/ledger/releases\). You can move the binary to any executable path, such as to \`/usr/local/bin\`. Installations using brew, apt, yum or docker are also \[available\]\(https://docs.formance.com/docs/installation-1\). +``` docker compose up -d # Submit a first transaction -curl -X POST \ - http://localhost:3068/quickstart/transactions -d '{"postings": [{"source": "world", "destination": "bank", "amount": 100, "asset": "USD"}]}' +curl -X POST http://localhost:3068/quickstart/transactions -d '{"postings": [{"source": "world", "destination": "bank", "amount": 100, "asset": "USD"}]}' # Get the balances of drivers:042 curl -X GET http://localhost:3068/quickstart/accounts/bank @@ -27,14 +33,16 @@ curl -X GET http://localhost:3068/quickstart/accounts/bank curl -X GET http://localhost:3068/quickstart/transactions ``` -# Documentation +### Documentation + +You can find the complete Numary documentation at \[docs.formance.com\]\(https://docs.formance.com\) + +### Community -You can find the complete Numary documentation at [docs.formance.com](https://docs.formance.com) +If you need help, want to show us what you built or just hang out and chat about ledgers you are more than welcome on our \[Slack\]\(https://bit.ly/formance-slack\) \- looking forward to see you there\! -# Community +## Index -If you need help, want to show us what you built or just hang out and chat about ledgers you are more than welcome on our [Slack](https://bit.ly/formance-slack) - looking forward to see you there! -# Contributing -See [dev](./DEV.md) page to contribute. \ No newline at end of file +Generated by [gomarkdoc]() diff --git a/cmd/README.md b/cmd/README.md new file mode 100644 index 000000000..eb9c0de4e --- /dev/null +++ b/cmd/README.md @@ -0,0 +1,149 @@ + + +# cmd + +```go +import "github.com/formancehq/ledger/cmd" +``` + +## Index + +- [Constants](<#constants>) +- [Variables](<#variables>) +- [func Execute\(\)](<#Execute>) +- [func NewBucket\(\) \*cobra.Command](<#NewBucket>) +- [func NewBucketUpgrade\(\) \*cobra.Command](<#NewBucketUpgrade>) +- [func NewDocCommand\(\) \*cobra.Command](<#NewDocCommand>) +- [func NewDocEventsCommand\(\) \*cobra.Command](<#NewDocEventsCommand>) +- [func NewDocFlagsCommand\(\) \*cobra.Command](<#NewDocFlagsCommand>) +- [func NewRootCommand\(\) \*cobra.Command](<#NewRootCommand>) +- [func NewServeCommand\(\) \*cobra.Command](<#NewServeCommand>) +- [func NewVersion\(\) \*cobra.Command](<#NewVersion>) +- [func PrintVersion\(\_ \*cobra.Command, \_ \[\]string\)](<#PrintVersion>) + + +## Constants + + + +```go +const ( + BindFlag = "bind" + BallastSizeInBytesFlag = "ballast-size" + NumscriptCacheMaxCountFlag = "numscript-cache-max-count" + AutoUpgradeFlag = "auto-upgrade" + EnablePProfFlag = "enable-pprof" +) +``` + + + +```go +const ( + ServiceName = "ledger" +) +``` + +## Variables + + + +```go +var ( + Version = "develop" + BuildDate = "-" + Commit = "-" +) +``` + + +## func Execute + +```go +func Execute() +``` + + + + +## func NewBucket + +```go +func NewBucket() *cobra.Command +``` + + + + +## func NewBucketUpgrade + +```go +func NewBucketUpgrade() *cobra.Command +``` + + + + +## func NewDocCommand + +```go +func NewDocCommand() *cobra.Command +``` + + + + +## func NewDocEventsCommand + +```go +func NewDocEventsCommand() *cobra.Command +``` + + + + +## func NewDocFlagsCommand + +```go +func NewDocFlagsCommand() *cobra.Command +``` + + + + +## func NewRootCommand + +```go +func NewRootCommand() *cobra.Command +``` + + + + +## func NewServeCommand + +```go +func NewServeCommand() *cobra.Command +``` + + + + +## func NewVersion + +```go +func NewVersion() *cobra.Command +``` + + + + +## func PrintVersion + +```go +func PrintVersion(_ *cobra.Command, _ []string) +``` + + + +Generated by [gomarkdoc]() diff --git a/go.mod b/go.mod index 5b6273827..9c370e748 100644 --- a/go.mod +++ b/go.mod @@ -140,6 +140,7 @@ require ( github.com/puzpuzpuz/xsync/v3 v3.4.0 // indirect github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect github.com/riandyrn/otelchi v0.10.0 // indirect + github.com/robertkrimen/godocdown v0.0.0-20130622164427-0bfa04905481 // indirect github.com/rs/cors v1.11.1 // indirect github.com/shirou/gopsutil/v4 v4.24.8 // indirect github.com/shoenig/go-m1cpu v0.1.6 // indirect diff --git a/go.sum b/go.sum index 4be4dbc75..311c9b34e 100644 --- a/go.sum +++ b/go.sum @@ -274,6 +274,8 @@ github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 h1:N/ElC8H3+5X github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/riandyrn/otelchi v0.10.0 h1:QMbR/FMDWBOkej6dfyWteYefUKqIFxnyrpaoWRJ9RPQ= github.com/riandyrn/otelchi v0.10.0/go.mod h1:zBaX2FavWMlsvq4GqHit+QXxF1c5wIMZZFaYyW4+7FA= +github.com/robertkrimen/godocdown v0.0.0-20130622164427-0bfa04905481 h1:jMxcLa+VjJKhpCwbLUXAD15wJ+hhvXMLujCl3MkXpfM= +github.com/robertkrimen/godocdown v0.0.0-20130622164427-0bfa04905481/go.mod h1:C9WhFzY47SzYBIvzFqSvHIR6ROgDo4TtdTuRaOMjF/s= github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= github.com/rs/cors v1.11.1 h1:eU3gRzXLRK57F5rKMGMZURNdIG4EoAmX8k94r9wXWHA= diff --git a/main.go b/main.go index 2b1571661..9e0c3d693 100644 --- a/main.go +++ b/main.go @@ -1,3 +1,35 @@ +// # Formance Ledger +// +// Formance Ledger (fka numary) is a programmable financial ledger that provides a foundation for money-moving applications. The ledger provides atomic multi-postings transactions and is programmable in [Numscript](doc:machine-instructions), a built-in language dedicated to money movements. It can be used either as a standalone micro-service or as part of the greater Formance Stack, and will shine for apps that require a lot of custom, money-moving code, e.g: +// * E-commerce with complex payments flows, payments splitting, such as marketplaces +// * Company-issued currencies systems, e.g. Twitch Bits +// * In-game currencies, inventories and trading systems, e.g. Fortnite V-Bucks +// * Payment gateways using non-standard assets, e.g. learning credits +// * Local currencies and complementary finance +// +// # Getting started +// +// Formance Ledger works as a standalone binary, the latest of which can be downloaded from the [releases page](https://github.com/formancehq/ledger/releases). You can move the binary to any executable path, such as to `/usr/local/bin`. Installations using brew, apt, yum or docker are also [available](https://docs.formance.com/docs/installation-1). +// +// docker compose up -d +// +// # Submit a first transaction +// curl -X POST http://localhost:3068/quickstart/transactions -d '{"postings": [{"source": "world", "destination": "bank", "amount": 100, "asset": "USD"}]}' +// +// # Get the balances of drivers:042 +// curl -X GET http://localhost:3068/quickstart/accounts/bank +// +// # List transactions +// curl -X GET http://localhost:3068/quickstart/transactions +// +// # Documentation +// +// You can find the complete Numary documentation at [docs.formance.com](https://docs.formance.com) +// +// # Community +// +// If you need help, want to show us what you built or just hang out and chat about ledgers you are more than welcome on our [Slack](https://bit.ly/formance-slack) - looking forward to see you there! +//go:generate gomarkdoc --output README.md . package main import (