Skip to content
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

The first line of Image docs are not rendered in the registry. #600

Closed
AaronFriel opened this issue Apr 21, 2023 · 0 comments · Fixed by #601
Closed

The first line of Image docs are not rendered in the registry. #600

AaronFriel opened this issue Apr 21, 2023 · 0 comments · Fixed by #601
Assignees
Labels
area/docs Improvements or additions to documentation kind/bug Some behavior is incorrect or out of spec resolution/fixed This issue was fixed

Comments

@AaronFriel
Copy link
Contributor

The resource defines a blurb to precede the examples:

dockerResource(dockerMod, "Image").String(): {
ObjectTypeSpec: schema.ObjectTypeSpec{
Type: "object",
Description: "Builds a Docker Image and pushes to a Docker registry.\n\n" +
docImage,

But this ends up hidden in the schema inside the {{% examples %}} section instead of outside it:

"description": "{{% examples %}}\nBuilds a Docker Image and pushes to a Docker registry.\n\n## Example Usage\n{{% example %}}\n### A Docker image build\n\n```typescript\nimport * as pulumi from \"@pulumi/pulumi\";\nimport * as docker from \"@pulumi/docker\";\n\nconst demoImage = new docker.Image(\"demo-image\", {\n build: {\n context: \".\",\n dockerfile: \"Dockerfile\",\n },\n imageName: \"username/image:tag1\",\n skipPush: true,\n});\nexport const imageName = demoImage.imageName;\n```\n```python\nimport pulumi\nimport pulumi_docker as docker\n\ndemo_image = docker.Image(\"demo-image\",\n build=docker.DockerBuildArgs(\n context=\".\",\n dockerfile=\"Dockerfile\",\n ),\n image_name=\"username/image:tag1\",\n skip_push=True)\npulumi.export(\"imageName\", demo_image.image_name)\n```\n```csharp\nusing System.Collections.Generic;\nusing System.Linq;\nusing Pulumi;\nusing Docker = Pulumi.Docker;\n\nreturn await Deployment.RunAsync(() =\u003e \n{\n var demoImage = new Docker.Image(\"demo-image\", new()\n {\n Build = new Docker.Inputs.DockerBuildArgs\n {\n Context = \".\",\n Dockerfile = \"Dockerfile\",\n },\n ImageName = \"username/image:tag1\",\n SkipPush = true,\n });\n\n return new Dictionary\u003cstring, object?\u003e\n {\n [\"imageName\"] = demoImage.ImageName,\n };\n});\n\n```\n```go\npackage main\n\nimport (\n\t\"github.com/pulumi/pulumi-docker/sdk/v4/go/docker\"\n\t\"github.com/pulumi/pulumi/sdk/v3/go/pulumi\"\n)\n\nfunc main() {\n\tpulumi.Run(func(ctx *pulumi.Context) error {\n\t\tdemoImage, err := docker.NewImage(ctx, \"demo-image\", \u0026docker.ImageArgs{\n\t\t\tBuild: \u0026docker.DockerBuildArgs{\n\t\t\t\tContext: pulumi.String(\".\"),\n\t\t\t\tDockerfile: pulumi.String(\"Dockerfile\"),\n\t\t\t},\n\t\t\tImageName: pulumi.String(\"username/image:tag1\"),\n\t\t\tSkipPush: pulumi.Bool(true),\n\t\t})\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tctx.Export(\"imageName\", demoImage.ImageName)\n\t\treturn nil\n\t})\n}\n```\n```yaml\nconfig: {}\ndescription: A Docker image build\nname: image-yaml\noutputs:\n imageName: ${demo-image.imageName}\nresources:\n demo-image:\n options:\n version: v4.0.0\n properties:\n build:\n context: .\n dockerfile: Dockerfile\n imageName: username/image:tag1\n skipPush: true\n type: docker:Image\nruntime: yaml\nvariables: {}\n```\n```java\npackage generated_program;\n\nimport com.pulumi.Context;\nimport com.pulumi.Pulumi;\nimport com.pulumi.core.Output;\nimport com.pulumi.docker.Image;\nimport com.pulumi.docker.ImageArgs;\nimport com.pulumi.docker.inputs.DockerBuildArgs;\nimport java.util.List;\nimport java.util.ArrayList;\nimport java.util.Map;\nimport java.io.File;\nimport java.nio.file.Files;\nimport java.nio.file.Paths;\n\npublic class App {\n public static void main(String[] args) {\n Pulumi.run(App::stack);\n }\n\n public static void stack(Context ctx) {\n var demoImage = new Image(\"demoImage\", ImageArgs.builder() \n .build(DockerBuildArgs.builder()\n .context(\".\")\n .dockerfile(\"Dockerfile\")\n .build())\n .imageName(\"username/image:tag1\")\n .skipPush(true)\n .build());\n\n ctx.export(\"imageName\", demoImage.imageName());\n }\n}\n```\n{{% /example %}}\n\n{{% /examples %}}",

And consequently, is not rendered into the registry docs for Docker.Image. It looks like the rendering pipeline drops the piece of text outside of an example.

@AaronFriel AaronFriel added kind/bug Some behavior is incorrect or out of spec area/docs Improvements or additions to documentation labels Apr 21, 2023
@AaronFriel AaronFriel self-assigned this Apr 21, 2023
AaronFriel added a commit to pulumi/pulumi-terraform-bridge that referenced this issue Apr 21, 2023
This enables the Docker provider to explicitly embed `{{% examples %}}` after
introductory text, unblocking:
- pulumi/pulumi-docker#592
- pulumi/pulumi-docker#588

This fix addresses this issue:
- pulumi/pulumi-docker#600

All of these might be fixed by a change to Docker that added introductory text
above examples, but as observed in pulumi/pulumi-docker#600, it's not currently
possible to render text outside of an examples block.

This change to docs rendering allows us to explicitly add the examples shortcode
block in the input docs, and pass-through tfgen rendering entirely.
@pulumi-bot pulumi-bot added the resolution/fixed This issue was fixed label Apr 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/docs Improvements or additions to documentation kind/bug Some behavior is incorrect or out of spec resolution/fixed This issue was fixed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants