From 5c979a84f573876e7911e44c0cf4d10e61f198d6 Mon Sep 17 00:00:00 2001 From: Daniel Simon Date: Tue, 26 Jan 2021 16:14:42 +0700 Subject: [PATCH] Add a script for generating API reference --- .gitignore | 1 + package.json | 5 +++++ scripts/collect-sdk-apis.js | 14 ++++++++++++++ yarn.lock | 25 ++++++++++++++++++++++++- 4 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 scripts/collect-sdk-apis.js diff --git a/.gitignore b/.gitignore index 620fbe15f..ed8f477f2 100644 --- a/.gitignore +++ b/.gitignore @@ -12,5 +12,6 @@ node_modules # api-extractor temp files /packages/*/temp +/temp .env .eslintcache diff --git a/package.json b/package.json index c01ff2995..ce9b1d6be 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,9 @@ "build:dev-frontend": "yarn workspace @liquity/dev-frontend build", "build:subgraph": "yarn workspace @liquity/subgraph build", "deploy": "yarn workspace @liquity/lib-ethers hardhat deploy", + "docs": "run-s docs:*", + "docs:collect-sdk-apis": "node scripts/collect-sdk-apis.js", + "docs:api-documenter": "api-documenter markdown -i temp/sdk-apis -o docs/sdk", "fuzzer": "yarn workspace @liquity/fuzzer fuzzer", "prepare": "run-s prepare:*", "prepare:contracts": "yarn workspace @liquity/contracts prepare", @@ -58,6 +61,8 @@ "coverage:contracts": "yarn workspace @liquity/contracts coverage" }, "devDependencies": { + "@microsoft/api-documenter": "^7.12.6", + "fs-extra": "^9.1.0", "npm-run-all": "^4.1.5", "prettier": "^2.1.2" } diff --git a/scripts/collect-sdk-apis.js b/scripts/collect-sdk-apis.js new file mode 100644 index 000000000..4f3621bb2 --- /dev/null +++ b/scripts/collect-sdk-apis.js @@ -0,0 +1,14 @@ +const fs = require("fs-extra"); +const path = require("path"); + +const filesToCollect = [ + "packages/lib-base/temp/lib-base.api.json", + "packages/lib-ethers/temp/lib-ethers.api.json" +]; + +const outputDir = "temp/sdk-apis"; + +fs.removeSync(outputDir); +fs.mkdirSync(outputDir, { recursive: true }); + +filesToCollect.forEach(file => fs.copyFileSync(file, path.join(outputDir, path.basename(file)))); diff --git a/yarn.lock b/yarn.lock index 53bc4660e..7641c5179 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2044,6 +2044,19 @@ resolved "https://registry.yarnpkg.com/@mdx-js/react/-/react-1.6.22.tgz#ae09b4744fddc74714ee9f9d6f17a66e77c43573" integrity sha512-TDoPum4SHdfPiGSAaRBw7ECyI8VaHpK8GJugbJIJuqyh6kzw9ZLJZW3HGL3NNrJGxcAixUvqROm+YuQOo5eXtg== +"@microsoft/api-documenter@^7.12.6": + version "7.12.6" + resolved "https://registry.yarnpkg.com/@microsoft/api-documenter/-/api-documenter-7.12.6.tgz#a7aec65d16cac9009dea38230aea77fb85089fd7" + integrity sha512-67VolY0ObxFyLqK5eVT73x1TLldZHWOyeW4R1FazGA+3LPheCU+TLW6ys7yrdtwuprw2jqtOXcvhVYVuvjkepw== + dependencies: + "@microsoft/api-extractor-model" "7.12.1" + "@microsoft/tsdoc" "0.12.24" + "@rushstack/node-core-library" "3.35.2" + "@rushstack/ts-command-line" "4.7.8" + colors "~1.2.1" + js-yaml "~3.13.1" + resolve "~1.17.0" + "@microsoft/api-extractor-model@7.12.1": version "7.12.1" resolved "https://registry.yarnpkg.com/@microsoft/api-extractor-model/-/api-extractor-model-7.12.1.tgz#1f10915c434048da34e1c07845ba2623d5f23f66" @@ -8777,6 +8790,16 @@ fs-extra@^9.0, fs-extra@^9.0.1: jsonfile "^6.0.1" universalify "^1.0.0" +fs-extra@^9.1.0: + version "9.1.0" + resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-9.1.0.tgz#5954460c764a8da2094ba3554bf839e6b9a7c86d" + integrity sha512-hcg3ZmepS30/7BSFqRvoo3DOMQu7IjqxO5nCDt+zM9XWjb33Wg7ziNT+Qvqbuc3+gWpzO02JubVyk2G4Zvo1OQ== + dependencies: + at-least-node "^1.0.0" + graceful-fs "^4.2.0" + jsonfile "^6.0.1" + universalify "^2.0.0" + fs-jetpack@^2.2.2: version "2.4.0" resolved "https://registry.yarnpkg.com/fs-jetpack/-/fs-jetpack-2.4.0.tgz#6080c4ab464a019d37a404baeb47f32af8835026" @@ -11235,7 +11258,7 @@ js-sha3@0.8.0, js-sha3@^0.8.0, js-sha3@~0.8.0: resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ== -js-yaml@3.13.1: +js-yaml@3.13.1, js-yaml@~3.13.1: version "3.13.1" resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.13.1.tgz#aff151b30bfdfa8e49e05da22e7415e9dfa37847" integrity sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==