Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit b166eec

Browse files
committedJun 26, 2024·
fixme
1 parent e007802 commit b166eec

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed
 

‎scripts/docsgen/main.go

+6-7
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,22 @@ import (
1616

1717
// This script patches Markdown docs generated by `terraform-plugin-docs` to expose the original deprecation message.
1818

19-
var (
20-
reDeprecatedProperty = regexp.MustCompile("`([^`]+)` \\(([^,\\)]+), Deprecated\\) ([^\n]+)")
21-
)
19+
const docsDir = "docs" // FIXME expose as flag?
20+
21+
var reDeprecatedProperty = regexp.MustCompile("`([^`]+)` \\(([^,\\)]+), Deprecated\\) ([^\n]+)")
2222

2323
func main() {
2424
p := provider.New()
2525
err := exposeDeprecationMessage(p)
2626
if err != nil {
2727
log.Fatal(err)
2828
}
29-
// FIXME flag to select dir
3029
}
3130

3231
func exposeDeprecationMessage(p *schema.Provider) error {
3332
// Patch data-sources
3433
for dataSourceName, dataSource := range p.DataSourcesMap {
35-
docFile := filepath.Join("docs", "data-sources", strings.Replace(dataSourceName, "coder_", "", 1)+".md")
34+
docFile := filepath.Join(docsDir, "data-sources", strings.Replace(dataSourceName, "coder_", "", 1)+".md")
3635

3736
err := adjustDocFile(docFile, dataSource.Schema)
3837
if err != nil {
@@ -42,7 +41,7 @@ func exposeDeprecationMessage(p *schema.Provider) error {
4241

4342
// Patch resources
4443
for resourceName, resource := range p.ResourcesMap {
45-
docFile := filepath.Join("docs", "resources", strings.Replace(resourceName, "coder_", "", 1)+".md")
44+
docFile := filepath.Join(docsDir, "resources", strings.Replace(resourceName, "coder_", "", 1)+".md")
4645

4746
err := adjustDocFile(docFile, resource.Schema)
4847
if err != nil {
@@ -51,7 +50,7 @@ func exposeDeprecationMessage(p *schema.Provider) error {
5150
}
5251

5352
// Patch index
54-
docFile := filepath.Join("docs", "index.md")
53+
docFile := filepath.Join(docsDir, "index.md")
5554
err := adjustDocFile(docFile, p.Schema)
5655
if err != nil {
5756
return xerrors.Errorf("unable to adjust index doc file: %w", err)

0 commit comments

Comments
 (0)
Please sign in to comment.