Skip to content

Remove document.RenderMarkdown function #1274

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

Merged
merged 1 commit into from
May 8, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 0 additions & 64 deletions pkg/notes/document/document.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,70 +322,6 @@ func (d *Document) template(templateSpec string) (string, error) {
return string(b), nil
}

// RenderMarkdown accepts a Document and writes a version of that document to
// supplied io.Writer in markdown format.
//
// Deprecated: Prefer using the golang template instead of markdown. Will be removed in #1019
func (d *Document) RenderMarkdown(bucket, tars, prevTag, newTag string) (string, error) {
o := &strings.Builder{}
if err := CreateDownloadsTable(o, bucket, tars, prevTag, newTag); err != nil {
return "", err
}

nl := func() {
o.WriteRune('\n')
}
nlnl := func() {
nl()
nl()
}

// writeNote encapsulates the pre-processing that might happen on a note text
// before it gets bulleted and written to the io.Writer
writeNote := func(s string) {
const prefix = "- "
if !strings.HasPrefix(s, prefix) {
o.WriteString(prefix)
}
o.WriteString(s)
nl()
}

// notes with action required get their own section
if len(d.NotesWithActionRequired) > 0 {
o.WriteString("## Urgent Upgrade Notes")
nlnl()
o.WriteString("### (No, really, you MUST read this before you upgrade)")
nlnl()
for _, note := range d.NotesWithActionRequired {
writeNote(note)
nl()
}
}

// each Kind gets a section
if len(d.Notes) > 0 {
o.WriteString("## Changes by Kind")
nlnl()

d.Notes.Sort(kindPriority)
for _, category := range d.Notes {
o.WriteString("### ")
o.WriteString(prettyKind(category.Kind))
nlnl()

sort.Strings(*category.NoteEntries)
for _, note := range *category.NoteEntries {
writeNote(note)
}
nl()
}
nlnl()
}

return strings.TrimSpace(o.String()), nil
}

// CreateDownloadsTable creates the markdown table with the links to the tarballs.
// The function does nothing if the `tars` variable is empty.
func CreateDownloadsTable(w io.Writer, bucket, tars, prevTag, newTag string) error {
Expand Down