-
Notifications
You must be signed in to change notification settings - Fork 12
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
Adding markdown and html output format #7
base: master
Are you sure you want to change the base?
Conversation
…to the generated html file.
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.
I really like the idea behind this PR.
However I'd rather see some changes made and some tests added for both html
and md
formats.
Cheers
@@ -22,8 +23,11 @@ var ( | |||
todoIdentifiers = []string{"TODO", "FIXME"} | |||
) | |||
|
|||
// TODOs represents a set of todos | |||
type TODOs []*TODO | |||
// TODOContainer represents a set of todos |
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.
I don't really like the idea of creating this wrapper here.
I'd rather keep the old TODOs
struct and if you need the root path in one of the Write
func, you inject it as one of the method argument.
var c = csv.NewWriter(w) | ||
|
||
// Write the headings for the document | ||
if err = c.Write([]string{"Filename", "Line", "Assignee", "Message"}); err != nil { | ||
if err = c.Write([]string{"Path", "Filename", "Line", "Assignee", "Message"}); err != 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.
Since we don't add TODOContainer
, remove this column
@@ -68,6 +68,14 @@ func main() { | |||
if err = todos.WriteJSON(writer); err != nil { | |||
log.Fatal(err) | |||
} | |||
case "md": | |||
if err = todos.WriteMarkdown(writer); err != 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.
Inject *output
here
log.Fatal(err) | ||
} | ||
case "html": | ||
if err = todos.WriteHTML(writer); err != 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.
Inject *output
here
tocBuffer.WriteString("\n</ul>\n") | ||
contentBuffer.WriteString("\n</ul>\n") | ||
|
||
_, err = io.WriteString(w, fmt.Sprintf("<html><head><title>Todos for %s</title><link rel=\"stylesheet\" type=\"text/css\" href=\"todos.css\" /></head><body>%s<hr>%s</body></html>", |
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.
Where is the todo.css
?
Besides adding the new formats I added the TODOContainer struct, which is capturing the path in which the TODOs have been found, in order to use that information in the outputs.