From 14fb76227dcfab5c35c5e9d662a35079b1e911a6 Mon Sep 17 00:00:00 2001 From: Andrei Punko Date: Sat, 26 Jun 2021 14:39:00 +0300 Subject: [PATCH 1/5] Create maven.yml --- .github/workflows/maven.yml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 .github/workflows/maven.yml diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml new file mode 100644 index 0000000..75d66bb --- /dev/null +++ b/.github/workflows/maven.yml @@ -0,0 +1,25 @@ +# This workflow will build a Java project with Maven +# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven + +name: Java CI with Maven + +on: + push: + branches: [ dev ] + pull_request: + branches: [ dev ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Set up JDK 11 + uses: actions/setup-java@v2 + with: + java-version: '11' + distribution: 'adopt' + - name: Build with Maven + run: mvn -B package --file pom.xml From f96faa9a6b086be32b7da4fb9cfcbb0cf6d3aabe Mon Sep 17 00:00:00 2001 From: Andrei Punko Date: Fri, 6 Aug 2021 09:32:53 +0300 Subject: [PATCH 2/5] Seems original com.overzealous:remark artifact was removed from repo, so we should replace it with possible fork And it's mandatory change for person who hasn't legacy com.overzealous artifact in local maven repo --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 06616a8..12793fb 100644 --- a/pom.xml +++ b/pom.xml @@ -17,7 +17,7 @@ 3.8.1 4.2 2.7 - 1.1.0 + 1.2.0 @@ -122,7 +122,7 @@ ${jackson.version} - com.overzealous + com.kotcrab.remark remark ${remark.version} From 1d5c0439639daf9d2c1358686a53d2a72d5a3121 Mon Sep 17 00:00:00 2001 From: Andrei Punko Date: Sat, 26 Jun 2021 14:22:13 +0300 Subject: [PATCH 3/5] Add class with hieroglyphs in description Add expected result files --- .../microsoft/samples/noneascii/Offer.java | 38 ++++ .../com.microsoft.samples.noneascii.Offer.yml | 188 ++++++++++++++++++ .../com.microsoft.samples.noneascii.yml | 19 ++ ...om.microsoft.samples.subpackage.Person.yml | 2 +- .../expected-generated-files/toc.yml | 5 + 5 files changed, 251 insertions(+), 1 deletion(-) create mode 100644 src/test/java/com/microsoft/samples/noneascii/Offer.java create mode 100644 src/test/resources/expected-generated-files/com.microsoft.samples.noneascii.Offer.yml create mode 100644 src/test/resources/expected-generated-files/com.microsoft.samples.noneascii.yml diff --git a/src/test/java/com/microsoft/samples/noneascii/Offer.java b/src/test/java/com/microsoft/samples/noneascii/Offer.java new file mode 100644 index 0000000..4dce77c --- /dev/null +++ b/src/test/java/com/microsoft/samples/noneascii/Offer.java @@ -0,0 +1,38 @@ +package com.microsoft.samples.noneascii; + +/** + * 代表客户可用的产品形式 + */ +public class Offer { + /** + * 初始化Offer类的新实例。 + */ + public Offer() { + } + + /** + * 获取或设置合作伙伴要求的资格,以便为客户购买优惠。 + */ + private String[] __ResellerQualifications; + + public String[] getResellerQualifications() { + return __ResellerQualifications; + } + + public void setResellerQualifications(String[] value) { + __ResellerQualifications = value; + } + + /** + * 获取或设置客户要求合作伙伴为客户购买的资格。 + */ + private String[] __ReselleeQualifications; + + public String[] getReselleeQualifications() { + return __ReselleeQualifications; + } + + public void setReselleeQualifications(String[] value) { + __ReselleeQualifications = value; + } +} \ No newline at end of file diff --git a/src/test/resources/expected-generated-files/com.microsoft.samples.noneascii.Offer.yml b/src/test/resources/expected-generated-files/com.microsoft.samples.noneascii.Offer.yml new file mode 100644 index 0000000..f03ac81 --- /dev/null +++ b/src/test/resources/expected-generated-files/com.microsoft.samples.noneascii.Offer.yml @@ -0,0 +1,188 @@ +### YamlMime:ManagedReference +items: +- uid: "com.microsoft.samples.noneascii.Offer" + id: "Offer" + parent: "com.microsoft.samples.noneascii" + children: + - "com.microsoft.samples.noneascii.Offer.Offer()" + - "com.microsoft.samples.noneascii.Offer.getReselleeQualifications()" + - "com.microsoft.samples.noneascii.Offer.getResellerQualifications()" + - "com.microsoft.samples.noneascii.Offer.setReselleeQualifications(java.lang.String[])" + - "com.microsoft.samples.noneascii.Offer.setResellerQualifications(java.lang.String[])" + langs: + - "java" + name: "Offer" + nameWithType: "Offer" + fullName: "com.microsoft.samples.noneascii.Offer" + type: "Class" + package: "com.microsoft.samples.noneascii" + summary: "代表客户可用的产品形式" + syntax: + content: "public class Offer" + inheritance: + - "java.lang.Object" + inheritedMembers: + - "java.lang.Object.clone()" + - "java.lang.Object.equals(java.lang.Object)" + - "java.lang.Object.finalize()" + - "java.lang.Object.getClass()" + - "java.lang.Object.hashCode()" + - "java.lang.Object.notify()" + - "java.lang.Object.notifyAll()" + - "java.lang.Object.toString()" + - "java.lang.Object.wait()" + - "java.lang.Object.wait(long)" + - "java.lang.Object.wait(long,int)" +- uid: "com.microsoft.samples.noneascii.Offer.Offer()" + id: "Offer()" + parent: "com.microsoft.samples.noneascii.Offer" + langs: + - "java" + name: "Offer()" + nameWithType: "Offer.Offer()" + fullName: "com.microsoft.samples.noneascii.Offer.Offer()" + overload: "com.microsoft.samples.noneascii.Offer.Offer*" + type: "Constructor" + package: "com.microsoft.samples.noneascii" + summary: "初始化Offer类的新实例。" + syntax: + content: "public Offer()" +- uid: "com.microsoft.samples.noneascii.Offer.getReselleeQualifications()" + id: "getReselleeQualifications()" + parent: "com.microsoft.samples.noneascii.Offer" + langs: + - "java" + name: "getReselleeQualifications()" + nameWithType: "Offer.getReselleeQualifications()" + fullName: "com.microsoft.samples.noneascii.Offer.getReselleeQualifications()" + overload: "com.microsoft.samples.noneascii.Offer.getReselleeQualifications*" + type: "Method" + package: "com.microsoft.samples.noneascii" + syntax: + content: "public String[] getReselleeQualifications()" + return: + type: "java.lang.String[]" +- uid: "com.microsoft.samples.noneascii.Offer.getResellerQualifications()" + id: "getResellerQualifications()" + parent: "com.microsoft.samples.noneascii.Offer" + langs: + - "java" + name: "getResellerQualifications()" + nameWithType: "Offer.getResellerQualifications()" + fullName: "com.microsoft.samples.noneascii.Offer.getResellerQualifications()" + overload: "com.microsoft.samples.noneascii.Offer.getResellerQualifications*" + type: "Method" + package: "com.microsoft.samples.noneascii" + syntax: + content: "public String[] getResellerQualifications()" + return: + type: "java.lang.String[]" +- uid: "com.microsoft.samples.noneascii.Offer.setReselleeQualifications(java.lang.String[])" + id: "setReselleeQualifications(java.lang.String[])" + parent: "com.microsoft.samples.noneascii.Offer" + langs: + - "java" + name: "setReselleeQualifications(String[] value)" + nameWithType: "Offer.setReselleeQualifications(String[] value)" + fullName: "com.microsoft.samples.noneascii.Offer.setReselleeQualifications(String[] value)" + overload: "com.microsoft.samples.noneascii.Offer.setReselleeQualifications*" + type: "Method" + package: "com.microsoft.samples.noneascii" + syntax: + content: "public void setReselleeQualifications(String[] value)" + parameters: + - id: "value" + type: "java.lang.String[]" +- uid: "com.microsoft.samples.noneascii.Offer.setResellerQualifications(java.lang.String[])" + id: "setResellerQualifications(java.lang.String[])" + parent: "com.microsoft.samples.noneascii.Offer" + langs: + - "java" + name: "setResellerQualifications(String[] value)" + nameWithType: "Offer.setResellerQualifications(String[] value)" + fullName: "com.microsoft.samples.noneascii.Offer.setResellerQualifications(String[] value)" + overload: "com.microsoft.samples.noneascii.Offer.setResellerQualifications*" + type: "Method" + package: "com.microsoft.samples.noneascii" + syntax: + content: "public void setResellerQualifications(String[] value)" + parameters: + - id: "value" + type: "java.lang.String[]" +references: +- uid: "com.microsoft.samples.noneascii.Offer.Offer*" + name: "Offer" + nameWithType: "Offer.Offer" + fullName: "com.microsoft.samples.noneascii.Offer.Offer" + package: "com.microsoft.samples.noneascii" +- uid: "java.lang.String[]" + spec.java: + - uid: "java.lang.String" + name: "String" + fullName: "java.lang.String" + - name: "[]" + fullName: "[]" +- uid: "com.microsoft.samples.noneascii.Offer.getResellerQualifications*" + name: "getResellerQualifications" + nameWithType: "Offer.getResellerQualifications" + fullName: "com.microsoft.samples.noneascii.Offer.getResellerQualifications" + package: "com.microsoft.samples.noneascii" +- uid: "com.microsoft.samples.noneascii.Offer.setResellerQualifications*" + name: "setResellerQualifications" + nameWithType: "Offer.setResellerQualifications" + fullName: "com.microsoft.samples.noneascii.Offer.setResellerQualifications" + package: "com.microsoft.samples.noneascii" +- uid: "com.microsoft.samples.noneascii.Offer.getReselleeQualifications*" + name: "getReselleeQualifications" + nameWithType: "Offer.getReselleeQualifications" + fullName: "com.microsoft.samples.noneascii.Offer.getReselleeQualifications" + package: "com.microsoft.samples.noneascii" +- uid: "com.microsoft.samples.noneascii.Offer.setReselleeQualifications*" + name: "setReselleeQualifications" + nameWithType: "Offer.setReselleeQualifications" + fullName: "com.microsoft.samples.noneascii.Offer.setReselleeQualifications" + package: "com.microsoft.samples.noneascii" +- uid: "java.lang.Object.notify()" + name: "Object.notify()" + nameWithType: "Object.notify()" + fullName: "java.lang.Object.notify()" +- uid: "java.lang.Object.wait()" + name: "Object.wait()" + nameWithType: "Object.wait()" + fullName: "java.lang.Object.wait()" +- uid: "java.lang.Object.finalize()" + name: "Object.finalize()" + nameWithType: "Object.finalize()" + fullName: "java.lang.Object.finalize()" +- uid: "java.lang.Object.clone()" + name: "Object.clone()" + nameWithType: "Object.clone()" + fullName: "java.lang.Object.clone()" +- uid: "java.lang.Object.notifyAll()" + name: "Object.notifyAll()" + nameWithType: "Object.notifyAll()" + fullName: "java.lang.Object.notifyAll()" +- uid: "java.lang.Object.equals(java.lang.Object)" + name: "Object.equals(Object)" + nameWithType: "Object.equals(Object)" + fullName: "java.lang.Object.equals(java.lang.Object)" +- uid: "java.lang.Object.getClass()" + name: "Object.getClass()" + nameWithType: "Object.getClass()" + fullName: "java.lang.Object.getClass()" +- uid: "java.lang.Object.wait(long)" + name: "Object.wait(long)" + nameWithType: "Object.wait(long)" + fullName: "java.lang.Object.wait(long)" +- uid: "java.lang.Object.hashCode()" + name: "Object.hashCode()" + nameWithType: "Object.hashCode()" + fullName: "java.lang.Object.hashCode()" +- uid: "java.lang.Object.wait(long,int)" + name: "Object.wait(long,int)" + nameWithType: "Object.wait(long,int)" + fullName: "java.lang.Object.wait(long,int)" +- uid: "java.lang.Object.toString()" + name: "Object.toString()" + nameWithType: "Object.toString()" + fullName: "java.lang.Object.toString()" diff --git a/src/test/resources/expected-generated-files/com.microsoft.samples.noneascii.yml b/src/test/resources/expected-generated-files/com.microsoft.samples.noneascii.yml new file mode 100644 index 0000000..93b7156 --- /dev/null +++ b/src/test/resources/expected-generated-files/com.microsoft.samples.noneascii.yml @@ -0,0 +1,19 @@ +### YamlMime:ManagedReference +items: +- uid: "com.microsoft.samples.noneascii" + id: "noneascii" + children: + - "com.microsoft.samples.noneascii.Offer" + langs: + - "java" + name: "com.microsoft.samples.noneascii" + nameWithType: "com.microsoft.samples.noneascii" + fullName: "com.microsoft.samples.noneascii" + type: "Namespace" + syntax: + content: "package com.microsoft.samples.noneascii" +references: +- uid: "com.microsoft.samples.noneascii.Offer" + name: "Offer" + nameWithType: "Offer" + fullName: "com.microsoft.samples.noneascii.Offer" diff --git a/src/test/resources/expected-generated-files/com.microsoft.samples.subpackage.Person.yml b/src/test/resources/expected-generated-files/com.microsoft.samples.subpackage.Person.yml index 63175cd..b8e64fe 100644 --- a/src/test/resources/expected-generated-files/com.microsoft.samples.subpackage.Person.yml +++ b/src/test/resources/expected-generated-files/com.microsoft.samples.subpackage.Person.yml @@ -21,7 +21,7 @@ items: fullName: "com.microsoft.samples.subpackage.Person" type: "Class" package: "com.microsoft.samples.subpackage" - summary: "Class that describes some person This comment has links to:\n\n * Owner class Person\n * Its inner class Person.IdentificationInfo\n * Its method Person#setLastName(String lastName)\n * Its method without params Person#setLastName()\n * Its public field Person#age\n * Another class which used here Set\n * Another class which not used here List\n * Broken link sdfdsagdsfghfgh\n * Plain link someContent\n * Link that starts from '\\#' #setLastName()\n * Link with label WordOne\n\nThis is an \"at\" symbol: @" + summary: "Class that describes some person This comment has links to:\n\n * Owner class Person\n * Its inner class Person.IdentificationInfo\n * Its method Person#setLastName(String lastName)\n * Its method without params Person#setLastName()\n * Its public field Person#age\n * Another class which used here Set\n * Another class which not used here List\n * Broken link sdfdsagdsfghfgh\n * Plain link someContent\n * Link that starts from '#' #setLastName()\n * Link with label WordOne\n\nThis is an \"at\" symbol: @" syntax: content: "public class Person" typeParameters: diff --git a/src/test/resources/expected-generated-files/toc.yml b/src/test/resources/expected-generated-files/toc.yml index a4e2eff..4239bc1 100644 --- a/src/test/resources/expected-generated-files/toc.yml +++ b/src/test/resources/expected-generated-files/toc.yml @@ -31,6 +31,11 @@ name: "Organism" - uid: "com.microsoft.samples.commentinheritance.Viviparous" name: "Viviparous" +- uid: "com.microsoft.samples.noneascii" + name: "com.microsoft.samples.noneascii" + items: + - uid: "com.microsoft.samples.noneascii.Offer" + name: "Offer" - uid: "com.microsoft.samples.offers" name: "com.microsoft.samples.offers" items: From 797a9869b98b40d0dd4177bb42a40065060fa7c8 Mon Sep 17 00:00:00 2001 From: Andrei Punko Date: Fri, 6 Aug 2021 09:33:35 +0300 Subject: [PATCH 4/5] Fix encoding error for summary/returnDescription/description etc --- pom.xml | 6 ++++++ src/main/java/com/microsoft/model/ExceptionItem.java | 4 +++- src/main/java/com/microsoft/model/MetadataFileItem.java | 3 ++- src/main/java/com/microsoft/model/MethodParameter.java | 4 +++- src/main/java/com/microsoft/model/Return.java | 3 ++- src/main/java/com/microsoft/model/SpecViewModel.java | 1 - src/main/java/com/microsoft/util/FileUtil.java | 3 ++- 7 files changed, 18 insertions(+), 6 deletions(-) diff --git a/pom.xml b/pom.xml index 12793fb..5f24ee3 100644 --- a/pom.xml +++ b/pom.xml @@ -17,6 +17,7 @@ 3.8.1 4.2 2.7 + 1.9 1.2.0 @@ -111,6 +112,11 @@ commons-io ${apache.commons-io.version} + + org.apache.commons + commons-text + ${apache.commons-text.version} + com.fasterxml.jackson.core jackson-databind diff --git a/src/main/java/com/microsoft/model/ExceptionItem.java b/src/main/java/com/microsoft/model/ExceptionItem.java index b833f6b..4a21e41 100644 --- a/src/main/java/com/microsoft/model/ExceptionItem.java +++ b/src/main/java/com/microsoft/model/ExceptionItem.java @@ -1,5 +1,7 @@ package com.microsoft.model; +import org.apache.commons.text.StringEscapeUtils; + public class ExceptionItem { private final String type; @@ -7,7 +9,7 @@ public class ExceptionItem { public ExceptionItem(String type, String description) { this.type = type; - this.description = description; + this.description = StringEscapeUtils.unescapeJava(description); } public String getType() { diff --git a/src/main/java/com/microsoft/model/MetadataFileItem.java b/src/main/java/com/microsoft/model/MetadataFileItem.java index d953ea7..8def62d 100644 --- a/src/main/java/com/microsoft/model/MetadataFileItem.java +++ b/src/main/java/com/microsoft/model/MetadataFileItem.java @@ -9,6 +9,7 @@ import java.util.List; import org.apache.commons.lang3.RegExUtils; +import org.apache.commons.text.StringEscapeUtils; @JsonPropertyOrder({"uid", "id", "parent", "children", "href", "langs", "isExternal", "name", "nameWithType", "fullName", "overload", "overridden", "type", "package", "summary", "syntax", "inheritance", "implements", "exceptions", @@ -158,7 +159,7 @@ public String getSummary() { } public void setSummary(String summary) { - this.summary = summary; + this.summary = StringEscapeUtils.unescapeJava(summary); } public Syntax getSyntax() { diff --git a/src/main/java/com/microsoft/model/MethodParameter.java b/src/main/java/com/microsoft/model/MethodParameter.java index 2c6d5c0..8a63d56 100644 --- a/src/main/java/com/microsoft/model/MethodParameter.java +++ b/src/main/java/com/microsoft/model/MethodParameter.java @@ -1,5 +1,7 @@ package com.microsoft.model; +import org.apache.commons.text.StringEscapeUtils; + public class MethodParameter { private final String id; @@ -25,6 +27,6 @@ public String getDescription() { } public void setDescription(String description) { - this.description = description; + this.description = StringEscapeUtils.unescapeJava(description); } } diff --git a/src/main/java/com/microsoft/model/Return.java b/src/main/java/com/microsoft/model/Return.java index 712c282..e83a491 100644 --- a/src/main/java/com/microsoft/model/Return.java +++ b/src/main/java/com/microsoft/model/Return.java @@ -1,6 +1,7 @@ package com.microsoft.model; import com.fasterxml.jackson.annotation.JsonProperty; +import org.apache.commons.text.StringEscapeUtils; public class Return { @@ -27,6 +28,6 @@ public String getReturnDescription() { } public void setReturnDescription(String returnDescription) { - this.returnDescription = returnDescription; + this.returnDescription = StringEscapeUtils.unescapeJava(returnDescription); } } diff --git a/src/main/java/com/microsoft/model/SpecViewModel.java b/src/main/java/com/microsoft/model/SpecViewModel.java index bb85c42..1597905 100644 --- a/src/main/java/com/microsoft/model/SpecViewModel.java +++ b/src/main/java/com/microsoft/model/SpecViewModel.java @@ -10,7 +10,6 @@ import com.fasterxml.jackson.annotation.JsonPropertyOrder; @JsonPropertyOrder({"uid", "name", "fullName", "isExternal"}) - public class SpecViewModel { private String uid; diff --git a/src/main/java/com/microsoft/util/FileUtil.java b/src/main/java/com/microsoft/util/FileUtil.java index a11ea87..9953513 100644 --- a/src/main/java/com/microsoft/util/FileUtil.java +++ b/src/main/java/com/microsoft/util/FileUtil.java @@ -2,6 +2,7 @@ import com.microsoft.model.YmlFile; import java.io.IOException; +import java.nio.charset.Charset; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; @@ -16,7 +17,7 @@ public static void dumpToFile(String content, String fileName) { try { Path path = Paths.get(fileName); Files.createDirectories(path.getParent()); - Files.write(path, content.getBytes()); + Files.write(path, content.getBytes(Charset.forName("UTF-8"))); } catch (IOException ioe) { throw new RuntimeException("Error during dump to file", ioe); } From 9619d3d145e9fccf052fdb6cbc48c74567ecd997 Mon Sep 17 00:00:00 2001 From: Andrei Punko Date: Fri, 6 Aug 2021 09:35:50 +0300 Subject: [PATCH 5/5] Bump artifacts versions --- pom.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 5f24ee3..6f2e42e 100644 --- a/pom.xml +++ b/pom.xml @@ -13,10 +13,10 @@ 11 ${java.version} ${java.version} - 2.9.10.7 + 2.10.5 3.8.1 - 4.2 - 2.7 + 4.4 + 2.10.0 1.9 1.2.0 @@ -105,7 +105,7 @@ org.apache.commons commons-collections4 - ${apache.commons-collections.version} + ${apache.commons-collections4.version} commons-io