mirror of
https://github.com/Koenkk/zigbee2mqtt.git
synced 2026-08-28 05:24:29 +00:00
Docgen specify directory.
This commit is contained in:
+25
-18
@@ -68,6 +68,7 @@ const plannedToSupport = [
|
||||
|
||||
const zigbee2mqtt = require('../lib/converters/zigbee2mqtt');
|
||||
const deviceMapping = require('../lib/devices');
|
||||
const fs = require('fs');
|
||||
|
||||
// Sanity check if all supported devices are in deviceMapping
|
||||
const supportedDevices = new Set();
|
||||
@@ -80,30 +81,36 @@ supportedDevices.forEach((s) => {
|
||||
}
|
||||
});
|
||||
|
||||
const outputdir = process.argv[2];
|
||||
|
||||
if (!outputdir) {
|
||||
console.error("Please specify an output directory");
|
||||
}
|
||||
|
||||
let file = 'Supported-devices.md';
|
||||
let text = '*NOTE: Automatically generated by `npm run docgen`*\n';
|
||||
text += `
|
||||
In case your device is **NOT** listed here, please create an issue at: https://github.com/Koenkk/zigbee2mqtt/issues
|
||||
\n`;
|
||||
|
||||
const logDevices = (devices) => {
|
||||
console.log('| Model | Description | Picture |')
|
||||
console.log('| ------------- | ------------- | -------------------------- |')
|
||||
let result = '';
|
||||
result += '| Model | Description | Picture |\n';
|
||||
result += '| ------------- | ------------- | -------------------------- |\n';
|
||||
|
||||
devices.forEach((device) => {
|
||||
console.log(`| ${device.model} | ${device.vendor} ${device.description} (${device.supports}) | }.jpg) |`);
|
||||
result += `| ${device.model} | ${device.vendor} ${device.description} (${device.supports}) | }.jpg) |\n`;
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
const vendors = Array.from(new Set(Object.values(deviceMapping).map((d) => d.vendor)));
|
||||
vendors.sort();
|
||||
|
||||
console.log('GENERATED')
|
||||
console.log('=============================')
|
||||
console.log('*NOTE: Automatically generated by `npm run docgen`*')
|
||||
console.log('')
|
||||
console.log('In case your device is **NOT** listed here, please create an issue at: https://github.com/Koenkk/zigbee2mqtt/issues');
|
||||
console.log('')
|
||||
vendors.forEach((vendor) => {
|
||||
console.log(`### ${vendor}`);
|
||||
logDevices(Object.values(deviceMapping).filter((d) => d.vendor === vendor));
|
||||
console.log('');
|
||||
text += `### ${vendor}\n`;
|
||||
text += logDevices(Object.values(deviceMapping).filter((d) => d.vendor === vendor));
|
||||
text += '\n';
|
||||
})
|
||||
console.log('### Planned to support');
|
||||
console.log('Devices listed below are **NOT** supported but are planned to be.');
|
||||
console.log('')
|
||||
logDevices(plannedToSupport);
|
||||
console.log('=============================')
|
||||
|
||||
fs.writeFileSync(outputdir + '/' + file, text);
|
||||
|
||||
Reference in New Issue
Block a user