-
Notifications
You must be signed in to change notification settings - Fork 42
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
Enable recursive nested list parsing for docs and add tests #2006
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #2006 +/- ##
==========================================
+ Coverage 60.82% 60.97% +0.14%
==========================================
Files 332 333 +1
Lines 44727 44830 +103
==========================================
+ Hits 27206 27334 +128
+ Misses 15998 15972 -26
- Partials 1523 1524 +1 ☔ View full report in Codecov by Sentry. |
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.
This looks great!
What happens if there is a bulleted list without * `property`
identifiers? What if some (but not all) elements have property identifiers?
pkg/tfgen/docs.go
Outdated
//nolint:lll | ||
func trackBulletListIndentation(line, name string, tracker []bulletListEntry) []bulletListEntry { | ||
listMarkerRegex := regexp.MustCompile("[-*+]") | ||
listMarkerIndex := listMarkerRegex.FindStringIndex(line)[0] |
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.
Will this never be empty?
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.
Correct. It will never be empty because we only run this code if we already detected a bullet listed arg via parseArgFromMarkdownLine.
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.
That would be a great thing to explicitly assert with contract
, or at least explain in a comment.
// https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#nested-lists | ||
// | ||
//nolint:lll | ||
func trackBulletListIndentation(line, name string, tracker []bulletListEntry) []bulletListEntry { |
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.
This algorithm makes a lot of sense.
This code only executes on lines that have already an established property identifier as defined in
Same story, really - keeping in mind that for the purposes of docsPath detection, we do not need to look at any lines that do not match the |
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.
LGTM!
pkg/tfgen/docs.go
Outdated
//nolint:lll | ||
func trackBulletListIndentation(line, name string, tracker []bulletListEntry) []bulletListEntry { | ||
listMarkerRegex := regexp.MustCompile("[-*+]") | ||
listMarkerIndex := listMarkerRegex.FindStringIndex(line)[0] |
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.
That would be a great thing to explicitly assert with contract
, or at least explain in a comment.
Thank you so much🔥 |
Due to [somewhat nonstandard](https://registry.terraform.io/providers/PagerDuty/pagerduty/latest/docs/resources/service) block descriptions, we were omitting some fields on pagerduty.Service doc. This pull request adds a docEdit rule that strips all of the extraneous text from the nested block description and rewrites it to reflect the nested blocks format the bridge expects. This fixes field descriptions for `ServiceSupportHours`, `ServiceScheduledAction`, and `ServiceIncidentUrgencyRule` nested blocks. Note that this PR is also build off of latest bridge rather than a release, to incorporate the much larger markdown parsing changes made in pulumi/pulumi-terraform-bridge#2006. Further note that this PR drops the additional information contained in the irregular block descriptions. This is the current status quo for all Pulumi providers. We additionally do not currently render extra information in the nested properties sections. Closes #477.
This pull request adds recursive parsing for nested lists in upstream docs of the format.
Due to looking at the index of the bullet point list marker in each such line, this addresses the bug underlying #1935 where blank space in front of a top-level list item is permitted in Markdown, as in this example:
Please see the schema diff for docs descriptions for pulumi-pagerduty: https://github.com/pulumi/pulumi-pagerduty/compare/guin/sample-docsgen?expand=1
Fixes #1935.
Partial fix for pulumi/pulumi-pagerduty#477.