From 5ae9a9f8a53305e90893f219e5fdcb1b18561a96 Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Sat, 14 Aug 2021 18:59:49 +0200 Subject: [PATCH] Update docs --- packages/franc-all/readme.md | 4 ++ packages/franc-cli/readme.md | 3 + packages/franc-min/readme.md | 4 ++ packages/franc/readme.md | 4 ++ readme.md | 47 ++++++++++----- script/build.js | 113 ++++++++++++++++++++--------------- 6 files changed, 111 insertions(+), 64 deletions(-) diff --git a/packages/franc-all/readme.md b/packages/franc-all/readme.md index 30bae00..cae5767 100644 --- a/packages/franc-all/readme.md +++ b/packages/franc-all/readme.md @@ -11,6 +11,10 @@ usage information. ## Install +This package is [ESM only](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c): +Node 12+ is needed to use it and it must be +`import`ed instead of `require`d. + npm: ```sh diff --git a/packages/franc-cli/readme.md b/packages/franc-cli/readme.md index e976bdf..9a2a099 100644 --- a/packages/franc-cli/readme.md +++ b/packages/franc-cli/readme.md @@ -7,6 +7,9 @@ and usage information. ## Install +This package is [ESM only](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c): +Node 12+ is needed to use it. + npm: ```sh diff --git a/packages/franc-min/readme.md b/packages/franc-min/readme.md index e79b7af..e233825 100644 --- a/packages/franc-min/readme.md +++ b/packages/franc-min/readme.md @@ -11,6 +11,10 @@ usage information. ## Install +This package is [ESM only](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c): +Node 12+ is needed to use it and it must be +`import`ed instead of `require`d. + npm: ```sh diff --git a/packages/franc/readme.md b/packages/franc/readme.md index a59d8bd..fa2a08a 100644 --- a/packages/franc/readme.md +++ b/packages/franc/readme.md @@ -11,6 +11,10 @@ usage information. ## Install +This package is [ESM only](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c): +Node 12+ is needed to use it and it must be +`import`ed instead of `require`d. + npm: ```sh diff --git a/readme.md b/readme.md index eee8e67..67b3aca 100644 --- a/readme.md +++ b/readme.md @@ -23,6 +23,9 @@ Make sure to pass it big documents to get reliable results. ## Install +This package is [ESM only](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c): +Node 12+ is needed to use it and it must be `import`ed instead of `require`d. + [npm][]: ```sh @@ -40,8 +43,11 @@ available on [GitHub Releases][releases]. ## Use +This package exports the following identifiers: `franc`, `francAll`. +There is no default export. + ```js -var franc = require('franc') +import {franc, francAll} from 'franc' franc('Alle menslike wesens word vry') // => 'afr' franc('এটি একটি ভাষা একক IBM স্ক্রিপ্ট') // => 'ben' @@ -57,47 +63,56 @@ franc('the', {minLength: 3}) // => 'sco' ###### `.all` ```js -console.log(franc.all('O Brasil caiu 26 posições')) +console.log(francAll('Considerando ser essencial que os direitos humanos')) ``` Yields: ```js -[ [ 'por', 1 ], - [ 'src', 0.8797557538750587 ], - [ 'glg', 0.8708313762329732 ], - [ 'snn', 0.8633161108501644 ], - [ 'bos', 0.8172851103804604 ], - ... 116 more items ] +[ + [ 'por', 1 ], + [ 'glg', 0.771284519307895 ], + [ 'spa', 0.6034146900423971 ], + [ 'cat', 0.5367251059928957 ], + [ 'src', 0.47461899851037015 ], + ... 122 more items ] ``` ###### `only` ```js -console.log(franc.all('O Brasil caiu 26 posições', {only: ['por', 'spa']})) +console.log( + francAll('Considerando ser essencial que os direitos humanos', { + only: ['por', 'spa'] + }) +) ``` Yields: ```js -[ [ 'por', 1 ], [ 'spa', 0.799906059182715 ] ] +[ [ 'por', 1 ], [ 'spa', 0.6034146900423971 ] ] ``` ###### `ignore` ```js -console.log(franc.all('O Brasil caiu 26 posições', {ignore: ['src', 'glg']})) +console.log( + francAll('Considerando ser essencial que os direitos humanos', { + ignore: ['src', 'glg'] + }) +) ``` Yields: ```js [ [ 'por', 1 ], - [ 'snn', 0.8633161108501644 ], - [ 'bos', 0.8172851103804604 ], - [ 'hrv', 0.8107092531705026 ], - [ 'lav', 0.810239549084077 ], - ... 114 more items ] + [ 'spa', 0.6034146900423971 ], + [ 'cat', 0.5367251059928957 ], + [ 'ita', 0.4740460639394981 ], + [ 'fra', 0.44757648676521145 ], + ... 120 more items ] ``` ## CLI diff --git a/script/build.js b/script/build.js index e95774f..9a42748 100644 --- a/script/build.js +++ b/script/build.js @@ -378,6 +378,25 @@ async function main() { depth: 2, children: [{type: 'text', value: 'Install'}] }, + { + type: 'paragraph', + children: [ + {type: 'text', value: 'This package is '}, + { + type: 'link', + url: 'https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c', + children: [{type: 'text', value: 'ESM only'}] + }, + { + type: 'text', + value: ':\nNode 12+ is needed to use it and it must be\n' + }, + {type: 'inlineCode', value: 'import'}, + {type: 'text', value: 'ed instead of '}, + {type: 'inlineCode', value: 'require'}, + {type: 'text', value: 'd.'} + ] + }, {type: 'paragraph', children: [{type: 'text', value: 'npm:'}]}, {type: 'code', lang: 'sh', value: 'npm install ' + pack.name}, { @@ -409,7 +428,52 @@ async function main() { } ] }, - ...list.map((d) => row(d)) + ...list.map((info) => ({ + type: 'tableRow', + children: [ + { + type: 'tableCell', + children: [ + { + type: 'link', + url: + 'http://www-01.sil.org/iso639-3/documentation.asp?id=' + + info.code, + title: null, + children: [{type: 'inlineCode', value: info.code}] + } + ] + }, + { + type: 'tableCell', + children: [ + { + type: 'text', + value: + info.name + + (counts[info.code] === 1 + ? '' + : ' (' + info.script + ')') + } + ] + }, + { + type: 'tableCell', + children: [ + { + type: 'text', + value: + typeof info.speakers === 'number' + ? info.speakers.toLocaleString('en', { + notation: 'compact', + maximumFractionDigits: 0 + }) + : 'unknown' + } + ] + } + ] + })) ] }, { @@ -437,53 +501,6 @@ async function main() { } return unified().use(stringify).use(gfm).stringify(tree) - - function row(info) { - return { - type: 'tableRow', - children: [ - { - type: 'tableCell', - children: [ - { - type: 'link', - url: - 'http://www-01.sil.org/iso639-3/documentation.asp?id=' + - info.code, - title: null, - children: [{type: 'inlineCode', value: info.code}] - } - ] - }, - { - type: 'tableCell', - children: [ - { - type: 'text', - value: - info.name + - (counts[info.code] === 1 ? '' : ' (' + info.script + ')') - } - ] - }, - { - type: 'tableCell', - children: [ - { - type: 'text', - value: - typeof info.speakers === 'number' - ? info.speakers.toLocaleString('en', { - notation: 'compact', - maximumFractionDigits: 0 - }) - : 'unknown' - } - ] - } - ] - } - } } function count(list) {