From 102803cb45b57893df2b52c7fc394f08b2163b73 Mon Sep 17 00:00:00 2001 From: Frazer Smith Date: Thu, 6 Feb 2025 09:35:47 +0000 Subject: [PATCH] docs(api): add api documentation (#41) * docs(api): add api documentation * chore: force eol style --- .husky/pre-commit | 3 ++- API.md | 36 ++++++++++++++++++++++++++++++++++++ README.md | 6 ++++-- package.json | 2 ++ 4 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 API.md diff --git a/.husky/pre-commit b/.husky/pre-commit index 4c260d1..7c5c6b0 100644 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1 +1,2 @@ -npm run lint:licenses && npm test \ No newline at end of file +npm run lint:licenses && npm test +npm run build:docs && git add API.md \ No newline at end of file diff --git a/API.md b/API.md new file mode 100644 index 0000000..91457b9 --- /dev/null +++ b/API.md @@ -0,0 +1,36 @@ +## Constants + +
+
replacements : Record.<string, string>
+

Object containing Latin-1 characters and their corresponding UTF-8 characters.

+
+
+ +## Functions + +
+
fixLatin1ToUtf8(str)string
+

Fixes common encoding errors when converting from Latin-1 (and Windows-1252) to UTF-8.

+
+
+ + + +## replacements : Record.<string, string> +Object containing Latin-1 characters and their corresponding UTF-8 characters. + +**Kind**: global constant + + +## fixLatin1ToUtf8(str) ⇒ string +Fixes common encoding errors when converting from Latin-1 (and Windows-1252) to UTF-8. + +**Kind**: global function +**Returns**: string - The converted string. +**See**: [ UTF-8 Encoding Debugging Chart](http://www.i18nqa.com/debug/utf8-debug.html) +**Author**: Frazer Smith + +| Param | Type | Description | +| --- | --- | --- | +| str | string | The string to be converted. | + diff --git a/README.md b/README.md index d5744b5..356f948 100644 --- a/README.md +++ b/README.md @@ -20,9 +20,11 @@ Install using `npm`: npm i fix-latin1-to-utf8 ``` -## Example usage +## API + +API documentation can be found [here](https://github.com/Fdawgs/fix-latin1-to-utf8/blob/main/API.md). -Please refer to the [JSDoc comments in the source code](./src/index.js) or the [generated type definitions](https://www.npmjs.com/package/fix-latin1-to-utf8?activeTab=code) for information on the available options. +## Example usage ```js const fixLatin1ToUtf8 = require("fix-latin1-to-utf8"); diff --git a/package.json b/package.json index 4da7817..d002f42 100644 --- a/package.json +++ b/package.json @@ -31,6 +31,7 @@ }, "scripts": { "build": "tsc", + "build:docs": "jsdoc2md src/index.js > API.md --EOL posix", "lint": "eslint . --cache --ext js,jsx --ignore-path .gitignore", "lint:fix": "npm run lint -- --fix", "lint:licenses": "node scripts/license-checker.js", @@ -60,6 +61,7 @@ "eslint-plugin-regexp": "^2.7.0", "eslint-plugin-security": "^3.0.1", "husky": "^9.1.7", + "jsdoc-to-markdown": "^9.1.1", "license-checker": "^25.0.1", "prettier": "^3.4.2", "spdx-copyleft": "^1.0.0",