bf251932ef
Fixes: https://github.com/pulumi/registry/issues/3724 Fixes: https://github.com/pulumi/registry/issues/2966 This PR is to resolve the enum rendering issue. The enums were not being rendered on the page at all due to a misconfigured language choosable (i.e. `<pulumi-choosable>`) that wraps the enum section. I found out this had to do with the lang property being set as `nodejs` when instead the choosable expects `javascript` or `typescript` as the valid values. I then followed the pattern of what we seem to be doing for the other pulumi-choosables which have this issue, which is to have an if statement that sets it to `javascript,typescript` if `nodejs` is given. This is how the rendering looks now. I have not adjusted any layouts of the template or anything along those lines, only fixed the choosable. I am wondering if this is actually what was intended for these, as we have a display name in the left column that is ~useless IMO and the right column has the value. I am assuming this was done to match the formatting of the other nested types that are displayed since these enums are treated as such. Though I don't think it is optimal for what we are trying to present given that we do not have descriptions for any of the individual enum values and what they represent. Should we consider doing something like having a separate enum section that is more purpose built for the data we can display where we just have the enum type in the left column, followed by the valid enum values in the right column. For example: | Instance Type | a1.2xlarge, a1.4xlarge , a1.large.... | Should we consider moving to something like this or continue following the current pattern we have? Thoughts welcome! Also, we can consider shipping this as it is as it is still an improvement over what we have now and file a follow up issue to re-assess the way this is presented. This is the current render that this PR fix will produce: <img width="795" alt="Screen Shot 2024-02-09 at 8 35 21 AM" src="https://github.com/pulumi/pulumi/assets/16751381/352462b7-720c-4495-bdfe-f62cfdd946c0"> |
||
---|---|---|
.. | ||
templates | ||
README.md | ||
examples.go | ||
gen.go | ||
gen_function.go | ||
gen_kubernetes.go | ||
gen_method.go | ||
gen_test.go | ||
package_tree.go | ||
package_tree_test.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 -