Added new functionality for documentation tool.

Added new documents to list to track the entire project document range.
This commit is contained in:
Ryan O'Hara-Reid
2018-02-28 09:53:41 +11:00
parent 63473d7057
commit bb2342ee99
31 changed files with 464 additions and 3 deletions

View File

@@ -7,6 +7,7 @@ import (
"log"
"os"
"strings"
"time"
"github.com/thrasher-/gocryptotrader/common"
)
@@ -31,7 +32,38 @@ const (
webPath = "..%s..%sweb%s"
rootPath = "..%s..%s"
// exchange packages
alphapoint = "..%s..%sexchanges%salphapoint%s"
anx = "..%s..%sexchanges%sanx%s"
binance = "..%s..%sexchanges%sbinance%s"
bitfinex = "..%s..%sexchanges%sbitfinex%s"
bitflyer = "..%s..%sexchanges%sbitflyer%s"
bithumb = "..%s..%sexchanges%sbithumb%s"
bitstamp = "..%s..%sexchanges%sbitstamp%s"
bittrex = "..%s..%sexchanges%sbittrex%s"
btcc = "..%s..%sexchanges%sbtcc%s"
btcmarkets = "..%s..%sexchanges%sbtcmarkets%s"
coinut = "..%s..%sexchanges%scoinut%s"
exmo = "..%s..%sexchanges%sexmo%s"
gdax = "..%s..%sexchanges%sgdax%s"
gemini = "..%s..%sexchanges%sgemini%s"
hitbtc = "..%s..%sexchanges%shitbtc%s"
huobi = "..%s..%sexchanges%shuobi%s"
itbit = "..%s..%sexchanges%sitbit%s"
kraken = "..%s..%sexchanges%skraken%s"
lakebtc = "..%s..%sexchanges%slakebtc%s"
localbitcoins = "..%s..%sexchanges%slocalbitcoins%s"
okcoin = "..%s..%sexchanges%sokcoin%s"
okex = "..%s..%sexchanges%sokex%s"
poloniex = "..%s..%sexchanges%spoloniex%s"
wex = "..%s..%sexchanges%swex%s"
yobit = "..%s..%sexchanges%syobit%s"
liqui = "..%s..%sexchanges%sliqui%s"
contributorsList = "https://api.github.com/repos/thrasher-/gocryptotrader/contributors"
licenseName = "LICENSE"
contributorName = "CONTRIBUTORS"
)
var (
@@ -42,12 +74,16 @@ var (
tmpl *template.Template
path string
contributors []contributor
// exchanges []string{"alphapoint", "anx", "binance", "bitfinex", "bitflyer",
// "bithumb"}
)
type readme struct {
Name string
Contributors []contributor
NameURL string
Year int
CapitalName string
}
type contributor struct {
@@ -149,24 +185,77 @@ func addPaths() {
codebasePaths["tools"] = fmt.Sprintf(toolsPath, path, path, path)
codebasePaths["web"] = fmt.Sprintf(webPath, path, path, path)
codebasePaths["root"] = fmt.Sprintf(rootPath, path, path)
codebasePaths["exchanges alphapoint"] = fmt.Sprintf(alphapoint, path, path, path, path)
codebasePaths["exchanges anx"] = fmt.Sprintf(anx, path, path, path, path)
codebasePaths["exchanges binance"] = fmt.Sprintf(binance, path, path, path, path)
codebasePaths["exchanges bitfinex"] = fmt.Sprintf(bitfinex, path, path, path, path)
codebasePaths["exchanges bitflyer"] = fmt.Sprintf(bitflyer, path, path, path, path)
codebasePaths["exchanges bithumb"] = fmt.Sprintf(bithumb, path, path, path, path)
codebasePaths["exchanges bitstamp"] = fmt.Sprintf(bitstamp, path, path, path, path)
codebasePaths["exchanges bittrex"] = fmt.Sprintf(bittrex, path, path, path, path)
codebasePaths["exchanges btcc"] = fmt.Sprintf(btcc, path, path, path, path)
codebasePaths["exchanges btcmarkets"] = fmt.Sprintf(btcmarkets, path, path, path, path)
codebasePaths["exchanges coinut"] = fmt.Sprintf(coinut, path, path, path, path)
codebasePaths["exchanges exmo"] = fmt.Sprintf(exmo, path, path, path, path)
codebasePaths["exchanges gdax"] = fmt.Sprintf(gdax, path, path, path, path)
codebasePaths["exchanges gemini"] = fmt.Sprintf(gemini, path, path, path, path)
codebasePaths["exchanges hitbtc"] = fmt.Sprintf(hitbtc, path, path, path, path)
codebasePaths["exchanges huobi"] = fmt.Sprintf(huobi, path, path, path, path)
codebasePaths["exchanges itbit"] = fmt.Sprintf(itbit, path, path, path, path)
codebasePaths["exchanges kraken"] = fmt.Sprintf(kraken, path, path, path, path)
codebasePaths["exchanges lakebtc"] = fmt.Sprintf(lakebtc, path, path, path, path)
codebasePaths["exchanges liqui"] = fmt.Sprintf(liqui, path, path, path, path)
codebasePaths["exchanges localbitcoins"] = fmt.Sprintf(localbitcoins, path, path, path, path)
codebasePaths["exchanges okcoin"] = fmt.Sprintf(okcoin, path, path, path, path)
codebasePaths["exchanges okex"] = fmt.Sprintf(okex, path, path, path, path)
codebasePaths["exchanges poloniex"] = fmt.Sprintf(poloniex, path, path, path, path)
codebasePaths["exchanges wex"] = fmt.Sprintf(wex, path, path, path, path)
codebasePaths["exchanges yobit"] = fmt.Sprintf(yobit, path, path, path, path)
codebasePaths["CONTRIBUTORS"] = fmt.Sprintf(rootPath, path, path)
codebasePaths["LICENSE"] = fmt.Sprintf(rootPath, path, path)
}
func addReadmeData(packageName string) {
readmeInfo := readme{
Name: packageName,
Name: getName(packageName, false),
Contributors: contributors,
NameURL: getslashFromName(packageName),
Year: time.Now().Year(),
CapitalName: getName(packageName, true),
}
codebaseReadme[packageName] = readmeInfo
}
func getName(name string, capital bool) string {
newStrings := strings.Split(name, " ")
if len(newStrings) > 1 {
if capital {
return getCapital(newStrings[1])
}
return newStrings[1]
}
if capital {
return getCapital(name)
}
return name
}
func getCapital(name string) string {
cap := strings.ToUpper(string(name[0]))
last := name[1:]
return cap + last
}
// returns a string for godoc package names
func getslashFromName(packageName string) string {
if strings.Contains(packageName, " ") {
s := strings.Split(packageName, " ")
return strings.Join(s, "/")
}
if packageName == "testdata" || packageName == "tools" {
if packageName == "testdata" || packageName == "tools" || packageName == contributorName || packageName == licenseName {
return ""
}
return packageName
@@ -182,6 +271,14 @@ func addTemplates() error {
if err != nil {
return err
}
_, err = glob.ParseGlob(fmt.Sprintf("exchange_readme_templates%s*", path))
if err != nil {
return err
}
_, err = glob.ParseGlob(fmt.Sprintf("general_templates%s*", path))
if err != nil {
return err
}
tmpl = glob
return nil
@@ -189,12 +286,22 @@ func addTemplates() error {
// checkReadme checks to see if the file exists
func checkReadme(packageName string) bool {
if packageName == licenseName || packageName == contributorName {
_, err := os.Stat(codebasePaths[packageName] + packageName)
return os.IsNotExist(err)
}
_, err := os.Stat(codebasePaths[packageName] + "README.md")
return os.IsNotExist(err)
}
// replaces readme file
func replaceReadme(packageName string) error {
if packageName == licenseName || packageName == contributorName {
if err := deleteFile(codebasePaths[packageName] + packageName); err != nil {
return err
}
return createReadme(packageName)
}
if err := deleteFile(codebasePaths[packageName] + "README.md"); err != nil {
return err
}
@@ -203,6 +310,17 @@ func replaceReadme(packageName string) error {
// creates new readme file and executes template
func createReadme(packageName string) error {
if packageName == licenseName || packageName == contributorName {
file, err := os.Create(codebasePaths[packageName] + packageName)
defer file.Close()
if err != nil {
return err
}
if verbose {
fmt.Println("File done")
}
return tmpl.ExecuteTemplate(file, packageName, codebaseReadme[packageName])
}
file, err := os.Create(codebasePaths[packageName] + "README.md")
defer file.Close()
if err != nil {

View File

@@ -0,0 +1,12 @@
{{define "exchanges alphapoint" -}}
{{template "header" .}}
## Alphapoint Exchange
### Current Features
+ Initial generation
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{end}}

View File

@@ -0,0 +1,12 @@
{{define "exchanges anx" -}}
{{template "header" .}}
## ANX Exchange
### Current Features
+ Initial generation
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{end}}

View File

@@ -0,0 +1,12 @@
{{define "exchanges binance" -}}
{{template "header" .}}
## Binance Exchange
### Current Features
+ Initial generation
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{end}}

View File

@@ -0,0 +1,12 @@
{{define "exchanges bitfinex" -}}
{{template "header" .}}
## Bitfinex Exchange
### Current Features
+ Initial generation
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{end}}

View File

@@ -0,0 +1,12 @@
{{define "exchanges bitflyer" -}}
{{template "header" .}}
## Bitflyer Exchange
### Current Features
+ Initial generation
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{end}}

View File

@@ -0,0 +1,12 @@
{{define "exchanges bithumb" -}}
{{template "header" .}}
## Bithumb Exchange
### Current Features
+ Initial generation
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{end}}

View File

@@ -0,0 +1,12 @@
{{define "exchanges bitstamp" -}}
{{template "header" .}}
## Bitstamp Exchange
### Current Features
+ Initial generation
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{end}}

View File

@@ -0,0 +1,12 @@
{{define "exchanges bittrex" -}}
{{template "header" .}}
## Bittrex Exchange
### Current Features
+ Initial generation
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{end}}

View File

@@ -0,0 +1,12 @@
{{define "exchanges btcc" -}}
{{template "header" .}}
## BTCC Exchange
### Current Features
+ Initial generation
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{end}}

View File

@@ -0,0 +1,12 @@
{{define "exchanges btcmarkets" -}}
{{template "header" .}}
## BTCMarkets Exchange
### Current Features
+ Initial generation
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{end}}

View File

@@ -0,0 +1,12 @@
{{define "exchanges coinut" -}}
{{template "header" .}}
## Coinut Exchange
### Current Features
+ Initial generation
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{end}}

View File

@@ -0,0 +1,12 @@
{{define "exchanges exmo" -}}
{{template "header" .}}
## Exmo Exchange
### Current Features
+ Initial generation
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{end}}

View File

@@ -0,0 +1,12 @@
{{define "exchanges gdax" -}}
{{template "header" .}}
## GDAX Exchange
### Current Features
+ Initial generation
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{end}}

View File

@@ -0,0 +1,12 @@
{{define "exchanges gemini" -}}
{{template "header" .}}
## Gemini Exchange
### Current Features
+ Initial generation
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{end}}

View File

@@ -0,0 +1,12 @@
{{define "exchanges hitbtc" -}}
{{template "header" .}}
## HitBTC Exchange
### Current Features
+ Initial generation
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{end}}

View File

@@ -0,0 +1,12 @@
{{define "exchanges huobi" -}}
{{template "header" .}}
## Huobi Exchange
### Current Features
+ Initial generation
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{end}}

View File

@@ -0,0 +1,12 @@
{{define "exchanges itbit" -}}
{{template "header" .}}
## Itbit Exchange
### Current Features
+ Initial generation
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{end}}

View File

@@ -0,0 +1,12 @@
{{define "exchanges kraken" -}}
{{template "header" .}}
## Kraken Exchange
### Current Features
+ Initial generation
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{end}}

View File

@@ -0,0 +1,12 @@
{{define "exchanges lakebtc" -}}
{{template "header" .}}
## LakeBTC Exchange
### Current Features
+ Initial generation
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{end}}

View File

@@ -0,0 +1,12 @@
{{define "exchanges liqui" -}}
{{template "header" .}}
## Liqui Exchange
### Current Features
+ Initial generation
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{end}}

View File

@@ -0,0 +1,12 @@
{{define "exchanges localbitcoins" -}}
{{template "header" .}}
## LocalBitcoins Exchange
### Current Features
+ Initial generation
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{end}}

View File

@@ -0,0 +1,12 @@
{{define "exchanges okcoin" -}}
{{template "header" .}}
## OKCoin Exchange
### Current Features
+ Initial generation
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{end}}

View File

@@ -0,0 +1,12 @@
{{define "exchanges okex" -}}
{{template "header" .}}
## OKex Exchange
### Current Features
+ Initial generation
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{end}}

View File

@@ -0,0 +1,12 @@
{{define "exchanges poloniex" -}}
{{template "header" .}}
## Poloniex Exchange
### Current Features
+ Initial generation
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{end}}

View File

@@ -0,0 +1,12 @@
{{define "exchanges wex" -}}
{{template "header" .}}
## Wex Exchange
### Current Features
+ Initial generation
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{end}}

View File

@@ -0,0 +1,12 @@
{{define "exchanges yobit" -}}
{{template "header" .}}
## Yobit Exchange
### Current Features
+ Initial generation
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{end}}

View File

@@ -0,0 +1,6 @@
{{define "CONTRIBUTORS"}}
Thanks to the following contributors:
{{ range $contributor := .Contributors -}}
{{$contributor.Login}} | {{$contributor.URL}}
{{ end }}
{{end}}

View File

@@ -0,0 +1,23 @@
{{define "LICENSE" -}}
The MIT License (MIT)
Copyright (c) 2014-{{- .Year}} The GoCryptoTrader Developers
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
{{end}}

View File

@@ -1,6 +1,8 @@
{{define "contributors"}}
## Contributor List
### A very special thank you to all who have contributed to this program:
|User|Github|Contribution Amount|
|--|--|--|
{{ range $contributor := .Contributors -}}

View File

@@ -1,5 +1,5 @@
{{define "header" -}}
# GoCryptoTrader package {{.Name}}
# GoCryptoTrader package {{.CapitalName}}
<img src="https://github.com/thrasher-/gocryptotrader/blob/master/web/src/assets/page-logo.png?raw=true" width="350px" height="350px" hspace="70">