aboutsummaryrefslogtreecommitdiff
path: root/home/dot_local/share/bin/executable_dox-open
blob: b259c2756f1ca346485e84ec48881dbecca9156c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env node

import { glob, readFile } from 'node:fs/promises';
import { spawn } from 'node:child_process';
import { argv, chdir, cwd } from 'node:process';
import { join } from 'node:path';

argv.shift();
argv.shift();
chdir("search");

var symbols = {};
for await (const chunk of glob('all_*.js')) {
	const contents = await readFile(chunk);
	const searchData = eval(`${contents}; searchData`);
	const here = cwd();

	for (const [ _id, [ symbol, ...entry ] ] of searchData) {
		symbols[symbol] = entry.map(e => `file://${join(here, e[0])}`);
	}
}

for (const symbol of argv) {
	if (!(symbol in symbols)) {
		console.error(`No doxygen index for symbol \`${symbol}\``);
		continue;
	}
	const urls = symbols[symbol];
	spawn('xdg-open', [ urls[0], ]);
}