Offline, privacy-first grammar checker. Fast, open-source, Rust-powered
fix: align comment field in `printannotations` (#1617)
Andrew Dunbara2bc3743a0b8
diff --git a/harper-core/annotations.json b/harper-core/annotations.jsonindex 0230262f1..96bc18bb6 100644--- a/harper-core/annotations.json+++ b/harper-core/annotations.json@@ -102,7 +102,7 @@},"^": {"#": "'-(i)est' superlative suffix",- "//": "mnemonic: the topmost is the best. see also 'u' which derives a superlative form",+ "//": "mnemonic: the topmost is the best. see also 'u' which marks a superlative form","kind": "suffix","cross_product": false,"replacements": [@@ -142,7 +142,7 @@"base_metadata": {}},">": {- "#": "'-(i)er' comparative suffix; agent suffix. see also 'c' which derives a comparative form",+ "#": "'-(i)er' comparative suffix; agent suffix. see also 'c' which marks a comparative form","//": "mnemonic: greater than is better","kind": "suffix","cross_product": true,diff --git a/justfile b/justfileindex 5720e6626..0b8c0e62a 100644--- a/justfile+++ b/justfile@@ -440,6 +440,9 @@ registerlinter module name:# Print annotations and their descriptions from annotations.jsonalias printaffixes := printannotations+alias getannotations := printannotations+alias listannotations := printannotations+alias showannotations := printannotationsprintannotations:#! /usr/bin/env node@@ -448,12 +451,25 @@ printannotations:...affixesData.affixes || {},...affixesData.properties || {}};- Object.entries(allEntries).sort((a, b) => a[0].localeCompare(b[0])).forEach(([flag, fields]) => {++ // Calculate the maximum description length for alignment+ const entries = Object.entries(allEntries);+ const maxDescLength = entries.reduce((max, [flag, fields]) => {+ const description = fields['#'] || '';+ const lineLength = flag.length + 2 + description.length; // flag + ': ' + description+ return Math.max(max, lineLength);+ }, 0);++ entries.sort((a, b) => a[0].localeCompare(b[0])).forEach(([flag, fields]) => {const description = fields['#'] || '';const comment = fields['//'] || null;- description && console.log(flag + ': ' + description + (comment ? '\t\t// ' + comment : ''));+ if (description) {+ const line = `${flag}: ${description}`;+ const padding = ' '.repeat(Math.max(1, maxDescLength - line.length + 2));+ console.log(line + (comment ? `${padding}// ${comment}` : ''));+ }});-+console.log('Available letters for new flags:', [...Array.from({length: 26}, (_, i) =>[String.fromCharCode(65 + i), String.fromCharCode(97 + i)]).flat()].filter(letter => !Object.keys(allEntries).includes(letter)).sort().join(' '));