-
Notifications
You must be signed in to change notification settings - Fork 131
cmd/docgen: implement documentation generator #132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Is |
cmd/makedocs/main.go
Outdated
package main | ||
|
||
import ( | ||
"html/template" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should probably use text/template
.
This way, there shouldn't be any weird escaping problems in the output.
docs/overview.md
Outdated
|
||
**After** | ||
```go | ||
x := xs[i+1] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These escaped sequences are probably there due to html/template
usage.
Checkers []checker | ||
}{ | ||
Checkers: checkers, | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use bytes.Buffer
for tmpl.Execute
and then do ioutil.WriteFile
.
This way, you don't need to mess around OpenFile
and it's flags, you don't need to close file either.
cmd/makedocs/main.go
Outdated
} | ||
if err != nil { | ||
log.Fatal(err) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What error does it check?
Seems like these 3 lines are not needed here.
cmd/makedocs/main.go
Outdated
if err != nil { | ||
log.Fatal(err) | ||
} | ||
ioutil.WriteFile(docsPath+"overview.md", buf.Bytes(), 0600) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- ioutil.WriteFile(docsPath+"overview.md", buf.Bytes(), 0600)
+ if err := ioutil.WriteFile(docsPath+"overview.md", buf.Bytes(), 0600); err != nil {
+ log.Fatalf("write output file: %v", err)
+ }
cmd/makedocs/main.go
Outdated
if err != nil { | ||
return "", err | ||
} | ||
return string(b), nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- if err != nil {
- return "", err
- }
- return string(b), nil
+ return string(b), err
fixes #132