Skip to content

Commit 8e56c24

Browse files
committed
Update generate_module_docs.js
1 parent 6e7b1f2 commit 8e56c24

File tree

1 file changed

+30
-3
lines changed

1 file changed

+30
-3
lines changed

generate_module_docs.js

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,30 @@ function stripH1(content) {
1818
return content.replace(/^#\s+.*\n?/, '').trim()
1919
}
2020

21+
function stripRealmIdentifiers(content) {
22+
if (!content) return ''
23+
return content
24+
.replace(/<div class="realm-[^"]+">/g, '')
25+
.replace(/<div class="realm-header">[^<]+<\/div>/g, '')
26+
.replace(/<div class="details-content">/g, '')
27+
.replace(/<\/div>/g, (match, offset, str) => {
28+
// Basic check to only remove divs that were likely our wrappers
29+
// This is a bit naive but works for the common case
30+
return ''
31+
})
32+
.trim()
33+
}
34+
35+
function stripWrappers(content) {
36+
// More robust stripping of our specific containers
37+
let cleaned = stripH1(content)
38+
cleaned = cleaned.replace(/<div class="realm-[^"]+">/g, '')
39+
cleaned = cleaned.replace(/<div class="realm-header">[^<]*<\/div>/g, '')
40+
cleaned = cleaned.replace(/<div class="details-content">/g, '')
41+
cleaned = cleaned.replace(/<\/div>/g, '')
42+
return cleaned.trim()
43+
}
44+
2145
function getChangelog(folder) {
2246
const changelogPath = path.join(docsModulesDir, folder, 'changelog.md')
2347
if (fs.existsSync(changelogPath)) {
@@ -78,14 +102,17 @@ function main() {
78102
}
79103
})
80104

81-
let markdown = '# List of Modules\n\n'
105+
let markdown = '# Modules\n\n'
82106

83107
const categories = ['Modules', 'Droppers']
84108
categories.forEach(category => {
85109
const mods = grouped[category]
86110
if (mods.length === 0 && category === 'Droppers') return
87111

88-
markdown += `## ${category}\n\n`
112+
if (category !== 'Modules') {
113+
markdown += `## ${category}\n\n`
114+
}
115+
89116
if (mods.length === 0) {
90117
markdown += 'No modules found.\n\n'
91118
return
@@ -105,7 +132,7 @@ function main() {
105132
markdown += `<details id="${slug}">\n<summary>${name}</summary>\n\n`
106133

107134
if (about) {
108-
markdown += `### About\n\n${stripH1(about)}\n\n`
135+
markdown += `${stripWrappers(about)}\n\n`
109136
} else {
110137
markdown += `- **Description**: ${description}\n`
111138
}

0 commit comments

Comments
 (0)