From d12bd90c666f40de953a856807025cc856955c7c Mon Sep 17 00:00:00 2001 From: gossi Date: Sun, 15 May 2022 19:41:55 +0200 Subject: [PATCH] prep api docs --- package.json | 5 +- packages/theemo/.gitignore | 3 +- packages/theemo/api-extractor.json | 4 +- packages/theemo/etc/theemo.api.md | 74 ++++++++++++++++++++++++ packages/theemo/package.json | 8 ++- scripts/{make-docs.cjs => make-docs.mjs} | 47 +++++++++------ 6 files changed, 115 insertions(+), 26 deletions(-) create mode 100644 packages/theemo/etc/theemo.api.md rename scripts/{make-docs.cjs => make-docs.mjs} (64%) diff --git a/package.json b/package.json index 2c4895b6..56fd721d 100644 --- a/package.json +++ b/package.json @@ -2,10 +2,11 @@ "name": "root", "private": true, "volta": { - "node": "16.15.0" + "node": "18.1.0" }, "scripts": { "test": "pnpm run --filter theemo test", - "coverage": "pnpm run --filter theemo coverage" + "coverage": "pnpm run --filter theemo coverage", + "api": "pnpm run --filter theemo api" } } diff --git a/packages/theemo/.gitignore b/packages/theemo/.gitignore index 53c37a16..7b20272f 100644 --- a/packages/theemo/.gitignore +++ b/packages/theemo/.gitignore @@ -1 +1,2 @@ -dist \ No newline at end of file +dist +api \ No newline at end of file diff --git a/packages/theemo/api-extractor.json b/packages/theemo/api-extractor.json index da342218..5fe737ad 100644 --- a/packages/theemo/api-extractor.json +++ b/packages/theemo/api-extractor.json @@ -2,7 +2,7 @@ "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", "mainEntryPointFilePath": "/dist/index.d.ts", "apiReport": { - "enabled": false, + "enabled": true, "reportFolder": "/etc/" }, "docModel": { @@ -10,6 +10,6 @@ "apiJsonFilePath": "/dist/.api.json" }, "dtsRollup": { - "enabled": false + "enabled": true } } diff --git a/packages/theemo/etc/theemo.api.md b/packages/theemo/etc/theemo.api.md new file mode 100644 index 00000000..4ed33fc3 --- /dev/null +++ b/packages/theemo/etc/theemo.api.md @@ -0,0 +1,74 @@ +## API Report File for "theemo" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts + +import { BaseToken } from './token.js'; +import { default as Figma } from './tools/figma/index.js'; +import { FigmaReaderConfig } from './tools/figma/config.js'; +import { FigmaReferencerConfig } from './tools/figma/config.js'; +import { FigmaReferencerPluginConfig } from './tools/figma/config.js'; +import { FigmaReferencerType } from './tools/figma/config.js'; +import { FigmaTheemoPluginConfig } from './tools/figma/referencers/theemo-plugin.js'; +import { default as GenerateConfig } from './generate/config.js'; +import { default as LexerConfig } from './sync/lexer/config.js'; +import { default as ReaderConfig } from './sync/reader/config.js'; +import { ReaderTool } from './tools/tool.js'; +import { default as StyleDictionary } from './tools/style-dictionary/index.js'; +import { StyleDictionaryConfig } from './tools/style-dictionary/config.js'; +import { StyleDictionaryWriterConfig } from './tools/style-dictionary/config.js'; +import { default as SyncConfig } from './sync/config.js'; +import Theemo from './theemo.js'; +import type TheemoConfig from './config.js'; +import { default as Token } from './token.js'; +import { TokenTier } from './token.js'; +import { Tools } from './tools/tool.js'; +import { default as WriterConfig } from './sync/writer/config.js'; +import { WriterTool } from './tools/tool.js'; + +export { BaseToken } + +export { Figma } + +export { FigmaReaderConfig } + +export { FigmaReferencerConfig } + +export { FigmaReferencerPluginConfig } + +export { FigmaReferencerType } + +export { FigmaTheemoPluginConfig } + +export { GenerateConfig } + +export { LexerConfig } + +export { ReaderConfig } + +export { ReaderTool } + +export { StyleDictionary } + +export { StyleDictionaryConfig } + +export { StyleDictionaryWriterConfig } + +export { SyncConfig } + +export default Theemo; + +export { TheemoConfig } + +export { Token } + +export { TokenTier } + +export { Tools } + +export { WriterConfig } + +export { WriterTool } + +``` diff --git a/packages/theemo/package.json b/packages/theemo/package.json index 78adee70..b3114d57 100644 --- a/packages/theemo/package.json +++ b/packages/theemo/package.json @@ -36,7 +36,10 @@ "lint:js": "eslint --ext ts,js src/ test/ --cache", "lint:js:fix": "eslint --ext ts,js src/ test/ --fix", "lint:types": "tsc --noEmit", - "api": "node scripts/make-docs.cjs", + "api:extractor": "api-extractor run --local", + "api:documenter": "api-documenter markdown -i dist -o api", + "api:doc": "pnpm api:extractor && pnpm api:documenter", + "api": "pnpm dts && pnpm api:doc", "prepublishOnly": "pnpm build", "prepack": "pnpm dts", "release": "release-it" @@ -104,6 +107,7 @@ } }, "volta": { - "extends": "../../package.json" + "extends": "../../package.json", + "node": "18.1.0" } } diff --git a/scripts/make-docs.cjs b/scripts/make-docs.mjs similarity index 64% rename from scripts/make-docs.cjs rename to scripts/make-docs.mjs index d3798ea7..c7c27dd6 100644 --- a/scripts/make-docs.cjs +++ b/scripts/make-docs.mjs @@ -1,30 +1,39 @@ -const { readdir, createReadStream, writeFile } = require('fs-extra'); +import { createReadStream, writeFile } from 'node:fs'; +import { readdir } from 'node:fs/promises'; -const { createInterface } = require('readline'); -const { join, parse } = require('path'); -const { exec } = require('child_process'); +import { createInterface } from 'node:readline/promises'; + +import { join, parse } from 'node:path'; + +import util from 'node:util'; +import { exec } from 'node:child_process'; // This script uses api-extractor and api-documenter and adds frontmatter // Taken from: // https://github.com/faastjs/faast.js/blob/master/build/make-docs.js +const execAsync = util.promisify(exec); + async function main() { - await new Promise((resolve, reject) => - exec( - 'api-extractor run --local && api-documenter markdown -i dist -o docs/api', - (err, stdout, stderr) => { - console.log(stdout); - console.error(stderr); - if (err) { - reject(err); - } else { - resolve(); - } - } - ) - ); + const { stdout, stderr } = await execAsync('api-extractor run --local && api-documenter markdown -i packages/theemo/dist -o website/docs/api'); + console.log(stdout); + console.error(stderr); + // await new Promise((resolve, reject) => + // exec( + // 'api-extractor run --local && api-documenter markdown -i dist -o website/docs/api', + // (err, stdout, stderr) => { + // console.log(stdout); + // console.error(stderr); + // if (err) { + // reject(err); + // } else { + // resolve(); + // } + // } + // ) + // ); - const dir = './docs/api'; + const dir = './website/docs/api'; const docFiles = await readdir(dir); for (const docFile of docFiles) { try {