pulumi/pkg/codegen/docs/templates/resource.tmpl
Justin Van Patten 48a1d3f696
[docgen] Fix horizontal scroll in python resource docs (#6801)
Add line breaks and whitespace to avoid long horizontal scrolls for Python constructor/function arguments. Also, include the new ResourceArgs constructor overload.
2021-04-17 15:33:23 -07:00

165 lines
7.9 KiB
Cheetah

{{ template "header" .Header }}
{{ htmlSafe "<!-- WARNING: this file was generated by" }} {{ .Tool }}. {{ htmlSafe "-->" }}
{{ htmlSafe "<!-- Do not edit by hand unless you're certain you know what you are doing! -->" }}
{{- if .DeprecationMessage }}
<p class="resource-deprecated">Deprecated: {{ print "{{% md %}}" -}}{{- .DeprecationMessage -}}{{- print "{{% /md %}}" -}}</p>
{{- end }}
{{ htmlSafe .Comment }}
{{- if ne (len .ExamplesSection) 0 }}
{{ template "examples" .ExamplesSection }}
{{- end }}
<!-- Create resource -->
## Create a {{ .Header.Title }} Resource {#create}
{{- if eq .LangChooserLanguages "" }}
{{ htmlSafe "{{< chooser language \"typescript,python,go,csharp\" / >}}" }}
{{- else }}
{{ htmlSafe "{{< chooser language \"" }}{{ .LangChooserLanguages }}{{ htmlSafe "\" / >}}" }}
{{- end }}
{{/*
Render the specific snippet to construct the resource, e.g.
"new Bucket(name: string, args?: BucketArgs, opts?: pulumi.ResourceOptions);"
"def Bucket(resource_name, opts=None, acceleration_status=None, ..."
*/}}
{{ htmlSafe "{{% choosable language nodejs %}}" }}
<div class="highlight"><pre class="chroma"><code class="language-typescript" data-lang="typescript"><span class="k">new </span>{{ template "linkify_param" .ConstructorResource.nodejs }}<span class="p">(</span>{{ htmlSafe .ConstructorParams.nodejs }}<span class="p">);</span></code></pre></div>
{{ htmlSafe "{{% /choosable %}}" }}
{{ htmlSafe "{{% choosable language python %}}" }}
<div class="highlight"><pre class="chroma"><code class="language-python" data-lang="python"><span class=nd>@overload</span>
<span class="k">def </span>{{ template "linkify_param" .ConstructorResource.python }}<span class="p">(</span>{{ htmlSafe .ConstructorParams.python }}<span class="p">)</span>
<span class=nd>@overload</span>
<span class="k">def </span>{{ template "linkify_param" .ConstructorResource.python }}<span class="p">(</span>{{ htmlSafe .ConstructorParams.pythonargs }}<span class="p">)</span></code></pre></div>
{{ htmlSafe "{{% /choosable %}}" }}
{{ htmlSafe "{{% choosable language go %}}" }}
<div class="highlight"><pre class="chroma"><code class="language-go" data-lang="go"><span class="k">func </span>{{ template "linkify_go_param" .ConstructorResource.go }}<span class="p">(</span>{{ htmlSafe .ConstructorParams.go }}<span class="p">) (*{{ template "linkify_param" .ConstructorResource.go }}, error)</span></code></pre></div>
{{ htmlSafe "{{% /choosable %}}" }}
{{ htmlSafe "{{% choosable language csharp %}}" }}
<div class="highlight"><pre class="chroma"><code class="language-csharp" data-lang="csharp"><span class="k">public </span>{{ template "linkify_param" .ConstructorResource.csharp }}<span class="p">(</span>{{ htmlSafe .ConstructorParams.csharp }}<span class="p">)</span></code></pre></div>
{{ htmlSafe "{{% /choosable %}}" }}
{{ htmlSafe "{{% choosable language nodejs %}}" }}
{{ template "constructor_args" .ConstructorParamsTyped.nodejs }}
{{ htmlSafe "{{% /choosable %}}" }}
{{ htmlSafe "{{% choosable language python %}}" }}
{{ template "constructor_args" .ConstructorParamsTyped.pythonargs }}
{{ htmlSafe "{{% /choosable %}}" }}
{{ htmlSafe "{{% choosable language go %}}" }}
{{ template "constructor_args" .ConstructorParamsTyped.go }}
{{ htmlSafe "{{% /choosable %}}" }}
{{ htmlSafe "{{% choosable language csharp %}}" }}
{{ template "constructor_args" .ConstructorParamsTyped.csharp }}
{{ htmlSafe "{{% /choosable %}}" }}
## {{ .Header.Title }} Resource Properties {#properties}
To learn more about resource properties and how to use them, see [Inputs and Outputs]({{ htmlSafe "{{< relref \"/docs/intro/concepts/inputs-outputs\" >}}" }}) in the Programming Model docs.
### Inputs
The {{ .Header.Title }} resource accepts the following [input]({{ htmlSafe "{{< relref \"/docs/intro/concepts/inputs-outputs\" >}}" }}) properties:
{{ template "properties" .InputProperties }}
<!-- Output properties -->
### Outputs
All [input](#inputs) properties are implicitly available as output properties. Additionally, the {{ .Header.Title }} resource produces the following output properties:
{{ template "properties" .OutputProperties }}
<!-- Read resource -->
{{ if ne (len .StateInputs) 0 }}
## Look up an Existing {{.Header.Title}} Resource {#look-up}
Get an existing {{.Header.Title}} resource's state with the given name, ID, and optional extra properties used to qualify the lookup.
{{- if eq .LangChooserLanguages "" }}
{{ htmlSafe "{{< chooser language \"typescript,python,go,csharp\" / >}}" }}
{{- else }}
{{ htmlSafe "{{< chooser language \"" }}{{ .LangChooserLanguages }}{{ htmlSafe "\" / >}}" }}
{{- end }}
{{ htmlSafe "{{% choosable language nodejs %}}" }}
<div class="highlight"><pre class="chroma"><code class="language-typescript" data-lang="typescript"><span class="k">public static </span><span class="nf">get</span><span class="p">(</span>{{ htmlSafe .LookupParams.nodejs }}<span class="p">): </span>{{ template "linkify_param" .ConstructorResource.nodejs }}</code></pre></div>
{{ htmlSafe "{{% /choosable %}}" }}
{{ htmlSafe "{{% choosable language python %}}" }}
<div class="highlight"><pre class="chroma"><code class="language-python" data-lang="python"><span class=nd>@staticmethod</span>
<span class="k">def </span><span class="nf">get</span><span class="p">(</span><span class="nx">resource_name</span><span class="p">:</span> <span class="nx">str</span><span class="p">,</span>
<span class="nx">id</span><span class="p">:</span> <span class="nx">str</span><span class="p">,</span>
<span class="nx">opts</span><span class="p">:</span> <span class="nx"><a href="/docs/reference/pkg/python/pulumi/#pulumi.ResourceOptions">Optional[ResourceOptions]</a></span> = None<span class="p">,</span>
{{ htmlSafe .LookupParams.python }}<span class="p">) -&gt;</span> {{ .ConstructorResource.python.Name }}</code></pre></div>
{{ htmlSafe "{{% /choosable %}}" }}
{{ htmlSafe "{{% choosable language go %}}" }}
<div class="highlight"><pre class="chroma"><code class="language-go" data-lang="go"><span class="k">func </span>Get{{ .Header.Title }}<span class="p">(</span>{{ htmlSafe .LookupParams.go }}<span class="p">) (*{{ template "linkify_param" .ConstructorResource.go }}, error)</span></code></pre></div>
{{ htmlSafe "{{% /choosable %}}" }}
{{ htmlSafe "{{% choosable language csharp %}}" }}
<div class="highlight"><pre class="chroma"><code class="language-csharp" data-lang="csharp"><span class="k">public static </span>{{ template "linkify_param" .ConstructorResource.csharp }}<span class="nf"> Get</span><span class="p">(</span>{{ htmlSafe .LookupParams.csharp }}<span class="p">)</span></code></pre></div>
{{ htmlSafe "{{% /choosable %}}" }}
{{ htmlSafe "{{% choosable language nodejs %}}" }}
{{ template "read_inputs" }}
{{ htmlSafe "{{% /choosable %}}" }}
{{ htmlSafe "{{% choosable language python %}}" }}
<dl class="resources-properties">
<dt class="property-required" title="Required">
<span>resource_name</span>
<span class="property-indicator"></span>
</dt>
<dd>The unique name of the resulting resource.</dd>
<dt class="property-required" title="Optional">
<span>id</span>
<span class="property-indicator"></span>
</dt>
<dd>The <em>unique</em> provider ID of the resource to lookup.</dd>
</dl>
{{ htmlSafe "{{% /choosable %}}" }}
{{ htmlSafe "{{% choosable language go %}}" }}
{{ template "read_inputs" }}
{{ htmlSafe "{{% /choosable %}}" }}
{{ htmlSafe "{{% choosable language csharp %}}" }}
{{ template "read_inputs" }}
{{ htmlSafe "{{% /choosable %}}" }}
The following state arguments are supported:
{{ template "properties" .StateInputs }}
{{ end }}
<!-- Supporting types -->
{{ if ne (len .NestedTypes) 0 }}
## Supporting Types
{{ range .NestedTypes }}
<h4 id="{{ .AnchorID }}">{{ htmlSafe .Name }}</h4>
{{- if .Properties }}{{template "properties" .Properties -}}{{ end -}}
{{- if .EnumValues }}{{- template "enums" .EnumValues -}}{{ end -}}
{{- end -}}
{{- end -}}
{{ if .ImportDocs }}
## Import
{{ htmlSafe .ImportDocs }}
{{ end }}
{{ template "package_details" .PackageDetails }}