Skip to content

Commit

Permalink
Update resourcedocsgen to pull in pulumi/pulumi updates
Browse files Browse the repository at this point in the history
  • Loading branch information
cnunciato committed Aug 11, 2023
1 parent 9380b93 commit fa794cc
Show file tree
Hide file tree
Showing 3 changed files with 1,158 additions and 212 deletions.
45 changes: 40 additions & 5 deletions tools/resourcedocsgen/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,22 +55,57 @@ and for the nav tree it is `static/registry/packages/navs/<package name>.json`.
### Updating the API docs templates

This tool depends on the `pulumi/pulumi` repo, namely the `pkg/codegen/docs` generator.
The docs generator uses Go-based [templates](https://github.com/pulumi/pulumi/tree/master/pkg/codegen/docs/templates) to render the markdown files in-memory which this tool then writes to the filesystem.
The docs generator uses Go-based [templates](https://github.com/pulumi/pulumi/tree/master/pkg/codegen/docs/templates) to render Markdown files to the filesystem.

To make changes to the templates, make sure you have `pulumi/pulumi` cloned locally and override the `github.com/pulumi/pulumi/pkg/v3` dependency to point to
your local repo for testing out the changes to the templates. Once done, you must submit a PR to the `pulumi/pulumi` repo.
To make changes to these templates, make sure you've cloned `pulumi/pulumi` locally, then override this package's `github.com/pulumi/pulumi` dependencies to point to the local clone. To do that, add the following lines to the `go.mod` file in this folder:

Once your `pulumi/pulumi` PR is merged, you should update the pseudo-version that this tool uses by running:
```go
replace github.com/pulumi/pulumi/pkg/v3 => ../../../pulumi/pkg
replace github.com/pulumi/pulumi/sdk/v3 => ../../../pulumi/sdk
```

The paths above assume `pulumi/pulumi` and `pulumi/docs` belong to the same parent folder.

Then, build and run `resourcedocsgen` to write the docs for the specified provider to a path on your local filesystem:

```bash
go mod tidy
go build -o "${GOPATH}/bin/resourcedocsgen" .
```

```bash
resourcedocsgen docs \
--schemaFile "../../../pulumi-aws/provider/cmd/pulumi-resource-aws/schema.json" \
--version "v5.42.0" \
--docsOutDir "../../../registry/themes/default/content/registry/packages/aws/api-docs" \
--packageTreeJSONOutDir "../../../registry/themes/default/static/registry/packages/navs" \
--logtostderr
```

To preview your changes in a browser, use a path that corresponds to the `content` folder of a local clone of either [`pulumi/hugo`](https://github.com/pulumi/pulumi-hugo) or [`pulumi/registry`](https://github.com/pulumi/registry). (The example above writes `aws` docs to the content folder of `pulumi/registry`.) Run `make serve` to start a local development server and then browse to <http://localhost:1313/registry> to see your changes:

```
make serve
```

Remember to rebuild `resourcedocsgen` after any making any changes to `pulumi/pulumi`.

When you're ready, submit a PR on`pulumi/pulumi`. [See the README there](https://github.com/pulumi/pulumi/tree/master/pkg/codegen/docs#modifying-templates-and-updating-tests) for details.

Once your `pulumi/pulumi` PR is merged, update the pseudo-version used by this package to pick up your changes:

```
go get -u github.com/pulumi/pulumi/pkg/v3@<commit hash>
go get -u github.com/pulumi/pulumi/sdk/v3@<commit hash>
go mod tidy
```

To update to latest pulumi/pulumi use
To update to latest pulumi/pulumi use:

```
go get -u github.com/pulumi/pulumi/pkg/v3
go get -u github.com/pulumi/pulumi/sdk/v3
go mod tidy
```

Commit, then submit a PR on this repo. Once merged, your changes will be published.
13 changes: 7 additions & 6 deletions tools/resourcedocsgen/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ go 1.16

require (
github.com/ghodss/yaml v1.0.0
github.com/golang/glog v1.0.0
github.com/hashicorp/hcl/v2 v2.15.0
github.com/golang-jwt/jwt v3.2.2+incompatible // indirect
github.com/golang/glog v1.1.1
github.com/hashicorp/hcl/v2 v2.17.0
github.com/pkg/errors v0.9.1
github.com/pulumi/pulumi/pkg/v3 v3.54.0
github.com/pulumi/pulumi/sdk/v3 v3.54.0
github.com/spf13/cobra v1.6.1
gocloud.dev/secrets/hashivault v0.28.0 // indirect
github.com/pulumi/pulumi/pkg/v3 v3.78.2-0.20230811181012-6c2c2cfa4d4f
github.com/pulumi/pulumi/sdk/v3 v3.78.2-0.20230811181012-6c2c2cfa4d4f
github.com/spf13/cobra v1.7.0
gocloud.dev/secrets/hashivault v0.33.0 // indirect
)
Loading

0 comments on commit fa794cc

Please sign in to comment.