45 lines
1.2 KiB
JavaScript
45 lines
1.2 KiB
JavaScript
|
|
#!/usr/bin/env node
|
||
|
|
|
||
|
|
const fs = require('fs');
|
||
|
|
const path = require('path');
|
||
|
|
|
||
|
|
// Test with a known file that has tests
|
||
|
|
const testFile = path.join(__dirname, '../source/Ox/js/Array.js');
|
||
|
|
const source = fs.readFileSync(testFile, 'utf-8');
|
||
|
|
|
||
|
|
// Regular expressions from Ox.doc
|
||
|
|
const re = {
|
||
|
|
multiline: /\/\*@([\w\W]+?)@?\*\//g,
|
||
|
|
singleline: /\/\/@\s*(.*?)\s*$/gm,
|
||
|
|
test: /^\s*>\s+(.+)$/,
|
||
|
|
expected: /^\s*([^>].*)$/,
|
||
|
|
item: /^(.+?)\s+<(.+?)>\s+(.+?)$/,
|
||
|
|
};
|
||
|
|
|
||
|
|
// Find all multiline comments
|
||
|
|
let match;
|
||
|
|
let found = 0;
|
||
|
|
console.log('Searching for /*@ comments in Array.js...\n');
|
||
|
|
|
||
|
|
while ((match = re.multiline.exec(source)) !== null) {
|
||
|
|
found++;
|
||
|
|
const content = match[1];
|
||
|
|
const lines = content.split('\n');
|
||
|
|
const firstLine = lines[0].trim();
|
||
|
|
|
||
|
|
console.log(`Found comment #${found}:`);
|
||
|
|
console.log('First line:', firstLine);
|
||
|
|
|
||
|
|
// Look for tests
|
||
|
|
let testCount = 0;
|
||
|
|
for (const line of lines) {
|
||
|
|
if (line.match(re.test)) {
|
||
|
|
testCount++;
|
||
|
|
console.log(' Test:', line);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
console.log(` Total tests in this block: ${testCount}`);
|
||
|
|
console.log('');
|
||
|
|
}
|
||
|
|
|
||
|
|
console.log(`\nTotal doc blocks found: ${found}`);
|