Skip to content

Commit

Permalink
Added contributor generation function. Applied updates to README docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
shazbert committed Feb 19, 2018
1 parent 6cb17bb commit 51755d2
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 5 deletions.
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |



34 changes: 29 additions & 5 deletions tools/documentation/documentation.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -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() {
Expand All @@ -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)
}
Expand All @@ -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
}
Expand All @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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)
}
1 change: 1 addition & 0 deletions tools/documentation/readme_templates/root_readme.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
10 changes: 10 additions & 0 deletions tools/documentation/sub_templates/contributors.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{{define "contributors"}}
## Contributor List

|User|Github|Contribution Amount|
|--|--|--|
{{ range $contributor := .Contributors -}}
| {{$contributor.Login}} | {{$contributor.URL}} | {{$contributor.Contributions}} |
{{ end }}

{{end}}

0 comments on commit 51755d2

Please sign in to comment.