From 51755d214b0a696476d4df8a30ef73570aa6a992 Mon Sep 17 00:00:00 2001 From: Ryan O'Hara-Reid Date: Sun, 18 Feb 2018 19:40:22 +1100 Subject: [PATCH] Added contributor generation function. Applied updates to README docs. --- README.md | 27 +++++++++++++++ tools/documentation/documentation.go | 34 ++++++++++++++++--- .../readme_templates/root_readme.tmpl | 1 + .../sub_templates/contributors.tmpl | 10 ++++++ 4 files changed, 67 insertions(+), 5 deletions(-) create mode 100644 tools/documentation/sub_templates/contributors.tmpl diff --git a/README.md b/README.md index 586633ea..6d56dfe2 100644 --- a/README.md +++ b/README.md @@ -135,3 +135,30 @@ If this framework helped you in any way, or you would like to support the develo ## Binaries Binaries will be published once the codebase reaches a stable condition. + +## Contributor List + +|User|Github|Contribution Amount| +|--|--|--| +| thrasher- | https://api.github.com/users/thrasher- | 411 | +| gloriousCode | https://api.github.com/users/gloriousCode | 113 | +| shazbert | https://api.github.com/users/shazbert | 108 | +| 140am | https://api.github.com/users/140am | 8 | +| faddat | https://api.github.com/users/faddat | 4 | +| crackcomm | https://api.github.com/users/crackcomm | 3 | +| bretep | https://api.github.com/users/bretep | 2 | +| gam-phon | https://api.github.com/users/gam-phon | 2 | +| cornelk | https://api.github.com/users/cornelk | 2 | +| if1live | https://api.github.com/users/if1live | 2 | +| daniel-cohen | https://api.github.com/users/daniel-cohen | 1 | +| starit | https://api.github.com/users/starit | 1 | +| mattkanwisher | https://api.github.com/users/mattkanwisher | 1 | +| mKurrels | https://api.github.com/users/mKurrels | 1 | +| m1kola | https://api.github.com/users/m1kola | 1 | +| tongxiaofeng | https://api.github.com/users/tongxiaofeng | 1 | +| idealhack | https://api.github.com/users/idealhack | 1 | +| askew- | https://api.github.com/users/askew- | 1 | +| snipesjr | https://api.github.com/users/snipesjr | 1 | + + + diff --git a/tools/documentation/documentation.go b/tools/documentation/documentation.go index ca034771..6c56621e 100644 --- a/tools/documentation/documentation.go +++ b/tools/documentation/documentation.go @@ -29,6 +29,8 @@ const ( toolsPath = "..%s..%stools%s" webPath = "..%s..%sweb%s" rootPath = "..%s..%s" + + contributorsList = "https://api.github.com/repos/thrasher-/gocryptotrader/contributors" ) var ( @@ -38,11 +40,18 @@ var ( codebaseReadme map[string]readme tmpl *template.Template path string + contributors []contributor ) type readme struct { Name string - Contributors string + Contributors []contributor +} + +type contributor struct { + Login string `json:"login"` + URL string `json:"url"` + Contributions int `json:"contributions"` } func main() { @@ -63,6 +72,11 @@ func main() { codebaseTemplatePath = make(map[string]string) codebaseReadme = make(map[string]readme) path = common.GetOSPathSlash() + + if err := getContributorList(); err != nil { + log.Fatal("GoCryptoTrader: Exchange documentation tool GET error ", err) + } + if err := addTemplates(); err != nil { log.Fatal("GoCryptoTrader: Exchange documentation tool add template error ", err) } @@ -87,7 +101,9 @@ func updateReadme() error { fmt.Printf("* %s Readme file FOUND.\n", packageName) } if replace { - fmt.Println("file replacement") + if verbose { + fmt.Println("file replacement") + } if err := replaceReadme(packageName); err != nil { return err } @@ -99,7 +115,9 @@ func updateReadme() error { fmt.Printf("* %s Readme file NOT FOUND.\n", packageName) } if replace { - log.Println("file creation") + if verbose { + log.Println("file creation") + } if err := createReadme(packageName); err != nil { return err } @@ -134,7 +152,7 @@ func addPaths() { func addReadmeData(packageName string) { readmeInfo := readme{ Name: packageName, - Contributors: "", //future implementation to track contributors + Contributors: contributors, } codebaseReadme[packageName] = readmeInfo } @@ -175,10 +193,16 @@ func createReadme(packageName string) error { if err != nil { return err } - fmt.Println("File done") + if verbose { + fmt.Println("File done") + } return tmpl.ExecuteTemplate(file, packageName, codebaseReadme[packageName]) } func deleteFile(path string) error { return os.Remove(path) } + +func getContributorList() error { + return common.SendHTTPGetRequest(contributorsList, true, false, &contributors) +} diff --git a/tools/documentation/readme_templates/root_readme.tmpl b/tools/documentation/readme_templates/root_readme.tmpl index 11ce4ab8..d12ca03c 100644 --- a/tools/documentation/readme_templates/root_readme.tmpl +++ b/tools/documentation/readme_templates/root_readme.tmpl @@ -118,4 +118,5 @@ If this framework helped you in any way, or you would like to support the develo ## Binaries Binaries will be published once the codebase reaches a stable condition. +{{template "contributors" .}} {{end}} diff --git a/tools/documentation/sub_templates/contributors.tmpl b/tools/documentation/sub_templates/contributors.tmpl new file mode 100644 index 00000000..123c6ca4 --- /dev/null +++ b/tools/documentation/sub_templates/contributors.tmpl @@ -0,0 +1,10 @@ +{{define "contributors"}} +## Contributor List + +|User|Github|Contribution Amount| +|--|--|--| +{{ range $contributor := .Contributors -}} +| {{$contributor.Login}} | {{$contributor.URL}} | {{$contributor.Contributions}} | +{{ end }} + +{{end}}