Skip to content

Commit 629e9fd

Browse files
committed
Fix parsing
1 parent d105ab9 commit 629e9fd

File tree

5 files changed

+317
-22
lines changed

5 files changed

+317
-22
lines changed

.github/workflows/update-readme.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ jobs:
2424
token: ${{ secrets.GITHUB_TOKEN }}
2525
fetch-depth: 0
2626

27-
- name: Set up Java
28-
uses: actions/setup-java@v4
29-
with:
30-
distribution: "temurin"
31-
java-version: "25"
27+
- name: Set up Java
28+
uses: actions/setup-java@v4
29+
with:
30+
distribution: "temurin"
31+
java-version: "25"
3232

3333
- name: Step 1 - Validate Input
3434
run: |

README.md

Lines changed: 100 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -411,11 +411,12 @@ _Libraries that provide caching facilities._
411411
_Libraries for everything related to the CLI._
412412

413413
#### Argument Parsing
414+
414415
_Libraries to assist with parsing command line arguments._
415416

416417

417418

418-
<!-- SECTION:CLI -->
419+
<!-- SECTION:CLI > Argument Parsing -->
419420
<table style="width:100%;table-layout:fixed;border-collapse:collapse;">
420421
<tbody>
421422
<tr>
@@ -458,6 +459,18 @@ _Libraries to assist with parsing command line arguments._
458459
<td style="width:7.5%;text-align:center;">-</td>
459460
<td style="width:7.5%;text-align:center;">-</td>
460461
</tr>
462+
</tbody>
463+
</table>
464+
465+
#### Text-Based User Interfaces
466+
467+
_Libraries that provide TUI frameworks, or building blocks related functions._
468+
469+
470+
471+
<!-- SECTION:CLI > Text-Based User Interfaces -->
472+
<table style="width:100%;table-layout:fixed;border-collapse:collapse;">
473+
<tbody>
461474
<tr>
462475
<td style="width:20%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;">
463476
<a href="https://github.com/fusesource/jansi">Jansi</a>
@@ -4676,7 +4689,8 @@ _Frameworks that are suites of multiple libraries encompassing several categorie
46764689
#### Apache Commons
46774690

46784691

4679-
<!-- SECTION:Platform -->
4692+
4693+
<!-- SECTION:Platform > Apache Commons -->
46804694
<table style="width:100%;table-layout:fixed;border-collapse:collapse;">
46814695
<tbody>
46824696
<tr>
@@ -5111,6 +5125,16 @@ _Frameworks that are suites of multiple libraries encompassing several categorie
51115125
<td style="width:7.5%;text-align:center;">-</td>
51125126
<td style="width:7.5%;text-align:center;">-</td>
51135127
</tr>
5128+
</tbody>
5129+
</table>
5130+
5131+
#### Other
5132+
5133+
5134+
5135+
<!-- SECTION:Platform > Other -->
5136+
<table style="width:100%;table-layout:fixed;border-collapse:collapse;">
5137+
<tbody>
51145138
<tr>
51155139
<td style="width:20%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;">
51165140
<a href="https://www.cuba-platform.com/">CUBA Platform</a>
@@ -5939,11 +5963,12 @@ _Tools that substitute expressions in a template._
59395963
_Tools that test from model to the view._
59405964

59415965
#### Asynchronous
5966+
59425967
_Tools that simplify testing asynchronous services._
59435968

59445969

59455970

5946-
<!-- SECTION:Testing -->
5971+
<!-- SECTION:Testing > Asynchronous -->
59475972
<table style="width:100%;table-layout:fixed;border-collapse:collapse;">
59485973
<tbody>
59495974
<tr>
@@ -6002,6 +6027,18 @@ _Tools that simplify testing asynchronous services._
60026027
<td style="width:7.5%;text-align:center;"><img src="https://img.shields.io/github/stars/testingisdocumenting/webtau?style=flat-square&label=" alt="GitHub stars"></td>
60036028
<td style="width:7.5%;text-align:center;"><img src="https://img.shields.io/github/last-commit/testingisdocumenting/webtau?style=flat-square&label=" alt="Last commit"></td>
60046029
</tr>
6030+
</tbody>
6031+
</table>
6032+
6033+
#### BDD
6034+
6035+
_Testing for the software development process that emerged from TDD and was heavily influenced by DDD and OOAD._
6036+
6037+
6038+
6039+
<!-- SECTION:Testing > BDD -->
6040+
<table style="width:100%;table-layout:fixed;border-collapse:collapse;">
6041+
<tbody>
60056042
<tr>
60066043
<td style="width:20%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;">
60076044
<a href="https://github.com/cucumber/cucumber-jvm">Cucumber</a>
@@ -6058,6 +6095,18 @@ _Tools that simplify testing asynchronous services._
60586095
<td style="width:7.5%;text-align:center;"><img src="https://img.shields.io/github/stars/serenity-bdd/serenity-core?style=flat-square&label=" alt="GitHub stars"></td>
60596096
<td style="width:7.5%;text-align:center;"><img src="https://img.shields.io/github/last-commit/serenity-bdd/serenity-core?style=flat-square&label=" alt="Last commit"></td>
60606097
</tr>
6098+
</tbody>
6099+
</table>
6100+
6101+
#### Fixtures
6102+
6103+
_Everything related to the creation and handling of random data._
6104+
6105+
6106+
6107+
<!-- SECTION:Testing > Fixtures -->
6108+
<table style="width:100%;table-layout:fixed;border-collapse:collapse;">
6109+
<tbody>
60616110
<tr>
60626111
<td style="width:20%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;">
60636112
<a href="https://github.com/AutoParams/AutoParams">AutoParams</a>
@@ -6138,6 +6187,18 @@ _Tools that simplify testing asynchronous services._
61386187
<td style="width:7.5%;text-align:center;"><img src="https://img.shields.io/github/stars/xcancloud/JMock?style=flat-square&label=" alt="GitHub stars"></td>
61396188
<td style="width:7.5%;text-align:center;"><img src="https://img.shields.io/github/last-commit/xcancloud/JMock?style=flat-square&label=" alt="Last commit"></td>
61406189
</tr>
6190+
</tbody>
6191+
</table>
6192+
6193+
#### Frameworks
6194+
6195+
_Provide environments to run tests for a specific use case._
6196+
6197+
6198+
6199+
<!-- SECTION:Testing > Frameworks -->
6200+
<table style="width:100%;table-layout:fixed;border-collapse:collapse;">
6201+
<tbody>
61416202
<tr>
61426203
<td style="width:20%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;">
61436204
<a href="http://jmeter.apache.org">Apache JMeter</a>
@@ -6226,6 +6287,18 @@ _Tools that simplify testing asynchronous services._
62266287
<td style="width:7.5%;text-align:center;"><img src="https://img.shields.io/github/stars/weld/weld-testing?style=flat-square&label=" alt="GitHub stars"></td>
62276288
<td style="width:7.5%;text-align:center;"><img src="https://img.shields.io/github/last-commit/weld/weld-testing?style=flat-square&label=" alt="Last commit"></td>
62286289
</tr>
6290+
</tbody>
6291+
</table>
6292+
6293+
#### Matchers
6294+
6295+
_Libraries that provide custom matchers._
6296+
6297+
6298+
6299+
<!-- SECTION:Testing > Matchers -->
6300+
<table style="width:100%;table-layout:fixed;border-collapse:collapse;">
6301+
<tbody>
62296302
<tr>
62306303
<td style="width:20%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;">
62316304
<a href="https://joel-costigliola.github.io/assertj/">AssertJ</a>
@@ -6274,6 +6347,18 @@ _Tools that simplify testing asynchronous services._
62746347
<td style="width:7.5%;text-align:center;"><img src="https://img.shields.io/github/stars/xmlunit/xmlunit?style=flat-square&label=" alt="GitHub stars"></td>
62756348
<td style="width:7.5%;text-align:center;"><img src="https://img.shields.io/github/last-commit/xmlunit/xmlunit?style=flat-square&label=" alt="Last commit"></td>
62766349
</tr>
6350+
</tbody>
6351+
</table>
6352+
6353+
#### Miscellaneous
6354+
6355+
_Other stuff related to testing._
6356+
6357+
6358+
6359+
<!-- SECTION:Testing > Miscellaneous -->
6360+
<table style="width:100%;table-layout:fixed;border-collapse:collapse;">
6361+
<tbody>
62776362
<tr>
62786363
<td style="width:20%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;">
62796364
<a href="https://github.com/Hakky54/console-captor">ConsoleCaptor</a>
@@ -6362,6 +6447,18 @@ _Tools that simplify testing asynchronous services._
63626447
<td style="width:7.5%;text-align:center;"><img src="https://img.shields.io/github/stars/testcontainers/testcontainers-java?style=flat-square&label=" alt="GitHub stars"></td>
63636448
<td style="width:7.5%;text-align:center;"><img src="https://img.shields.io/github/last-commit/testcontainers/testcontainers-java?style=flat-square&label=" alt="Last commit"></td>
63646449
</tr>
6450+
</tbody>
6451+
</table>
6452+
6453+
#### Mocking
6454+
6455+
_Tools which mock collaborators to help testing single, isolated units._
6456+
6457+
6458+
6459+
<!-- SECTION:Testing > Mocking -->
6460+
<table style="width:100%;table-layout:fixed;border-collapse:collapse;">
6461+
<tbody>
63656462
<tr>
63666463
<td style="width:20%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;">
63676464
<a href="http://jmockit.github.io">JMockit</a>

scripts/step_2_parse_projects.java

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,12 @@ List<ProjectEntry> parseProjectEntries(String content) {
4040
var projectEntries = new ArrayList<ProjectEntry>();
4141
var inProjectSection = false;
4242
var currentSection = "";
43+
var sectionStack = new ArrayList<String>();
4344

4445
for (int i = 0; i < lines.length; i++) {
4546
var line = lines[i];
4647
var isSubsection = line.startsWith(Constants.SUBSECTION);
48+
var sectionLevel = getSectionLevel(line);
4749

4850
// Check if we're entering the Projects section
4951
if (line.startsWith(Constants.PROJECTS_SECTION)) {
@@ -54,16 +56,32 @@ List<ProjectEntry> parseProjectEntries(String content) {
5456
if (inProjectSection &&
5557
line.startsWith(Constants.SECTION) &&
5658
!isSubsection &&
59+
sectionLevel == 0 &&
5760
!line.equals(Constants.PROJECTS_SECTION)
5861
) {
5962
inProjectSection = false;
6063
}
6164
if (!inProjectSection) {
6265
continue;
6366
}
64-
// Track current subsection
65-
if (isSubsection) {
66-
currentSection = line.substring(Constants.SUBSECTION.length());
67+
// Track section hierarchy - maintain a stack of section levels
68+
if (sectionLevel >= 3) {
69+
var sectionName = line.substring(sectionLevel + 1).trim();
70+
71+
// Adjust stack size to match current level
72+
while (sectionStack.size() >= sectionLevel - 2) {
73+
sectionStack.remove(sectionStack.size() - 1);
74+
}
75+
76+
// Add current section to stack
77+
sectionStack.add(sectionName);
78+
79+
// Build full section path for entries
80+
if (sectionStack.size() == 1) {
81+
currentSection = sectionName; // Main section (###)
82+
} else {
83+
currentSection = String.join(" > ", sectionStack); // Subsection path
84+
}
6785
continue;
6886
}
6987
// Skip headers and empty lines
@@ -83,6 +101,24 @@ List<ProjectEntry> parseProjectEntries(String content) {
83101
return projectEntries;
84102
}
85103

104+
/**
105+
* Determines the section level based on the number of # symbols.
106+
* Returns 0 if the line is not a section header.
107+
*/
108+
int getSectionLevel(String line) {
109+
if (!line.startsWith("#")) {
110+
return 0;
111+
}
112+
113+
int level = 0;
114+
for (int i = 0; i < line.length() && line.charAt(i) == '#'; i++) {
115+
level++;
116+
}
117+
118+
// Must have at least 3 # symbols and a space after them
119+
return (level >= 3 && line.length() > level && line.charAt(level) == ' ') ? level : 0;
120+
}
121+
86122
/**
87123
* Parses a single project entry from the list format.
88124
*/
@@ -102,6 +138,7 @@ ProjectEntry parseProjectEntry(String[] lines, int startIndex, String section) {
102138
if (nextLine.isBlank() ||
103139
nextLine.startsWith(Constants.SECTION) ||
104140
nextLine.startsWith(Constants.SUBSECTION) ||
141+
getSectionLevel(nextLine) > 0 ||
105142
nextLine.matches(Constants.ENTRY_PATTERN)
106143
) {
107144
break;

scripts/step_5_assemble_readme.java

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ String assembleReadme(String originalContent, String tablesContent) {
4747
// Create a mapping of sections to their tables
4848
var sectionToTableMap = createSectionToTableMap(tables);
4949

50+
5051
for (int i = 0; i < lines.length; i++) {
5152
var line = lines[i];
5253

@@ -79,6 +80,11 @@ String assembleReadme(String originalContent, String tablesContent) {
7980
result.append(line).append("\n\n");
8081
continue;
8182
}
83+
// Handle sub-subsection headers (####)
84+
if (line.startsWith("#### ")) {
85+
result.append(line).append("\n\n");
86+
continue;
87+
}
8288
// Handle headers
8389
if (line.startsWith("_") && line.endsWith("_")) {
8490
result.append(line).append("\n\n");
@@ -95,9 +101,10 @@ String assembleReadme(String originalContent, String tablesContent) {
95101
if (currentSubsection != null && sectionToTableMap.containsKey(currentSubsection)) {
96102
result.append(sectionToTableMap.get(currentSubsection)).append("</table>\n\n");
97103
}
98-
// Skip ALL remaining list items in this section until we hit the next subsection or end delimiter
104+
// Skip remaining list items in this subsection until we hit the next subsection or end delimiter
99105
while (i + 1 < lines.length &&
100106
!lines[i + 1].startsWith(Constants.SUBSECTION) &&
107+
!lines[i + 1].startsWith("#### ") &&
101108
!lines[i + 1].contains(Constants.END_PROJECTS_SECTION_COMMENT)) {
102109
i++;
103110
if (lines[i].matches(Constants.ENTRY_PATTERN)) {
@@ -161,13 +168,33 @@ Map<String, String> createSectionToTableMap(String[] tables) {
161168

162169
/**
163170
* Finds the current subsection by looking backwards from the given line index.
171+
* Handles both flat sections (###) and hierarchical sections (####).
164172
*/
165173
String findCurrentSubsection(String[] lines, int currentIndex) {
174+
String currentMainSection = null;
175+
String currentSubsection = null;
176+
166177
for (int i = currentIndex; i >= 0; i--) {
167178
var line = lines[i];
179+
180+
// Check for subsection (####) first
181+
if (line.startsWith("#### ") && currentSubsection == null) {
182+
currentSubsection = line.substring(5).trim();
183+
}
184+
185+
// Check for main section (###)
168186
if (line.startsWith(Constants.SUBSECTION)) {
169-
return line.substring(Constants.SUBSECTION.length());
187+
currentMainSection = line.substring(Constants.SUBSECTION.length());
188+
break; // Stop when we find the main section
170189
}
171190
}
172-
return null;
191+
192+
// If we found both main section and subsection, return hierarchical name
193+
if (currentMainSection != null && currentSubsection != null) {
194+
return currentMainSection + " > " + currentSubsection;
195+
}
196+
197+
// Otherwise return just the main section
198+
return currentMainSection;
173199
}
200+

0 commit comments

Comments
 (0)