-
Notifications
You must be signed in to change notification settings - Fork 9
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
Update release notes parsing #502
base: trunk
Are you sure you want to change the base?
Changes from 5 commits
1c9058f
baac2e7
add2aac
7bc0a80
265ffb9
6d6b969
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,23 @@ | |
HEADER | ||
end | ||
|
||
it 'adds a new section after any `#` comments on top' do | ||
run_release_notes_test <<~HEADER | ||
# This is a Markdown header | ||
## This is another kind of Markdown header | ||
### This is an H3 Markdown header | ||
|
||
HEADER | ||
end | ||
Comment on lines
+25
to
+32
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I feel like this might not be what we want, because while the I'm not fully sure that our current For that reason, I'm not sure I agree for us to consider An alternative that we could consider would be to use HTML comments:
I think that solution shouldn't be too hard to implement, something like: line_idx = if lines.first.start_with('<!--')
lines.find_index { |l| l.end_with('-->') } &+ 1
else
lines.find_index { |l| l.chomp == '<!-- INSTRUCTION END MARKER -->' } &+ 1
end
line_idx ||= lines.finx_index { |l| !l.start_with('***') && !l.start_with('//') && !l.chomp.empty? } That way, if the file starts with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I really like this approach! Seems much simpler and easy to just have anything above a |
||
|
||
it 'adds a new section after any `- ` comments on top' do | ||
run_release_notes_test <<~HEADER | ||
- This is a line item | ||
- And this is another line item that we want to include | ||
|
||
HEADER | ||
end | ||
|
||
it 'does consider empty lines as header' do | ||
run_release_notes_test("\n\n\n") | ||
end | ||
|
@@ -35,20 +52,20 @@ | |
*** with both double-slash style comment lines | ||
*** and triple-star style ones. | ||
|
||
- List item | ||
- Another list item | ||
|
||
# Markdown Header | ||
## H2 Markdown Header | ||
|
||
|
||
|
||
|
||
// It also contains some empty lines we want to count as part of the pinned lines. | ||
|
||
HEADER | ||
end | ||
|
||
it 'does not consider # as comments' do | ||
prefix = <<~NOT_HEADER | ||
# This is not a comment | ||
NOT_HEADER | ||
run_release_notes_test('', prefix + FAKE_CONTENT) | ||
end | ||
|
||
Comment on lines
-45
to
-51
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test isn't needed anymore now that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it could be worth it to make sure that any line starting with |
||
it 'does not consider ** as comments' do | ||
prefix = <<~NOT_HEADER | ||
** This is not a comment | ||
|
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.
Rubocop says this formatting is fine, but it seems strange to have the last four lines indented more.
I broke them into separate lines for readability. Is there a better way of doing it?
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 think the additional indentation is because the subsequent lines are a continuation of the first line so I agree it can look strange, but it's expected at least.
Another option would be to extract this condition in a function to make this line shorter and use an array of comment prefixes. Something like:
Then we could go back to write this code as a one-liner: