Skip to content

Component markdown help#80

Merged
arl merged 18 commits intomainfrom
component-markdown-help
Nov 12, 2020
Merged

Component markdown help#80
arl merged 18 commits intomainfrom
component-markdown-help

Conversation

@arl
Copy link
Copy Markdown
Collaborator

@arl arl commented Nov 11, 2020

❓ What

Implement markdown generation from component description structures.

🔨 How to test

  1. List all steps necessary;
  2. To test this pull request.

✅ Checklists

This section contains a list of checklists for common uses, please delete the checklists that are useless for your current use case (or add another checklist if your use case isn't covered yet).

  • Is there unit/integration test coverage for all new and/or changed functionality added in this PR?
  • Have the changes in this PR been functionally tested?
  • Has make gofmt-write been run on the code?
  • Has make govet been run on the code? Has the code been fixed accordingly to the output?
  • Have the changes been added to the CHANGELOG.md file?
  • Have the steps in CONTRIBUTING.md been followed to update a Go module?

@arl arl requested a review from tommyblue November 11, 2020 18:50
Copy link
Copy Markdown
Contributor

@tommyblue tommyblue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgmt! nice work

Comment thread markdown_help.go
@@ -0,0 +1,161 @@
package baker
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

at first glance I'd had called these files help_text and help_markdown, to visually group all together. It it a convention to call them with the trailing _help?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment thread help.go Outdated
Comment thread help.go Outdated
}

// RenderHelpMarkdown calls PrintHelp withy format markdown but render the
// markdown for terminal consulation.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consulation -> consultation?

Comment thread help.go Outdated
return h, nil
}

func dumpConfigHelp(w io.Writer, cfg interface{}) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unused

Comment thread help.go Outdated
fmt.Fprint(w, sep, "\n")
}

/*
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

leftover?

Comment thread markdown_help.go
return nil
}

func breakAfterDots(s string) string {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in markdown, newline requires two spaces before a \n if we don't want to leave a blank line or \n\n otherwise. A single \n is rendered as a simple space without newline.

Copy link
Copy Markdown
Collaborator Author

@arl arl Nov 12, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uh?! a single \n is rendered as a \n in markdown when it's at the end of a text line.

The objective here is to add a carriage return (i.e just go to the next line) and this is what that does.
What you're saying with the 2 spaces is \n\n is if you want to force a line jump on a blank line.
Here we're not dealing with blank lines, but line with text, so adding \n does what is expected.
Don't you agree?

Copy link
Copy Markdown
Contributor

@tommyblue tommyblue Nov 12, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no really, markdown specs says that 2 spaces + \n correspond to a line break :) https://www.markdownguide.org/basic-syntax/#line-breaks
most markdown renderers also render a single \n as a line break, but many others, including GH, don't

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

while 2 blank lines create a paragraph https://www.markdownguide.org/basic-syntax/#paragraphs-1

Comment thread markdown_test.go Outdated
Comment thread go.sum
@arl arl merged commit e7de842 into main Nov 12, 2020
@arl arl deleted the component-markdown-help branch November 12, 2020 14:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants