mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-31 23:16:54 +00:00
Updated documentation tool (#155)
* Updated documentation tool Added templates Updated documentation using tool * Fixed incorrect version in web README * Added new templates to tool. Updated documents in templates across the code base. Used tool to regenerate documentation.
This commit is contained in:
committed by
Adrian Gallagher
parent
aaf9f52a70
commit
3b8591bcc8
@@ -13,24 +13,37 @@ import (
|
||||
)
|
||||
|
||||
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"
|
||||
commonPath = "..%s..%scommon%s"
|
||||
communicationsPath = "..%s..%scommunications%s"
|
||||
communicationsBasePath = "..%s..%scommunications%sbase%s"
|
||||
communicationsSlackPath = "..%s..%scommunications%sslack%s"
|
||||
communicationsSmsglobalPath = "..%s..%scommunications%ssmsglobal%s"
|
||||
communicationsSMTPPath = "..%s..%scommunications%ssmtpservice%s"
|
||||
communicationsTelegramPath = "..%s..%scommunications%stelegram%s"
|
||||
configPath = "..%s..%sconfig%s"
|
||||
currencyPath = "..%s..%scurrency%s"
|
||||
currencyFXPath = "..%s..%scurrency%sforexprovider%s"
|
||||
currencyFXBasePath = "..%s..%scurrency%sforexprovider%sbase%s"
|
||||
currencyFXCurrencyConverterPath = "..%s..%scurrency%sforexprovider%scurrencyconverterapi%s"
|
||||
currencyFXCurrencylayerPath = "..%s..%scurrency%sforexprovider%scurrencylayer%s"
|
||||
currencyFXFixerPath = "..%s..%scurrency%sforexprovider%sfixer.io%s"
|
||||
currencyFXOpenExchangeRatesPath = "..%s..%scurrency%sforexprovider%sopenexchangerates%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"
|
||||
exchangesOrdersPath = "..%s..%sexchanges%sorders%s"
|
||||
exchangesRequestPath = "..%s..%sexchanges%srequest%s"
|
||||
portfolioPath = "..%s..%sportfolio%s"
|
||||
testdataPath = "..%s..%stestdata%s"
|
||||
toolsPath = "..%s..%stools%s"
|
||||
webPath = "..%s..%sweb%s"
|
||||
rootPath = "..%s..%s"
|
||||
|
||||
// exchange packages
|
||||
alphapoint = "..%s..%sexchanges%salphapoint%s"
|
||||
@@ -43,22 +56,22 @@ const (
|
||||
bittrex = "..%s..%sexchanges%sbittrex%s"
|
||||
btcc = "..%s..%sexchanges%sbtcc%s"
|
||||
btcmarkets = "..%s..%sexchanges%sbtcmarkets%s"
|
||||
coinbasepro = "..%s..%sexchanges%scoinbasepro%s"
|
||||
coinut = "..%s..%sexchanges%scoinut%s"
|
||||
exmo = "..%s..%sexchanges%sexmo%s"
|
||||
coinbasepro = "..%s..%sexchanges%scoinbasepro%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"
|
||||
liqui = "..%s..%sexchanges%sliqui%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"
|
||||
|
||||
@@ -74,8 +87,6 @@ var (
|
||||
tmpl *template.Template
|
||||
path string
|
||||
contributors []contributor
|
||||
// exchanges []string{"alphapoint", "anx", "binance", "bitfinex", "bitflyer",
|
||||
// "bithumb"}
|
||||
)
|
||||
|
||||
type readme struct {
|
||||
@@ -93,10 +104,8 @@ type contributor struct {
|
||||
}
|
||||
|
||||
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(`
|
||||
@@ -114,10 +123,14 @@ func main() {
|
||||
log.Fatal("GoCryptoTrader: Exchange documentation tool GET error ", err)
|
||||
}
|
||||
|
||||
fmt.Println("Contributor list fetched")
|
||||
|
||||
if err := addTemplates(); err != nil {
|
||||
log.Fatal("GoCryptoTrader: Exchange documentation tool add template error ", err)
|
||||
}
|
||||
|
||||
fmt.Println("Templates parsed")
|
||||
|
||||
if err := updateReadme(); err != nil {
|
||||
log.Fatal("GoCryptoTrader: Exchange documentation tool update readme error ", err)
|
||||
}
|
||||
@@ -167,23 +180,42 @@ func updateReadme() error {
|
||||
// Adds paths to different potential README.md files in the codebase
|
||||
func addPaths() {
|
||||
codebasePaths["common"] = fmt.Sprintf(commonPath, path, path, path)
|
||||
|
||||
codebasePaths["communications comms"] = fmt.Sprintf(communicationsPath, path, path, path)
|
||||
codebasePaths["communications base"] = fmt.Sprintf(communicationsBasePath, path, path, path, path)
|
||||
codebasePaths["communications slack"] = fmt.Sprintf(communicationsSlackPath, path, path, path, path)
|
||||
codebasePaths["communications smsglobal"] = fmt.Sprintf(communicationsSmsglobalPath, path, path, path, path)
|
||||
codebasePaths["communications smtp"] = fmt.Sprintf(communicationsSMTPPath, path, path, path, path)
|
||||
codebasePaths["communications telegram"] = fmt.Sprintf(communicationsTelegramPath, path, path, path, path)
|
||||
|
||||
codebasePaths["config"] = fmt.Sprintf(configPath, path, path, path)
|
||||
|
||||
codebasePaths["currency"] = fmt.Sprintf(currencyPath, path, path, path)
|
||||
codebasePaths["currency forexprovider"] = fmt.Sprintf(currencyFXPath, path, path, path, path)
|
||||
codebasePaths["currency forexprovider base"] = fmt.Sprintf(currencyFXBasePath, path, path, path, path, path)
|
||||
codebasePaths["currency forexprovider currencyconverter"] = fmt.Sprintf(currencyFXCurrencyConverterPath, path, path, path, path, path)
|
||||
codebasePaths["currency forexprovider currencylayer"] = fmt.Sprintf(currencyFXCurrencylayerPath, path, path, path, path, path)
|
||||
codebasePaths["currency forexprovider fixer"] = fmt.Sprintf(currencyFXFixerPath, path, path, path, path, path)
|
||||
codebasePaths["currency forexprovider openexchangerates"] = fmt.Sprintf(currencyFXOpenExchangeRatesPath, path, path, 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["portfolio"] = fmt.Sprintf(portfolioPath, 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)
|
||||
|
||||
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)
|
||||
codebasePaths["exchanges orders"] = fmt.Sprintf(exchangesOrdersPath, path, path, path, path)
|
||||
codebasePaths["exchanges request"] = fmt.Sprintf(exchangesRequestPath, path, path, path, path)
|
||||
|
||||
codebasePaths["exchanges alphapoint"] = fmt.Sprintf(alphapoint, path, path, path, path)
|
||||
codebasePaths["exchanges anx"] = fmt.Sprintf(anx, path, path, path, path)
|
||||
@@ -260,26 +292,31 @@ func getslashFromName(packageName string) string {
|
||||
return packageName
|
||||
}
|
||||
|
||||
var globS = []string{
|
||||
fmt.Sprintf("common_templates%s*", common.GetOSPathSlash()),
|
||||
fmt.Sprintf("communications_templates%s*", common.GetOSPathSlash()),
|
||||
fmt.Sprintf("config_templates%s*", common.GetOSPathSlash()),
|
||||
fmt.Sprintf("currency_templates%s*", common.GetOSPathSlash()),
|
||||
fmt.Sprintf("events_templates%s*", common.GetOSPathSlash()),
|
||||
fmt.Sprintf("exchanges_templates%s*", common.GetOSPathSlash()),
|
||||
fmt.Sprintf("portfolio_templates%s*", common.GetOSPathSlash()),
|
||||
fmt.Sprintf("root_templates%s*", common.GetOSPathSlash()),
|
||||
fmt.Sprintf("sub_templates%s*", common.GetOSPathSlash()),
|
||||
fmt.Sprintf("testdata_templates%s*", common.GetOSPathSlash()),
|
||||
fmt.Sprintf("tools_templates%s*", common.GetOSPathSlash()),
|
||||
fmt.Sprintf("web_templates%s*", common.GetOSPathSlash()),
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
_, 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 = template.New("")
|
||||
|
||||
tmpl = glob
|
||||
for _, s := range globS {
|
||||
_, err := tmpl.ParseGlob(s)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user