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

docs: update usage documentation for new commands #556

Merged
merged 22 commits into from
May 29, 2023
Merged
Show file tree
Hide file tree
Changes from 17 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: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,10 @@
"build": "rimraf lib && node scripts/fetch-asyncapi-example.js && tsc && echo \"Build Completed\"",
"bump:version": "npm --no-git-tag-version --allow-same-version version $VERSION",
"dev": "tsc --watch",
"generate:assets": "npm run generate:readme:toc",
"generate:readme:create": "printf '\n\n# Usage\n\n<!-- usage -->\n\n# Commands\n\n<!-- commands -->\n' > scripts/README.md",
"generate:readme:commands": "cd scripts && oclif readme",
"generate:assets": "npm run generate:readme:toc && npm run generate:commands",
"generate:commands": "npm run generate:readme:create && npm run generate:readme:commands && node ./scripts/updateUsageDocs.js && rimraf ./scripts/README.md",
"generate:readme:toc": "markdown-toc -i README.md",
"lint": "eslint --max-warnings 0 --config .eslintrc .",
"lint:fix": "eslint --max-warnings 5 --config .eslintrc . --fix",
Expand Down
26 changes: 26 additions & 0 deletions scripts/updateUsageDocs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const { writeFile, readFile } = require('fs').promises;
mhmohona marked this conversation as resolved.
Show resolved Hide resolved

// Define the paths to the README and usage files
const README_PATH = './scripts/README.md'; // File path for the generated README file
const USAGE_PATH = './docs/usage.md';

// Create a header for the usage.md file
const header = `
---
title: 'Usage'
weight: 40
---

The AsyncAPI CLI makes it easier to work with AsyncAPI documents.
`;

// Define an async function to write the header and the README contents to the usage documentation file
async function run() {
await writeFile(USAGE_PATH, header, { encoding: 'utf8' });
const readmeContents = await readFile(README_PATH, 'utf8');

// Append the contents of the README file to the usage documentation file
await writeFile(USAGE_PATH, readmeContents, { encoding: 'utf8', flag: 'a' });
}

run();
mhmohona marked this conversation as resolved.
Show resolved Hide resolved