Skip to content

Commit 3ccf753

Browse files
Fix windows path issues
1 parent b6286a5 commit 3ccf753

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

smithy-docgen/src/it/java/software/amazon/smithy/docgen/PluginTest.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import java.net.URL;
1111
import java.nio.file.Path;
12+
import java.nio.file.Paths;
1213
import java.util.Objects;
1314
import java.util.Set;
1415
import java.util.stream.Collectors;
@@ -40,7 +41,7 @@ public static void setup(@TempDir Path tempDir) {
4041
}
4142

4243
@Test
43-
public void pluginGeneratesMarkdown() {
44+
public void pluginGeneratesMarkdown() throws Exception {
4445
ObjectNode settings = Node.objectNodeBuilder()
4546
.withMember("service", "com.example#DocumentedService")
4647
.withMember("format", "markdown")
@@ -49,7 +50,7 @@ public void pluginGeneratesMarkdown() {
4950
Node.objectNodeBuilder()
5051
.withMember("com.example#ExternalResource", "https://aws.amazon.com")
5152
.build())
52-
.withMember("snippetConfigs", Node.fromStrings(SNIPPETS.getFile()))
53+
.withMember("snippetConfigs", Node.fromStrings(Paths.get(SNIPPETS.toURI()).toString()))
5354
.build();
5455
PluginContext context = getPluginContext(model, settings);
5556

@@ -64,7 +65,7 @@ public void pluginGeneratesMarkdown() {
6465
}
6566

6667
@Test
67-
public void pluginGeneratesSphinxMarkdown(@TempDir Path tempDir) {
68+
public void pluginGeneratesSphinxMarkdown() throws Exception {
6869
Model model = getModel("main.smithy");
6970
ObjectNode settings = Node.objectNodeBuilder()
7071
.withMember("service", "com.example#DocumentedService")
@@ -74,7 +75,7 @@ public void pluginGeneratesSphinxMarkdown(@TempDir Path tempDir) {
7475
Node.objectNodeBuilder()
7576
.withMember("com.example#ExternalResource", "https://aws.amazon.com")
7677
.build())
77-
.withMember("snippetConfigs", Node.fromStrings(SNIPPETS.getFile()))
78+
.withMember("snippetConfigs", Node.fromStrings(Paths.get(SNIPPETS.toURI()).toString()))
7879
.build();
7980
PluginContext context = getPluginContext(model, settings);
8081

smithy-docgen/src/main/java/software/amazon/smithy/docgen/DocSettings.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
package software.amazon.smithy.docgen;
66

77
import java.nio.file.Path;
8-
import java.nio.file.Paths;
98
import java.util.List;
109
import java.util.Map;
1110
import java.util.Objects;
@@ -63,7 +62,7 @@ public static DocSettings fromNode(ObjectNode pluginSettings) {
6362
e -> e.getValue().expectStringNode().getValue()));
6463
var snippetConfigs = pluginSettings.getArrayMember("snippetConfigs")
6564
.orElse(Node.arrayNode())
66-
.getElementsAs(e -> Paths.get(e.expectStringNode().getValue()));
65+
.getElementsAs(e -> Path.of(e.expectStringNode().getValue()));
6766
return new DocSettings(
6867
pluginSettings.expectStringMember("service").expectShapeId(),
6968
pluginSettings.getStringMemberOrDefault("format", "sphinx-markdown"),

smithy-docgen/src/test/java/software/amazon/smithy/docgen/generators/OperationGeneratorTest.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
import java.net.URL;
1212
import java.nio.file.Path;
13+
import java.nio.file.Paths;
1314
import java.util.Objects;
1415
import org.junit.jupiter.api.Test;
1516
import org.junit.jupiter.api.io.TempDir;
@@ -33,8 +34,14 @@ protected URL testFile() {
3334

3435
@Override
3536
protected ObjectNode settings() {
37+
String path;
38+
try {
39+
path = Paths.get(SNIPPETS_FILE.toURI()).toString();
40+
} catch (Exception e) {
41+
throw new RuntimeException(e);
42+
}
3643
return super.settings().toBuilder()
37-
.withMember("snippetConfigs", Node.fromStrings(SNIPPETS_FILE.getFile()))
44+
.withMember("snippetConfigs", Node.fromStrings(path))
3845
.build();
3946
}
4047

@@ -96,7 +103,7 @@ public void testGeneratesSnippetsFromDiscoveredConfig(@TempDir Path tempDir) {
96103
.withoutMember("snippetConfigs")
97104
.build();
98105

99-
sharedManifest.writeFile("snippets/snippets.json", IoUtils.readUtf8File(SNIPPETS_FILE.getFile()));
106+
sharedManifest.writeFile("snippets/snippets.json", IoUtils.readUtf8Url(SNIPPETS_FILE));
100107
execute(manifest, sharedManifest, settings);
101108
var operationDocs = manifest.expectFileString("/content/operations/BasicOperation.md");
102109
assertThat(operationDocs, containsString("""

0 commit comments

Comments
 (0)