Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ public static String cleanupHtml(String text) {
.replaceAll("<([A-Z][a-z]+||)>", "&lt;$1&gt;")
.replaceAll("`([^`]+)`", "<code>$1</code>")
.replaceAll("\\[([^]]+)]\\(([^)]+)\\)", "<a href=\"$2\">$1</a>")
.replaceAll("\\{@link *\"([^\\{]+)\" *\\}", "<a href=\"$1\">$1</a>")
.replaceAll("\\[([^]]+)]\\[([^]]+)\\]", "<xref uid=\"$2\" data-throw-if-not-resolved=\"false\">$1</xref>")
.replaceAll("\\{@link *([^\\{\"]+) *\\}", "<xref uid=\"$1\" data-throw-if-not-resolved=\"false\">$1</xref>")
.replaceAll("==+([^=]+)==+", "<h2>$1</h2>");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ public static final SpeechClient create() throws IOException {
/**
* Constructs an instance of SpeechClient, using the given settings. The channels are created
* based on the settings passed in, or defaults for any settings that are not set.
* Example broken links: {@link "http://tools.ietf.org/html/rfc2616#section-3.7"}
* {@link ApiFutures#immediateFuture(null)}.
*/
public static final SpeechClient create(com.microsoft.samples.google.SpeechSettings settings) throws IOException {
return new SpeechClient(settings);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,26 @@ public void cleanupHtmlReferenceTest() {
assertEquals("[uid]][text]", YamlUtil.cleanupHtml("[uid]][text]"));
assertFalse(YamlUtil.cleanupHtml("[text[uid]]").contains("xref"));
}

@Test
public void cleanupHtmlLinkTagWithLinkTest() {
String expectedActual = "{@link \"http://www.bad-way-to-include-link.com#section\"}";
String expectedResult = "<a href=\"http://www.bad-way-to-include-link.com#section\">http://www.bad-way-to-include-link.com#section</a>";
String random = UUID.randomUUID().toString();

assertEquals(expectedResult, YamlUtil.cleanupHtml(expectedActual));
assertEquals(random + expectedResult + random, YamlUtil.cleanupHtml(random + expectedActual + random));
assertEquals(expectedResult + random + expectedResult, YamlUtil.cleanupHtml(expectedActual + random + expectedActual));
}

@Test
public void cleanupHtmlLinkTagNotRecognizedTest() {
String expectedActual = "{@link WeirdLink#didntResolve(null)}";
String expectedResult = "<xref uid=\"WeirdLink#didntResolve(null)\" data-throw-if-not-resolved=\"false\">WeirdLink#didntResolve(null)</xref>";
String random = UUID.randomUUID().toString();

assertEquals(expectedResult, YamlUtil.cleanupHtml(expectedActual));
assertEquals(random + expectedResult + random, YamlUtil.cleanupHtml(random + expectedActual + random));
assertEquals(expectedResult + random + expectedResult, YamlUtil.cleanupHtml(expectedActual + random + expectedActual));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ items:
overload: "com.microsoft.samples.google.v1p1alpha.SpeechClient.create*"
type: "Method"
package: "com.microsoft.samples.google.v1p1alpha"
summary: "Constructs an instance of SpeechClient, using the given settings. The channels are created\n based on the settings passed in, or defaults for any settings that are not set."
summary: "Constructs an instance of SpeechClient, using the given settings. The channels are created\n based on the settings passed in, or defaults for any settings that are not set.\n Example broken links: <a href=\"http://tools.ietf.org/html/rfc2616#section-3.7\">http://tools.ietf.org/html/rfc2616#section-3.7</a>\n <xref uid=\"\" data-throw-if-not-resolved=\"false\">ApiFutures#immediateFuture(null)</xref>."
syntax:
content: "public static final SpeechClient create(SpeechSettings settings)"
parameters:
Expand Down