Skip to content

Commit

Permalink
[Improve][doc] Add doc name check (#8140)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangshenghang authored Nov 28, 2024
1 parent 2dbf02d commit 73b76c3
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 1 deletion.
File renamed without changes.
3 changes: 3 additions & 0 deletions docs/en/contribution/how-to-create-your-connector.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Develop Your Own Connector

If you want to develop your own connector for the new SeaTunnel connector API (Connector V2), please check [here](https://github.com/apache/seatunnel/blob/dev/seatunnel-connectors-v2/README.md).
1 change: 1 addition & 0 deletions docs/sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ const sidebars = {
'contribution/new-license',
'contribution/coding-guide',
'contribution/contribute-transform-v2-guide',
'contribution/how-to-create-your-connector'
],
},
"faq"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledOnOs;
import org.junit.jupiter.api.condition.OS;

import java.io.IOException;
import java.nio.charset.StandardCharsets;
Expand All @@ -31,7 +33,7 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class MarkdownHeaderTest {
public class MarkdownTest {

private static final List<Path> docsDirectorys = new ArrayList<>();

Expand All @@ -41,6 +43,53 @@ public static void setup() {
docsDirectorys.add(Paths.get("..", "docs", "zh"));
}

@Test
@DisabledOnOs(OS.WINDOWS)
public void testChineseDocFileNameContainsInEnglishVersionDoc() {
// Verify that the file names in the English and Chinese directories are the same.
List<String> enFileName =
fileName(docsDirectorys.get(0)).stream()
.map(path -> path.replace("/en/", "/"))
.collect(Collectors.toList());
List<String> zhFileName =
fileName(docsDirectorys.get(1)).stream()
.map(path -> path.replace("/zh/", "/"))
.collect(Collectors.toList());

// Find Chinese files that don't have English counterparts
List<String> missingEnglishFiles =
zhFileName.stream()
.filter(zhFile -> !enFileName.contains(zhFile))
.collect(Collectors.toList());

// If there are files missing English versions, throw an exception
if (!missingEnglishFiles.isEmpty()) {
StringBuilder errorMessage = new StringBuilder();
errorMessage.append(
String.format(
"Found %d Chinese files without English versions:\n",
missingEnglishFiles.size()));

missingEnglishFiles.forEach(
file ->
errorMessage.append(
String.format("Missing English version for: %s\n", file)));

throw new AssertionError(errorMessage.toString());
}
}

private List<String> fileName(Path docDirectory) {
try (Stream<Path> paths = Files.walk(docDirectory)) {
return paths.filter(Files::isRegularFile)
.filter(path -> path.toString().endsWith(".md"))
.map(Path::toString)
.collect(Collectors.toList());
} catch (IOException e) {
throw new RuntimeException(e);
}
}

@Test
public void testPrimaryHeadersHaveNoTextAbove() {
docsDirectorys.forEach(
Expand Down

0 comments on commit 73b76c3

Please sign in to comment.