Added new document tool for standardising supplementary documentation

This commit is contained in:
Ryan O'Hara-Reid
2018-02-18 11:09:36 +11:00
parent f1dcb11b66
commit ef51adae76
23 changed files with 587 additions and 0 deletions

View File

@@ -0,0 +1,184 @@
package main
import (
"flag"
"fmt"
"html/template"
"log"
"os"
"github.com/thrasher-/gocryptotrader/common"
)
const (
commonPath = "..%s..%scommon%s"
configPath = "..%s..%sconfig%s"
currencyPath = "..%s..%scurrency%s"
currencyPairPath = "..%s..%scurrency%spair%s"
currencySymbolPath = "..%s..%scurrency%ssymbol%s"
currencyTranslationPath = "..%s..%scurrency%stranslation%s"
eventsPath = "..%s..%sevents%s"
exchangesPath = "..%s..%sexchanges%s"
exchangesNoncePath = "..%s..%sexchanges%snonce%s"
exchangesOrderbookPath = "..%s..%sexchanges%sorderbook%s"
exchangesStatsPath = "..%s..%sexchanges%sstats%s"
exchangesTickerPath = "..%s..%sexchanges%sticker%s"
portfolioPath = "..%s..%sportfolio%s"
smsglobalPath = "..%s..%ssmsglobal%s"
testdataPath = "..%s..%stestdata%s"
toolsPath = "..%s..%stools%s"
webPath = "..%s..%sweb%s"
rootPath = "..%s..%s"
)
var (
verbose, replace bool
codebasePaths map[string]string
codebaseTemplatePath map[string]string
codebaseReadme map[string]readme
tmpl *template.Template
path string
)
type readme struct {
Name string
Contributors string
}
func main() {
flag.BoolVar(&verbose, "v", false, "-v Verbose flag prints more information to the std output")
flag.BoolVar(&replace, "r", false, "-r Replace flag generates and replaces all documentation across the code base")
flag.Parse()
fmt.Println(`
GoCryptoTrader: Exchange documentation tool
This will update and regenerate documentation for the different packages
in GoCryptoTrader.
`)
codebasePaths = make(map[string]string)
codebaseTemplatePath = make(map[string]string)
codebaseReadme = make(map[string]readme)
path = common.GetOSPathSlash()
if err := addTemplates(); err != nil {
log.Fatal("GoCryptoTrader: Exchange documentation tool add template error ", err)
}
if err := updateReadme(); err != nil {
log.Fatal("GoCryptoTrader: Exchange documentation tool update readme error ", err)
}
fmt.Println("\nTool finished")
}
// Iterates through codebase paths to check for readme files and either adds
// or replaces with new readme files.
func updateReadme() error {
addPaths()
for packageName := range codebasePaths {
addReadmeData(packageName)
if !checkReadme(packageName) {
if verbose {
fmt.Printf("* %s Readme file FOUND.\n", packageName)
}
if replace {
fmt.Println("file replacement")
if err := replaceReadme(packageName); err != nil {
return err
}
continue
}
continue
}
if verbose {
fmt.Printf("* %s Readme file NOT FOUND.\n", packageName)
}
if replace {
log.Println("file creation")
if err := createReadme(packageName); err != nil {
return err
}
continue
}
}
return nil
}
// Adds paths to different potential README.md files in the codebase
func addPaths() {
codebasePaths["common"] = fmt.Sprintf(commonPath, path, path, path)
codebasePaths["config"] = fmt.Sprintf(configPath, path, path, path)
codebasePaths["currency"] = fmt.Sprintf(currencyPath, path, path, path)
codebasePaths["currency pair"] = fmt.Sprintf(currencyPairPath, path, path, path, path)
codebasePaths["currency symbol"] = fmt.Sprintf(currencySymbolPath, path, path, path, path)
codebasePaths["currency translation"] = fmt.Sprintf(currencyTranslationPath, path, path, path, path)
codebasePaths["events"] = fmt.Sprintf(eventsPath, path, path, path)
codebasePaths["exchanges"] = fmt.Sprintf(exchangesPath, path, path, path)
codebasePaths["exchanges nonce"] = fmt.Sprintf(exchangesNoncePath, path, path, path, path)
codebasePaths["exchanges orderbook"] = fmt.Sprintf(exchangesOrderbookPath, path, path, path, path)
codebasePaths["exchanges stats"] = fmt.Sprintf(exchangesStatsPath, path, path, path, path)
codebasePaths["exchanges ticker"] = fmt.Sprintf(exchangesTickerPath, path, path, path, path)
codebasePaths["portfolio"] = fmt.Sprintf(portfolioPath, path, path, path)
codebasePaths["smsglobal"] = fmt.Sprintf(smsglobalPath, path, path, path)
codebasePaths["testdata"] = fmt.Sprintf(testdataPath, path, path, path)
codebasePaths["tools"] = fmt.Sprintf(toolsPath, path, path, path)
codebasePaths["web"] = fmt.Sprintf(webPath, path, path, path)
codebasePaths["root"] = fmt.Sprintf(rootPath, path, path)
}
func addReadmeData(packageName string) {
readmeInfo := readme{
Name: packageName,
Contributors: "", //future implementation to track contributors
}
codebaseReadme[packageName] = readmeInfo
}
// adds all the template files
func addTemplates() error {
glob, err := template.ParseGlob(fmt.Sprintf("readme_templates%s*", path))
if err != nil {
return err
}
_, err = glob.ParseGlob(fmt.Sprintf("sub_templates%s*", path))
if err != nil {
return err
}
tmpl = glob
return nil
}
// checkReadme checks to see if the file exists
func checkReadme(packageName string) bool {
_, err := os.Stat(codebasePaths[packageName] + "README.md")
return os.IsNotExist(err)
}
// replaces readme file
func replaceReadme(packageName string) error {
if err := deleteFile(codebasePaths[packageName] + "README.md"); err != nil {
return err
}
return createReadme(packageName)
}
// creates new readme file and executes template
func createReadme(packageName string) error {
file, err := os.Create(codebasePaths[packageName] + "README.md")
defer file.Close()
if err != nil {
return err
}
fmt.Println("File done")
return tmpl.ExecuteTemplate(file, packageName, codebaseReadme[packageName])
}
func deleteFile(path string) error {
return os.Remove(path)
}

View File

@@ -0,0 +1,10 @@
{{define "common" -}}
{{template "header" .Name}}
## Current Features for {{.Name}}
+ This package collates basic broad functions that are used throughout this codebase
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{end}}

View File

@@ -0,0 +1,10 @@
{{define "config" -}}
{{template "header" .Name}}
## Current Features for {{.Name}}
+ This package deals with configuration utilities
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{end}}

View File

@@ -0,0 +1,10 @@
{{define "currency pair" -}}
{{template "header" .Name}}
## Current Features for {{.Name}}
+ This package services the currency package
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{end}}

View File

@@ -0,0 +1,10 @@
{{define "currency" -}}
{{template "header" .Name}}
## Current Features for {{.Name}}
+ Currency package deals with currency pair generation, manipulation and tracking
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{end}}

View File

@@ -0,0 +1,10 @@
{{define "currency symbol" -}}
{{template "header" .Name}}
## Current Features for {{.Name}}
+ This package services the currency package
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{end}}

View File

@@ -0,0 +1,10 @@
{{define "currency translation" -}}
{{template "header" .Name}}
## Current Features for {{.Name}}
+ This package services the currency package with translation functions
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{end}}

View File

@@ -0,0 +1,10 @@
{{define "events" -}}
{{template "header" .Name}}
## Current Features for {{.Name}}
+ The events package handles events from GoCryptoTrader bot
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{end}}

View File

@@ -0,0 +1,10 @@
{{define "exchanges nonce" -}}
{{template "header" .Name}}
## Current Features for {{.Name}}
+ This package services the exchanges package with nonce creation
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{end}}

View File

@@ -0,0 +1,10 @@
{{define "exchanges orderbook" -}}
{{template "header" .Name}}
## Current Features for {{.Name}}
+ This package facilitates orderbook generation
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{end}}

View File

@@ -0,0 +1,10 @@
{{define "exchanges" -}}
{{template "header" .Name}}
## Current Features for {{.Name}}
+ This package is used to connect and query data from supported exchanges
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{end}}

View File

@@ -0,0 +1,10 @@
{{define "exchanges stats" -}}
{{template "header" .Name}}
## Current Features for {{.Name}}
+ This package services the exchanges package
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{end}}

View File

@@ -0,0 +1,10 @@
{{define "exchanges ticker" -}}
{{template "header" .Name}}
## Current Features for {{.Name}}
+ This services the exchanges package by ticker functions
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{end}}

View File

@@ -0,0 +1,10 @@
{{define "portfolio" -}}
{{template "header" .Name}}
## Current Features for {{.Name}}
+ This package allows for the monitoring of portfolio data
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{end}}

View File

@@ -0,0 +1,121 @@
{{define "root" -}}
<img src="https://github.com/thrasher-/gocryptotrader/blob/master/web/src/assets/page-logo.png?raw=true" width="350px" height="350px" hspace="70">
[![Build Status](https://travis-ci.org/thrasher-/gocryptotrader.svg?branch=master)](https://travis-ci.org/thrasher-/gocryptotrader)
[![Software License](https://img.shields.io/badge/License-MIT-orange.svg?style=flat-square)](https://github.com/thrasher-/gocryptotrader/blob/master/LICENSE)
[![GoDoc](https://godoc.org/github.com/thrasher-/gocryptotrader?status.svg)](https://godoc.org/github.com/thrasher-/gocryptotrader)
[![Coverage Status](http://codecov.io/github/thrasher-/gocryptotrader/coverage.svg?branch=master)](http://codecov.io/github/thrasher-/gocryptotrader?branch=master)
[![Go Report Card](https://goreportcard.com/badge/github.com/thrasher-/gocryptotrader)](https://goreportcard.com/report/github.com/thrasher-/gocryptotrader)
A cryptocurrency trading bot supporting multiple exchanges written in Golang.
**Please note that this bot is under development and is not ready for production!**
## Community
Join our slack to discuss all things related to GoCryptoTrader! [GoCryptoTrader Slack](https://gocryptotrader.herokuapp.com/)
## Exchange Support Table
| Exchange | REST API | Streaming API | FIX API |
|----------|------|-----------|-----|
| Alphapoint | Yes | Yes | NA |
| ANXPRO | Yes | No | NA |
| Binance| Yes | No | NA |
| Bitfinex | Yes | Yes | NA |
| Bitflyer | Yes | No | NA |
| Bithumb | Yes | NA | NA |
| Bitstamp | Yes | Yes | No |
| Bittrex | Yes | No | NA |
| BTCC | Yes | Yes | No |
| BTCMarkets | Yes | No | NA |
| COINUT | Yes | No | NA |
| Exmo | Yes | NA | NA |
| GDAX(Coinbase) | Yes | Yes | No|
| Gemini | Yes | No | No |
| HitBTC | Yes | Yes | No |
| Huobi.Pro | Yes | No |No |
| ItBit | Yes | NA | No |
| Kraken | Yes | NA | NA |
| LakeBTC | Yes | No | NA |
| Liqui | Yes | No | NA |
| LocalBitcoins | Yes | NA | NA |
| OKCoin China | Yes | Yes | No |
| OKCoin International | Yes | Yes | No |
| OKEX | Yes | No | No |
| Poloniex | Yes | Yes | NA |
| WEX | Yes | NA | NA |
| Yobit | Yes | NA | NA |
We are aiming to support the top 20 highest volume exchanges based off the [CoinMarketCap exchange data](https://coinmarketcap.com/exchanges/volume/24-hour/).
** NA means not applicable as the Exchange does not support the feature.
## Current Features
+ Support for all Exchange fiat and digital currencies, with the ability to individually toggle them on/off.
+ AES encrypted config file.
+ REST API support for all exchanges.
+ Websocket support for applicable exchanges.
+ Ability to turn off/on certain exchanges.
+ Ability to adjust manual polling timer for exchanges.
+ SMS notification support via SMS Gateway.
+ Packages for handling currency pairs, ticker/orderbook fetching and currency conversion.
+ Portfolio management tool; fetches balances from supported exchanges and allows for custom address tracking.
+ Basic event trigger system.
+ WebGUI.
## Planned Features
Planned features can be found on our [community Trello page](https://trello.com/b/ZAhMhpOy/gocryptotrader).
## Contribution
Please feel free to submit any pull requests or suggest any desired features to be added.
When submitting a PR, please abide by our coding guidelines:
+ Code must adhere to the official Go [formatting](https://golang.org/doc/effective_go.html#formatting) guidelines (i.e. uses [gofmt](https://golang.org/cmd/gofmt/)).
+ Code must be documented adhering to the official Go [commentary](https://golang.org/doc/effective_go.html#commentary) guidelines.
+ Code must adhere to our [coding style](https://github.com/thrasher-/gocryptotrader/blob/master/doc/coding_style.md).
+ Pull requests need to be based on and opened against the `master` branch.
## Compiling instructions
Download and install Go from [Go Downloads](https://golang.org/dl/) for your
platform.
### Linux/OSX
```bash
go get github.com/thrasher-/gocryptotrader
cd $GOPATH/src/github.com/thrasher-/gocryptotrader
make get
make install
cp $GOPATH/src/github.com/thrasher-/gocryptotrader/config_example.json $GOPATH/bin/config.json
```
### Windows
```bash
go get github.com/thrasher-/gocryptotrader
cd %GOPATH%\src\github.com\thrasher-\gocryptotrader
go install
copy %GOPATH%\src\github.com\thrasher-\gocryptotrader\config_example.json %GOPATH%\bin\config.json
```
+ Make any neccessary changes to the `config.json` file.
+ Run the `gocryptotrader` binary file inside your GOPATH bin folder.
## Donations
<img src="https://github.com/thrasher-/gocryptotrader/blob/master/web/src/assets/early-dumb-donate.png?raw=true" hspace="70">
If this framework helped you in any way, or you would like to support the developers working on it, please donate Bitcoin to:
***1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB***
## Binaries
Binaries will be published once the codebase reaches a stable condition.
{{end}}

View File

@@ -0,0 +1,10 @@
{{define "smsglobal" -}}
{{template "header" .Name}}
## Current Features for {{.Name}}
+ This package allows for the messaging of events to a personal phone number or a group of phone numbers
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{end}}

View File

@@ -0,0 +1,10 @@
{{define "testdata" -}}
{{template "header" .Name}}
## Current Features
This folder contains a configuration test file for non-deployement test params.
It also has the code coverage test files that allow us to monitor our entire
codebase, click this link for more information [https://codecov.io/](https://codecov.io/).
{{template "contributions"}}
{{template "donations"}}
{{end}}

View File

@@ -0,0 +1,21 @@
{{define "tools" -}}
{{template "header" .Name}}
## Current Features
This folder contains an assortment of tools
+ Configuration
+ Documentation creation
+ Portfolio monitoring
+ Exchange deployment
+ Websocket client
Example Run for documentation generation - flags -v Verbose & -R Replace files
```
cd documentation/
go run documentation -v
```
{{template "contributions"}}
{{template "donations"}}
{{end}}

View File

@@ -0,0 +1,68 @@
{{define "web" -}}
{{template "header" .Name}}
## Current Features
+ It can run
+ It can be compiled with Electron to run as an executable
+ Websocket support to listen to GoCryptoTrader events
+ Material design
+ Has a semi-working Settings page
+ Has a basic ticker dashboard
## Install dependencies with npm
``` bash
npm install
```
If you want to generate Angular components with Angular-cli , you **MUST** install `@angular/cli` in npm global context.
Please follow [Angular-cli documentation](https://github.com/angular/angular-cli) if you had installed a previous version of `angular-cli`.
``` bash
npm install -g @angular/cli
```
## To build for development
``` bash
npm run start:web
```
Voila! You can use GoCryptoTrader web app in a local development environment with webpack watching!
## To build for production
+ Using development variables (environments/index.ts) : `npm run electron:dev`
+ Using production variables (environments/index.prod.ts) : `npm run electron:prod`
Your built files are in the /dist folder.
## Included Commands
|Command|Description|
|--|--|
|`npm run start:web`| Execute the app in the brower |
|`npm run electron:linux`| Builds your application and creates an app consumable on linux system |
|`npm run electron:windows`| On a Windows OS, builds your application and creates an app consumable in windows 32/64 bit systems |
|`npm run electron:mac`| On a MAC OS, builds your application and generates a `.app` file of your application that can be run on Ma |
## Execute E2E tests
You can find end-to-end tests in /e2e folder.
You can run tests with the command lines below:
+ **in a terminal window** -> First, start a web server on port 4200 : `npm run start:web`
+ **in another terminal window** -> Then, launch Protractor (E2E framework): `npm run e2e`
## Contributors
|User|Github|Contribution|
|--|--|--|
|GloriousCode|https://github.com/gloriouscode |Lead front-end|
|Maxime GRIS|https://github.com/maximegris |Angular4 + Electron Base|
|Shazbert|https://github.com/shazbert |Initial designs|
{{template "contributions"}}
{{template "donations"}}
{{end}}

View File

@@ -0,0 +1,12 @@
{{define "contributions"}}
## Contribution
Please feel free to submit any pull requests or suggest any desired features to be added.
When submitting a PR, please abide by our coding guidelines:
+ Code must adhere to the official Go [formatting](https://golang.org/doc/effective_go.html#formatting) guidelines (i.e. uses [gofmt](https://golang.org/cmd/gofmt/)).
+ Code must be documented adhering to the official Go [commentary](https://golang.org/doc/effective_go.html#commentary) guidelines.
+ Code must adhere to our [coding style](https://github.com/thrasher-/gocryptotrader/blob/master/doc/coding_style.md).
+ Pull requests need to be based on and opened against the `master` branch.
{{end}}

View File

@@ -0,0 +1,9 @@
{{define "donations" -}}
## Donations
<img src="https://github.com/thrasher-/gocryptotrader/blob/master/web/src/assets/early-dumb-donate.png?raw=true" hspace="70">
If this framework helped you in any way, or you would like to support the developers working on it, please donate Bitcoin to:
***1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB***
{{end}}

View File

@@ -0,0 +1,15 @@
{{define "header" -}}
# GoCryptoTrader package {{.}}
<img src="https://github.com/thrasher-/gocryptotrader/blob/master/web/src/assets/page-logo.png?raw=true" width="350px" height="350px" hspace="70">
{{template "status" .}}
This {{.}} package is part of the GoCryptoTrader codebase
## This is still in active development
You can track ideas, planned features and what's in progresss on this Trello board: [https://trello.com/b/ZAhMhpOy/gocryptotrader](https://trello.com/b/ZAhMhpOy/gocryptotrader).
Join our slack to discuss all things related to GoCryptoTrader! [GoCryptoTrader Slack](https://gocryptotrader.herokuapp.com/)
{{end}}

View File

@@ -0,0 +1,7 @@
{{define "status"}}
[![Build Status](https://travis-ci.org/thrasher-/gocryptotrader.svg?branch=master)](https://travis-ci.org/thrasher-/gocryptotrader)
[![Software License](https://img.shields.io/badge/License-MIT-orange.svg?style=flat-square)](https://github.com/thrasher-/gocryptotrader/blob/master/LICENSE)
[![GoDoc](https://godoc.org/github.com/thrasher-/gocryptotrader?status.svg)](https://godoc.org/github.com/thrasher-/gocryptotrader/{{.}})
[![Coverage Status](http://codecov.io/github/thrasher-/gocryptotrader/coverage.svg?branch=master)](http://codecov.io/github/thrasher-/gocryptotrader?branch=master)
[![Go Report Card](https://goreportcard.com/badge/github.com/thrasher-/gocryptotrader)](https://goreportcard.com/report/github.com/thrasher-/gocryptotrader)
{{end}}