Conversation
… as a parameter.
bendbennett
approved these changes
Nov 27, 2023
Contributor
bendbennett
left a comment
There was a problem hiding this comment.
LGTM 🚀
Only question I had was whether there are any instances in which these changes will result in different behaviour, and if so, whether this should be documented?
|
I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes: #9
Fixes: #191
Fixes: #193
Supersedes: #185
The
renderMissingResourceDoc()andrenderMissingProviderDoc()methods determine if there are any existing templates for a given resource/datasource and if not, generates new templates either by using the default templates or by generating templates from generic "fallback" templates if they exist (i.e.templates/resources.tmpl.md). When new templates are generated in these methods, they are rendered to.mdfiles. After these methods are called, therenderStaticWebsite()method is called to render the template files to.mdfiles and copy them into the rendered website directory. This means that templates generated during therenderMissingResourceDoc()andrenderMissingProviderDoc()methods are rendered to markdown twice leading to confusing and inconsistent behavior around theprintffunction which should print a string literal but would instead render the string as actual markdown.The default templates use
printfto show example syntax of how to call thecodefileandtffilefunctions:but because of this bug, they ended up rendering as actual markdown:
instead of the expected string literal:
The changes in
cmd/tfplugindocs/testdata/scripts/schema-json/generate/framework_provider_success_generic_templates.txtardemonstrate this difference.This PR fixes the bug by removing template rendering code from
renderMissingResourceDoc()andrenderMissingProviderDoc()methods and refactoring these methods to make their purposes clearer. New acceptance tests have been added to test the behavior of static files that skip new template generation.Because there may be developers using this tool who have relied on the default templates to generate docs with rendered examples, I choose to change the default templates to accommodate this after fixing the bug.