Skip to content

Commit

Permalink
Generate only neccessary path to md files from labels (#60)
Browse files Browse the repository at this point in the history
Signed-off-by: Jakub Stejskal <[email protected]>
  • Loading branch information
Frawless authored Sep 6, 2024
1 parent 4be8db3 commit 051cb2f
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 16 deletions.
4 changes: 2 additions & 2 deletions docs/expected/option1/labels/default.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@

<!-- generated part -->
**Tests:**
- [testMethodOne](../../../.././docs/actual/option1/md/io/skodjob/DummyTest.md)
- [testMethodFour](../../../.././docs/actual/option1/md/io/skodjob/DummyTest.md)
- [testMethodOne](../md/io/skodjob/DummyTest.md)
- [testMethodFour](../md/io/skodjob/DummyTest.md)
2 changes: 1 addition & 1 deletion docs/expected/option1/labels/regression.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@

<!-- generated part -->
**Tests:**
- [testMethodFour](../../../.././docs/actual/option1/md/io/skodjob/DummyTest.md)
- [testMethodFour](../md/io/skodjob/DummyTest.md)
4 changes: 2 additions & 2 deletions docs/expected/option2/labels/default.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@

<!-- generated part -->
**Tests:**
- [testMethodOne](../../../.././docs/actual/option2/md/io.skodjob.DummyTest.md)
- [testMethodFour](../../../.././docs/actual/option2/md/io.skodjob.DummyTest.md)
- [testMethodOne](../md/io.skodjob.DummyTest.md)
- [testMethodFour](../md/io.skodjob.DummyTest.md)
2 changes: 1 addition & 1 deletion docs/expected/option2/labels/regression.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@

<!-- generated part -->
**Tests:**
- [testMethodFour](../../../.././docs/actual/option2/md/io.skodjob.DummyTest.md)
- [testMethodFour](../md/io.skodjob.DummyTest.md)
4 changes: 2 additions & 2 deletions docs/expected/option3/labels/default.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@

<!-- generated part -->
**Tests:**
- [testMethodOne](../../../.././docs/actual/option3/io.skodjob.DummyTest.md)
- [testMethodFour](../../../.././docs/actual/option3/io.skodjob.DummyTest.md)
- [testMethodOne](../io.skodjob.DummyTest.md)
- [testMethodFour](../io.skodjob.DummyTest.md)
2 changes: 1 addition & 1 deletion docs/expected/option3/labels/regression.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@

<!-- generated part -->
**Tests:**
- [testMethodFour](../../../.././docs/actual/option3/io.skodjob.DummyTest.md)
- [testMethodFour](../io.skodjob.DummyTest.md)
4 changes: 2 additions & 2 deletions docs/expected/option4/labels/default.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@

<!-- generated part -->
**Tests:**
- [testMethodOne](../../../.././docs/actual/option4/io/skodjob/DummyTest.md)
- [testMethodFour](../../../.././docs/actual/option4/io/skodjob/DummyTest.md)
- [testMethodOne](../io/skodjob/DummyTest.md)
- [testMethodFour](../io/skodjob/DummyTest.md)
2 changes: 1 addition & 1 deletion docs/expected/option4/labels/regression.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@

<!-- generated part -->
**Tests:**
- [testMethodFour](../../../.././docs/actual/option4/io/skodjob/DummyTest.md)
- [testMethodFour](../io/skodjob/DummyTest.md)
Original file line number Diff line number Diff line change
Expand Up @@ -312,17 +312,14 @@ private static void updateLabelFile(String labelFilePath, String updatedData) {
public static void updateLinksInLabels(String docsPath) {
String labelsPath = docsPath + LABELS;

int numberOfDirs = docsPath.length() - docsPath.replace("/", "").length();
String mdFilesPath = "../".repeat(numberOfDirs);

if (Files.exists(new File(labelsPath).toPath())) {
for (Map.Entry<String, Map<String, String>> entry : MdGenerator.labelsMap.entrySet()) {
String labelsFile = labelsPath + "/" + entry.getKey() + ".md";

if (Files.exists(new File(labelsFile).toPath())) {
StringBuilder newText = new StringBuilder("**Tests:**");
for (Map.Entry<String, String> item : entry.getValue().entrySet()) {
String data = String.format("[%s](%s%s)", item.getKey(), mdFilesPath, item.getValue());
String data = String.format("[%s](%s%s)", item.getKey(), "../", item.getValue().replace(docsPath, ""));
newText.append("\n- ").append(data);
}

Expand Down

0 comments on commit 051cb2f

Please sign in to comment.