Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prep api docs #570

Merged
merged 1 commit into from
May 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
3 changes: 2 additions & 1 deletion packages/theemo/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
dist
dist
api
4 changes: 2 additions & 2 deletions packages/theemo/api-extractor.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
"mainEntryPointFilePath": "<projectFolder>/dist/index.d.ts",
"apiReport": {
"enabled": false,
"enabled": true,
"reportFolder": "<projectFolder>/etc/"
},
"docModel": {
"enabled": true,
"apiJsonFilePath": "<projectFolder>/dist/<unscopedPackageName>.api.json"
},
"dtsRollup": {
"enabled": false
"enabled": true
}
}
74 changes: 74 additions & 0 deletions packages/theemo/etc/theemo.api.md
Original file line number Diff line number Diff line change
@@ -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 }

```
8 changes: 6 additions & 2 deletions packages/theemo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -104,6 +107,7 @@
}
},
"volta": {
"extends": "../../package.json"
"extends": "../../package.json",
"node": "18.1.0"
}
}
47 changes: 28 additions & 19 deletions scripts/make-docs.cjs → scripts/make-docs.mjs
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down