Skip to content

Commit

Permalink
Post-code-translation edit rules: Configuration Schema and datasource (
Browse files Browse the repository at this point in the history
…#2579)

Papercuts discovered when generating Snowflake's registry `_index.md`
file.

The string "D/datasource" should be translated to "function", and
"Configuration Schema" would translate to "Configuration Configuration
Reference" without tis change.

They're worth having as global rules in my opinion.


- **Add datasource -> function replace edit rule**
- **Add replace rule for '# Configuration Schema' because some providers
are extra special**
  • Loading branch information
guineveresaenger authored Nov 1, 2024
1 parent 2096fb4 commit 9b51fe5
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/tfgen/edit_rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ func defaultEditRules() editRules {
`Configuration Reference`, info.PostCodeTranslation),
reReplace(`# Arguments`,
`# Configuration Reference`, info.PostCodeTranslation),
reReplace(`# Configuration Schema`,
`# Configuration Reference`, info.PostCodeTranslation),
reReplace(`# Schema`,
`# Configuration Reference`, info.PostCodeTranslation),
reReplace("### Optional\n", "", info.PostCodeTranslation),
Expand All @@ -74,6 +76,8 @@ func defaultEditRules() editRules {
reReplace("`provider` block", "provider configuration", info.PostCodeTranslation),
reReplace("Data Source", "Function", info.PostCodeTranslation),
reReplace("data source", "function", info.PostCodeTranslation),
reReplace("Datasource", "Function", info.PostCodeTranslation),
reReplace("datasource", "function", info.PostCodeTranslation),
}
}

Expand Down
26 changes: 26 additions & 0 deletions pkg/tfgen/edit_rules_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,23 @@ func TestApplyEditRules(t *testing.T) {
expected: []byte(readfile(t, "test_data/replace-data-source/expected.md")),
phase: info.PostCodeTranslation,
},
{
// Found in snowflake
name: "Replaces 'datasource' with 'function'",
docFile: DocFile{
Content: []byte("Currently deprecated datasources"),
},
expected: []byte("Currently deprecated functions"),
phase: info.PostCodeTranslation,
},
{
name: "Replaces 'Datasource' with 'Function'",
docFile: DocFile{
Content: []byte("How About This Datasource"),
},
expected: []byte("How About This Function"),
phase: info.PostCodeTranslation,
},
{
name: "Replaces 'Terraform W/workspace' with 'Pulumi Stack'",
docFile: DocFile{
Expand All @@ -239,6 +256,15 @@ func TestApplyEditRules(t *testing.T) {
expected: []byte("Manage a single Schema Registry cluster"),
phase: info.PostCodeTranslation,
},
{
// Found in snowflake
name: "Replaces '# Configuration Schema' with '# Configuration Reference ",
docFile: DocFile{
Content: []byte("# Configuration Schema"),
},
expected: []byte("# Configuration Reference"),
phase: info.PostCodeTranslation,
},
}
edits := defaultEditRules()

Expand Down

0 comments on commit 9b51fe5

Please sign in to comment.