aboutsummaryrefslogtreecommitdiff
path: root/.local/share/bin/dox-open
blob: 493c435200baba2e3dcb33276baf3f3a540a0ab5 (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
#!/bin/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], ]);
}