9388c54be7
<!--- Thanks so much for your contribution! If this is your first time contributing, please ensure that you have read the [CONTRIBUTING](https://github.com/pulumi/pulumi/blob/master/CONTRIBUTING.md) documentation. --> # Description Originally motivated by uncontrolled pseudo-recurcive type expansion in AWS WafV2, we've limited the number of types that we should in the docs to 200: https://github.com/pulumi/pulumi/pull/12070 Our large customer that publishes their own packages and docs came back to us and said they have legitimate use cases with more than 200 types: #15507 I've grabbed stats about our current packages and still found a few offenders: ``` "aws:lex/v2modelsIntent:V2modelsIntent" 920 "aws:wafv2/ruleGroup:RuleGroup" 310 "aws:wafv2/webAcl:WebAcl" 523 "azure-native:datafactory:Dataset" 256 "azure-native:datafactory:LinkedService" 299 "azure-native:datafactory:Pipeline" 618 "azure-native:datamigration:ServiceTask" 291 "azure-native:datamigration:Task" 291 "aws-native:quicksight:Analysis" 589 "aws-native:quicksight:Dashboard" 606 "aws-native:quicksight:Template" 590 ``` Therefore, I'm not entirely removing the limit in this PR, but a) bumping the default to 1000 b) applying 200 to the known offenders only I don't love it's hard coded, but I haven't found a place to add simple configuration nob. Anyway, it's slightly less hard-coded than it used to be. Fixes #15507 ## Checklist - [x] I have run `make tidy` to update any new dependencies - [x] I have run `make lint` to verify my code passes the lint check - [ ] I have formatted my code using `gofumpt` <!--- Please provide details if the checkbox below is to be left unchecked. --> - [x] I have added tests that prove my fix is effective or that my feature works - Existing docs gen tests cover that I haven't broken anything - I re-generated the AWS docs and they had no changes <!--- User-facing changes require a CHANGELOG entry. --> - [x] I have run `make changelog` and committed the `changelog/pending/<file>` documenting my change <!-- If the change(s) in this PR is a modification of an existing call to the Pulumi Cloud, then the service should honor older versions of the CLI where this change would not exist. You must then bump the API version in /pkg/backend/httpstate/client/api.go, as well as add it to the service. --> - [ ] Yes, there are changes in this PR that warrants bumping the Pulumi Cloud API version <!-- @Pulumi employees: If yes, you must submit corresponding changes in the service repo. --> |
||
---|---|---|
.. | ||
templates | ||
testdata | ||
README.md | ||
constructor_syntax_extractor.go | ||
constructor_syntax_generator.go | ||
constructor_syntax_generator_test.go | ||
description.go | ||
description_test.go | ||
examples.go | ||
gen.go | ||
gen_function.go | ||
gen_kubernetes.go | ||
gen_method.go | ||
gen_test.go | ||
package_tree.go | ||
package_tree_test.go | ||
static_schema_loader.go | ||
utils.go | ||
utils_test.go |
README.md
Docs generator
This generator generates resource-level docs by utilizing the Pulumi schema.
Crash course on templates
The templates use Go's built-in html/template
package to process templates with data. The driver for this doc generator (e.g. tfbridge for TF-based providers) then persists each file from memory onto the disk as .md
files.
Although we are using the html/template
package, it has the same exact interface as the text/template
package, except for some HTML specific things. Therefore, all of the functions available in the text/template
package are also available with the html/template
package.
- Data can be injected using
{{.PropertyName}}
. - Nested properties can be accessed using the dot notation, i.e.
{{.Property1.Property2}}
. - Templates can inject other templates using the
{{template "template_name"}}
directive.- For this to work, you will need to first define the named template using
{{define "template_name"}}
.
- For this to work, you will need to first define the named template using
- You can pass data to nested templates by simply passing an argument after the template's name.
- To remove whitespace from injected values, use the
-
in the template tags.- For example,
{{if .SomeBool}} some text {{- else}} some other text {{- end}}
. Note the use of-
to eliminate whitespace from the enclosing text. - Read more here.
- For example,
- To render un-encoded content use the custom global function
htmlSafe
.- Note: This should only be used if you know for sure you are not injecting any user-generated content, as it by-passes the HTML encoding.
- To render strings to Markdown, use the custom global function
markdownify
. - To print regular strings, that share the same syntax as the Go templating engine, use the built-in global function
print
function.
Learn more from here: https://curtisvermeeren.github.io/2017/09/14/Golang-Templates-Cheatsheet
Modifying templates and updating tests
We run tests that validate our template-rendering output. If you need to make change that produces a set of Markdown files that differs from the set that we use in our tests (see codegen/testing/test/testdata/**/*.md
), your pull-request checks will fail, and to get them to pass, you'll need to modify the test data to match the output produced by your change.
For minor diffs, you can just update the test files manually and include those updates with your PR. But for large diffs, you may want to regenerate the full set. To do that, from the root of the repo, run:
cd pkg/codegen/docs && PULUMI_ACCEPT=true go test . && cd -