Skip to content

Commit

Permalink
Merge branch 'feature/mermaid-markdown' into mermaid-markdown
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhilkalburgi authored Mar 10, 2024
2 parents e29110f + 89335b5 commit cc4fef7
Show file tree
Hide file tree
Showing 6 changed files with 102 additions and 6 deletions.
34 changes: 28 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -150,5 +150,6 @@
"ejs": "^3.1.9",
"markdown-it": "^14.0.0",
"mermaid": "^10.8.0"
"@types/markdown-it": "^13.0.7",
}
}
4 changes: 4 additions & 0 deletions src/PreviewMarkdown.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as vscode from 'vscode';
import * as path from 'path';
import { isAsyncAPIFile } from './PreviewWebPanel';

import { Parser, fromFile, AsyncAPIDocumentInterface } from '@asyncapi/parser';
import Asyncapi from './Asyncapi';

Expand All @@ -10,6 +11,7 @@ const parser = new Parser();

async function buildMarkdown(document:AsyncAPIDocumentInterface | undefined, context: vscode.ExtensionContext){


let content = '';

if(document !== undefined){
Expand All @@ -18,6 +20,7 @@ async function buildMarkdown(document:AsyncAPIDocumentInterface | undefined, con
}

return content;

}

export function previewMarkdown(context: vscode.ExtensionContext) {
Expand Down Expand Up @@ -54,6 +57,7 @@ export async function openAsyncAPIMarkdown(context: vscode.ExtensionContext, uri
const { document } = await fromFile(parser, uri.fsPath).parse();
let result = await buildMarkdown(document, context);


panel.title = path.basename(uri.fsPath);
panel.webview.html = getWebviewContent(context, panel.webview, uri, result);

Expand Down
61 changes: 61 additions & 0 deletions src/components/Info.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import {AsyncAPIDocumentInterface } from '@asyncapi/parser';

export default function info(asyncapi:AsyncAPIDocumentInterface) {

const info = asyncapi.info();
const defaultContentType = asyncapi.defaultContentType();
const specId = info.id();
const termsOfService = info.termsOfService();
const license = info.license();
const contact = info.contact();
const externalDocs = info.externalDocs();
const extensions: any = info.extensions();

const infoList = [];
if (specId) {
infoList.push(`Specification ID: \`${specId}\``);
}
if (license) {
infoList.push(license.url() ? (
`License: [${license.name()}](${license.url()})`
) : `License: ${license.name()}`);
}
if (termsOfService) {
infoList.push(
`[${termsOfService}](${termsOfService})`
);
}
if (defaultContentType) {
infoList.push(
`Default content type: [${defaultContentType}](https://www.iana.org/assignments/media-types/${defaultContentType})`
);
}
if (contact) {
if (contact.url()) {
infoList.push(
`Support: [${contact.url()}](${contact.name() || 'Link'})`
);
}
if (contact.email()) {
infoList.push(
`Email support: [${`mailto:${contact.email()}`}](${contact.email()})`
);
}
}

return (
`
# ${info.title()} ${info.version()} documentation
${
infoList.map((value)=>{
return '\n* '+ value;
})
}
![${info.title()}](${(extensions.get('x-logo'))?extensions.get('x-logo').value():null})
#### ${info.description()}
`);
}
7 changes: 7 additions & 0 deletions src/components/MermaidDiagram.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import {AsyncAPIDocumentInterface } from '@asyncapi/parser';

export default function mermaidDiagram(asyncapi:AsyncAPIDocumentInterface){


return ``;
}
1 change: 1 addition & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ const extensionConfig = {
from: 'src/components',
to: 'components'
}

],
}),
],
Expand Down

0 comments on commit cc4fef7

Please sign in to comment.