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

feat(docs): adding API docs for winglibs #981

Merged
merged 2 commits into from
Sep 2, 2024
Merged
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
12 changes: 11 additions & 1 deletion scripts/winglibDocs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import fs from "node:fs/promises";
import tar from "tar";
import { glob } from "glob";
import { join, dirname } from 'node:path';
import { readFileSync } from 'fs';
import { readFileSync, existsSync } from 'fs';

const authorization = `token ${process.env.GITHUB_TOKEN}`;

Expand Down Expand Up @@ -143,6 +143,15 @@ keywords: [winglib, Wing library]
for (const { winglib, readme, packageJson, title } of winglibs) {

const content = await fs.readFile(readme, { encoding: 'utf-8' });

// This is auto generated files for winglibs, if its there add it in
const apiFile = join(dirname(readme), 'API.md');
let apiFileContent = '';

if(existsSync(apiFile)) {
apiFileContent = await fs.readFile(apiFile, { encoding: 'utf-8' });
}

// remove any markdown images from the content (for now)
const contentWithoutImages = content.replace(/!\[.*\]\(.*\)/g, '');
console.log(join(WINGLIB_DIR, `${winglib}.md`))
Expand All @@ -155,6 +164,7 @@ description: ${packageJson.wing?.docs?.summary || packageJson.description}
keywords: [winglib, Wing library]
---
${contentWithoutImages}
${apiFileContent}
`

await fs.writeFile(join(WINGLIB_DIR, `${winglib}.md`), file);
Expand Down