Skip to content

Commit

Permalink
Fix recipes with example values containing new lines
Browse files Browse the repository at this point in the history
  • Loading branch information
timtebeek committed Dec 3, 2024
1 parent fe8f495 commit c1b27a7
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 40 deletions.
28 changes: 15 additions & 13 deletions docs/recipes/xml/createxmlfile.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ displayName: Create XML file example
recipeList:
- org.openrewrite.xml.CreateXmlFile:
relativeFileName: foo/bar/baz.xml
fileContents: <?xml version="1.0" encoding="UTF-8"?>
<root>
<child>1</child></root>
fileContents: >
<?xml version="1.0" encoding="UTF-8"?>
<root>
<child>1</child></root>
```
Now that `com.yourorg.CreateXmlFileExample` has been defined, activate it in your build file:
Expand Down Expand Up @@ -87,21 +88,22 @@ repositories {
```
2. Run `mvn rewrite:run` to run the recipe.
</TabItem>
<TabItem value="moderne-cli" label="Moderne CLI">
<TabItem value="moderne-cli" label="Moderne CLI">

You will need to have configured the [Moderne CLI](https://docs.moderne.io/user-documentation/moderne-cli/getting-started/cli-intro) on your machine before you can run the following command.
You will need to have configured the [Moderne CLI](https://docs.moderne.io/user-documentation/moderne-cli/getting-started/cli-intro) on your machine before you can run the following command.

```shell title="shell"
mod run . --recipe CreateXmlFile --recipe-option "relativeFileName=foo/bar/baz.xml" --recipe-option "fileContents=<?xml version="1.0" encoding="UTF-8"?>
```shell title="shell"
mod run . --recipe CreateXmlFile --recipe-option "relativeFileName=foo/bar/baz.xml" --recipe-option "fileContents=>
<?xml version="1.0" encoding="UTF-8"?>
<root>
<child>1</child></root>"
```
```

If the recipe is not available locally, then you can install it using:
```shell
mod config recipes jar install org.openrewrite:rewrite-xml:{{VERSION_REWRITE_XML}}
```
</TabItem>
If the recipe is not available locally, then you can install it using:
```shell
mod config recipes jar install org.openrewrite:rewrite-xml:{{VERSION_REWRITE_XML}}
```
</TabItem>
</Tabs>

## See how this recipe works across multiple open-source repositories
Expand Down
30 changes: 16 additions & 14 deletions docs/recipes/yaml/createyamlfile.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,11 @@ displayName: Create YAML file example
recipeList:
- org.openrewrite.yaml.CreateYamlFile:
relativeFileName: foo/bar/baz.yaml
fileContents: a:
property: value
another:
property: value
fileContents: >
a:
property: value
another:
property: value
fileContentsUrl: http://foo.bar/baz.yaml
```
Expand Down Expand Up @@ -90,22 +91,23 @@ repositories {
```
2. Run `mvn rewrite:run` to run the recipe.
</TabItem>
<TabItem value="moderne-cli" label="Moderne CLI">
<TabItem value="moderne-cli" label="Moderne CLI">

You will need to have configured the [Moderne CLI](https://docs.moderne.io/user-documentation/moderne-cli/getting-started/cli-intro) on your machine before you can run the following command.
You will need to have configured the [Moderne CLI](https://docs.moderne.io/user-documentation/moderne-cli/getting-started/cli-intro) on your machine before you can run the following command.

```shell title="shell"
mod run . --recipe CreateYamlFile --recipe-option "relativeFileName=foo/bar/baz.yaml" --recipe-option "fileContents=a:
```shell title="shell"
mod run . --recipe CreateYamlFile --recipe-option "relativeFileName=foo/bar/baz.yaml" --recipe-option "fileContents=>
a:
property: value
another:
property: value" --recipe-option "fileContentsUrl=http://foo.bar/baz.yaml"
```
```

If the recipe is not available locally, then you can install it using:
```shell
mod config recipes jar install org.openrewrite:rewrite-yaml:{{VERSION_REWRITE_YAML}}
```
</TabItem>
If the recipe is not available locally, then you can install it using:
```shell
mod config recipes jar install org.openrewrite:rewrite-yaml:{{VERSION_REWRITE_YAML}}
```
</TabItem>
</Tabs>

## See how this recipe works across multiple open-source repositories
Expand Down
28 changes: 15 additions & 13 deletions docs/recipes/yaml/mergeyaml.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ displayName: Merge YAML snippet example
recipeList:
- org.openrewrite.yaml.MergeYaml:
key: $.metadata
yaml: labels:
label-one: "value-one"
yaml: >
labels:
label-one: "value-one"
objectIdentifyingProperty: name
filePattern: .github/workflows/*.yml
```
Expand Down Expand Up @@ -90,20 +91,21 @@ repositories {
```
2. Run `mvn rewrite:run` to run the recipe.
</TabItem>
<TabItem value="moderne-cli" label="Moderne CLI">
<TabItem value="moderne-cli" label="Moderne CLI">

You will need to have configured the [Moderne CLI](https://docs.moderne.io/user-documentation/moderne-cli/getting-started/cli-intro) on your machine before you can run the following command.
You will need to have configured the [Moderne CLI](https://docs.moderne.io/user-documentation/moderne-cli/getting-started/cli-intro) on your machine before you can run the following command.

```shell title="shell"
mod run . --recipe MergeYaml --recipe-option "key=$.metadata" --recipe-option "yaml=labels:
label-one: "value-one"" --recipe-option "objectIdentifyingProperty=name" --recipe-option "filePattern=.github/workflows/*.yml"
```
```shell title="shell"
mod run . --recipe MergeYaml --recipe-option "key=$.metadata" --recipe-option "yaml=>
labels:
label-one: "value-one"" --recipe-option "objectIdentifyingProperty=name" --recipe-option "filePattern=.github/workflows/*.yml"
```

If the recipe is not available locally, then you can install it using:
```shell
mod config recipes jar install org.openrewrite:rewrite-yaml:{{VERSION_REWRITE_YAML}}
```
</TabItem>
If the recipe is not available locally, then you can install it using:
```shell
mod config recipes jar install org.openrewrite:rewrite-yaml:{{VERSION_REWRITE_YAML}}
```
</TabItem>
</Tabs>

## See how this recipe works across multiple open-source repositories
Expand Down

0 comments on commit c1b27a7

Please sign in to comment.