Skip to content

Commit

Permalink
fix: Enable control of docs by provider authors
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
AaronFriel committed Apr 21, 2023
1 parent cbb2d56 commit fe643a9
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/tfgen/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -1085,6 +1085,12 @@ func (g *Generator) convertExamples(docs, name string, stripSubsectionsWithError
return ""
}

if strings.Contains(docs, "{{% examples %}}") {
// The provider author has explicitly written an entire markdown document including examples.
// We'll just return it as is.
return docs
}

if strings.Contains(docs, "```typescript") || strings.Contains(docs, "```python") ||
strings.Contains(docs, "```go") || strings.Contains(docs, "```yaml") ||
strings.Contains(docs, "```csharp") || strings.Contains(docs, "```java") {
Expand Down

0 comments on commit fe643a9

Please sign in to comment.