Skip to content
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
56 changes: 56 additions & 0 deletions .github/bin/generate-docs/api-documenter.mjs
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is unused at this time, but I am hoping to use it to resolve : #1201

Actually running it generates hundreds of markdown files with API docs.
So I want to save that for a future PR.

Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { spawn } from 'child_process';
import { platform } from 'process';
import path from 'path';
import fs from 'fs';

import { listWorkspaces } from "../list-workspaces/list-workspaces.mjs";

const workspaces = await listWorkspaces();

for (const workspace of workspaces) {
await runApiDocumenter(workspace);
}

async function runApiDocumenter(workspace) {
await new Promise((resolve, reject) => {
if (workspace.private) {
resolve(true);

return;
}

const docsExist = fs.existsSync(path.join(workspace.path, 'docs', workspace.unscopedName + '.api.json'));
if (!docsExist) {
resolve(true);

return;
}

const publishCmd = spawn(
'npm',
[
'exec',
'--',
'api-documenter',
'markdown',
'--input-folder',
path.join(workspace.path, 'docs'),
'--output-folder',
path.join(workspace.path, 'api-reference'),
],
{
stdio: 'inherit',
shell: platform === 'win32'
}
);

publishCmd.on('close', (code) => {
if (0 !== code) {
reject(new Error(`'npm publish' exited with code ${code} for ${packageName}`));
return;
}

resolve(true);
});
});
}
1 change: 1 addition & 0 deletions .github/bin/list-workspaces/list-workspaces.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export async function listWorkspaces() {
result.push({
path: packagePath,
name: packageJSON.name,
unscopedName: packageJSON.name.replace(/^@[^/]+\//, ''),
private: packageJSON.private,
dependencies: [
...Object.keys(Object(packageJSON.dependencies)),
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ reports
!e2e/package-lock.json
!sites/package-lock.json
.cached-commit
_types
Loading