-
Notifications
You must be signed in to change notification settings - Fork 43
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
Add an Overview subheader to logically separate Installation and general provider info #2419
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2419 +/- ##
==========================================
- Coverage 57.67% 57.42% -0.25%
==========================================
Files 369 369
Lines 50189 50209 +20
==========================================
- Hits 28948 28835 -113
- Misses 19664 19796 +132
- Partials 1577 1578 +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.
We need to make the overview section conditional on the remaining body not starting with a H2. We don't want to add:
## Overview
## Examples
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.
Can we add a test that shows we drop ## Overview
it has no content.
|
415a9ca
to
a266de6
Compare
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.
The test still feels pretty funny, but otherwise this looks good.
pkg/tfgen/installation_docs.go
Outdated
@@ -107,6 +111,22 @@ func writeInstallationInstructions(goImportBasePath, providerName string) string | |||
) | |||
} | |||
|
|||
func writeOverviewHeader(content []byte) string { | |||
overviewHeader := "## Overview\n\n" |
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.
Go doesn't have much of a const correctness culture, but I think it makes the code much easier to read.
overviewHeader := "## Overview\n\n" | |
const overviewHeader = "## Overview\n\n" |
pkg/tfgen/installation_docs.go
Outdated
@@ -107,6 +111,22 @@ func writeInstallationInstructions(goImportBasePath, providerName string) string | |||
) | |||
} | |||
|
|||
func writeOverviewHeader(content []byte) string { |
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.
write
implies that the function will write something.
func writeOverviewHeader(content []byte) string { | |
func getOverviewHeader(content []byte) string { |
pkg/tfgen/installation_docs.go
Outdated
|
||
func stripSchemaGeneratedByTFPluginDocs(content []byte) []byte { | ||
tfplugindocsComment := regexp.MustCompile("<!-- schema generated by tfplugindocs -->") |
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.
We don't need to compile this multiple times.
func stripSchemaGeneratedByTFPluginDocs(content []byte) []byte { | |
tfplugindocsComment := regexp.MustCompile("<!-- schema generated by tfplugindocs -->") | |
var tfPluginDocsComment = regexp.MustCompile("<!-- schema generated by tfplugindocs -->") | |
func stripSchemaGeneratedByTFPluginDocs(content []byte) []byte { |
@@ -157,6 +157,57 @@ func TestWriteInstallationInstructions(t *testing.T) { | |||
}) | |||
} | |||
|
|||
func TestWriteOverviewHeader(t *testing.T) { |
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'd love if this was a bit higher level, probably by the scope of one function. We shouldn't need to add the header to the body in the test content.
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.
The next level up is testing the whole file conversion. I will add this in another pull request today.
Adding the header to the body here provides more surrounding context, which I was hoping would provide more clarity.
text, err := removeTitle([]byte(contextTest.input)) | ||
require.NoError(t, err) | ||
header := writeOverviewHeader(text) | ||
actual := header + string(text) |
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.
Why do we need this?
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 follows how the surrounding code operates here. It mirrors the context surrounding this function, so we can test on an actual input file, rather than just assert that write/getOverview
does the right thing.
This PR has been shipped in release v3.91.1. |
This pull request is the result of discovering #2420.
This fix:
##
headerTL;DR: while this is on its face a quick fix, we do want to separate the installation from the general text, so adding the Overview header is something we'd want to do anyway.
Screenshots:
Before:
After: