From abb463e334f73ca7682bbb2ccb544d0ced9f2020 Mon Sep 17 00:00:00 2001 From: Kirigaya <1193466151@qq.com> Date: Sat, 16 Nov 2024 23:28:14 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E6=96=87=E6=A1=A3=E5=8C=96?= =?UTF-8?q?=E7=9A=84=E5=AE=9A=E4=B9=89=E8=B7=B3=E8=BD=AC=E5=92=8C=E4=BE=9D?= =?UTF-8?q?=E8=B5=96=E4=B8=8A=E7=9A=84lib=E6=A0=87=E8=AE=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- css/documentation.css | 5 ++--- src/function/hdlDoc/html.ts | 31 ++++++++++++++++++++++++++++++- src/function/hdlDoc/markdown.ts | 26 +++++++++++++++++++------- src/manager/PL/xilinx.ts | 6 +++--- 4 files changed, 54 insertions(+), 14 deletions(-) diff --git a/css/documentation.css b/css/documentation.css index c4cf9e5..b1b5c2d 100644 --- a/css/documentation.css +++ b/css/documentation.css @@ -125,7 +125,6 @@ input { } a { - color: #4078c0; text-decoration: none; } @@ -498,11 +497,11 @@ img { .vscode-dark #write table thead th { - background-color: rgb(76,55,114); + background-color: rgb(76, 55, 114); } .vscode-light #write table thead th { - background-color: rgb(236,226,254); + background-color: rgb(236, 226, 254); } .vscode-dark table tr:nth-child(even) { diff --git a/src/function/hdlDoc/html.ts b/src/function/hdlDoc/html.ts index 99c7b5e..662f4c6 100644 --- a/src/function/hdlDoc/html.ts +++ b/src/function/hdlDoc/html.ts @@ -29,6 +29,22 @@ function makeFinalHTML(body: string, style: string): string { + @@ -157,7 +173,20 @@ async function showDocWebview() { webview.iconPath = hdlIcon.getIconConfig('documentation'); webview.webview.html = await htmlPromise; - + webview.webview.onDidReceiveMessage(message => { + switch (message.command) { + case 'openFile': + let filePath: string = message.filePath; + if (filePath.startsWith('file://')) { + filePath = filePath.slice(7); + } + console.log('debug, ', filePath); + + const uri = vscode.Uri.file(filePath); + vscode.commands.executeCommand('vscode.open', uri); + return; + } + }); } diff --git a/src/function/hdlDoc/markdown.ts b/src/function/hdlDoc/markdown.ts index 3da237e..a770f8d 100644 --- a/src/function/hdlDoc/markdown.ts +++ b/src/function/hdlDoc/markdown.ts @@ -31,8 +31,23 @@ function selectFieldValue(obj: any, subName: string, ws: string, name: string): return '——'; } let value = obj[subName]; + + // 对于 source ,支持跳转 if (subName === 'instModPath' && value) { - value = value.replace(ws, ''); + const relativePath = value.replace(ws, ''); + if (fs.existsSync(value)) { + // 判断 类型 + const hdlFile = hdlParam.getHdlFile(value); + if (hdlFile && hdlFile.type === 'remote_lib') { + // 如果是 库 文件,做出更加自定义的字面量 + const libRelPath = value.replace(`${opeParam.extensionPath}/library/`, ''); + value = `[library] [${libRelPath}](file://${value})`; + } else { + value = `[project] [${relativePath}](file://${value})`; + } + } else { + value = relativePath; + } } if (value && value.trim().length === 0) { @@ -56,7 +71,7 @@ function makeTableFromObjArray(md: MarkdownString, array: any[], name: string, f const rows = []; for (const obj of array) { const data = []; - for (const subName of fieldNames) { + for (const subName of fieldNames) { const value = selectFieldValue(obj, subName, ws, name); data.push(value); } @@ -157,21 +172,18 @@ async function getDocsFromModule(module: HdlModule): Promise { makeTableFromObjArray(md, module.ports, 'ports', ['name', 'type', 'width', 'desc'], ['Port Name', 'Direction', 'Range', 'Description']); - md.addEnter(); + md.addEnter(); - // dependency section md.addTitle('Dependency', 2); const insts = []; for (const inst of module.getAllInstances()) { insts.push(inst); } - console.log('文档化 debug'); - console.log(insts); makeTableFromObjArray(md, insts, 'Dependencies', ['name', 'type', 'instModPath'], - ['name', 'module', 'path']); + ['name', 'module', 'source']); md.addEnter(); return md; diff --git a/src/manager/PL/xilinx.ts b/src/manager/PL/xilinx.ts index cbc8315..bafd5f3 100644 --- a/src/manager/PL/xilinx.ts +++ b/src/manager/PL/xilinx.ts @@ -186,7 +186,7 @@ class XilinxOperation { const onVivadoClose = debounce(() => { _this.onVivadoClose(); - }, 200); + }, 100); function launchScript(): Promise { // 执行 cmd 启动 @@ -599,7 +599,7 @@ file delete ${scriptPath} -force\n`; public addFiles(files: string[], context: PLContext) { const { t } = vscode.l10n; - if (!this.guiLaunched) { + if (!this.guiLaunched && files.length > 0) { const filesString = files.join("\n"); HardwareOutput.report(t('info.pl.add-files.title') + '\n' + filesString); this.processFileInPrj(files, context, "add_file"); @@ -609,7 +609,7 @@ file delete ${scriptPath} -force\n`; public delFiles(files: string[], context: PLContext) { const { t } = vscode.l10n; - if (!this.guiLaunched) { + if (!this.guiLaunched && files.length > 0) { const filesString = files.join("\n"); HardwareOutput.report(t('info.pl.del-files.title') + '\n' + filesString); this.processFileInPrj(files, context, "remove_files");