From 1b91990cb35a1489c144da6b0b7b75cfd5062c30 Mon Sep 17 00:00:00 2001 From: Kirigaya <1193466151@qq.com> Date: Fri, 10 Jan 2025 15:17:35 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=AF=BC=E5=87=BA=20pdf=20?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- l10n/bundle.l10n.de.json | 6 +++++- l10n/bundle.l10n.en.json | 6 +++++- l10n/bundle.l10n.ja.json | 6 +++++- l10n/bundle.l10n.zh-cn.json | 6 +++++- l10n/bundle.l10n.zh-tw.json | 6 +++++- project/property-schema.json | 3 ++- src/function/dide-doc/index.ts | 5 +++++ src/function/dide-doc/pdf.ts | 25 +++++++++++++++++++------ src/function/dide-netlist/api.ts | 2 +- 10 files changed, 53 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 160ecdc..4f231f0 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ ## Digital IDE | All in one vscode plugin for Verilog/VHDL development -[Document (New)](https://sterben.nitcloud.cn/) | [中文文档 (New)](https://sterben.nitcloud.cn/zh/) | [Bilibili Video](https://www.bilibili.com/video/BV1t14y1179V/?spm_id_from=333.999.0.0) +[Document (New)](https://nc-ai.cn/en/) | [中文文档 (New)](https://nc-ai.cn/) | [Bilibili Video](https://www.bilibili.com/video/BV1t14y1179V/?spm_id_from=333.999.0.0) ![](https://img.shields.io/badge/version-0.4.0-purple) ![](https://img.shields.io/badge/Verilog-support-green) diff --git a/l10n/bundle.l10n.de.json b/l10n/bundle.l10n.de.json index 0973b84..26310e9 100644 --- a/l10n/bundle.l10n.de.json +++ b/l10n/bundle.l10n.de.json @@ -120,5 +120,9 @@ "info.progress.launch-lsp": "Starten Sie den Digital LSP-Sprachserver", "info.choose.digital-lsp-targz": "Wählen Sie das Digital LSP-Archiv aus", "info.digital-lsp.targz": "Digitales LSP-Paket", - "error.digital-lsp.incorrect-filename": "Die von Ihnen bereitgestellte Digital-LSP-Archivdatei {0} entspricht nicht der aktuellen Systemarchitektur. Bitte laden Sie die Archivdatei mit dem Namen {1} herunter!" + "error.digital-lsp.incorrect-filename": "Die von Ihnen bereitgestellte Digital-LSP-Archivdatei {0} entspricht nicht der aktuellen Systemarchitektur. Bitte laden Sie die Archivdatei mit dem Namen {1} herunter!", + "error.not-valid-browser": "{0} ist kein gültiger Browser-Pfad!", + "info.config-browser-path": "Browser-Pfad konfigurieren", + "info.pdf.exporting": "PDF wird nach {0} exportiert", + "info.generate-pdf-to": "PDF wurde unter {0} generiert" } \ No newline at end of file diff --git a/l10n/bundle.l10n.en.json b/l10n/bundle.l10n.en.json index 4fe28b0..5764fc0 100644 --- a/l10n/bundle.l10n.en.json +++ b/l10n/bundle.l10n.en.json @@ -120,5 +120,9 @@ "info.progress.launch-lsp": "Start the Digital LSP language server", "info.choose.digital-lsp-targz": "Select the Digital LSP archive", "info.digital-lsp.targz": "Digital LSP Package", - "error.digital-lsp.incorrect-filename": "The digital LSP archive file {0} you provided does not match the current system architecture. Please download the archive file named {1}!" + "error.digital-lsp.incorrect-filename": "The digital LSP archive file {0} you provided does not match the current system architecture. Please download the archive file named {1}!", + "error.not-valid-browser": "{0} is not a valid browser path!", + "info.config-browser-path": "Configure browser path", + "info.pdf.exporting": "Exporting PDF to {0}", + "info.generate-pdf-to": "PDF has been generated to {0}" } \ No newline at end of file diff --git a/l10n/bundle.l10n.ja.json b/l10n/bundle.l10n.ja.json index 70ff430..76192ad 100644 --- a/l10n/bundle.l10n.ja.json +++ b/l10n/bundle.l10n.ja.json @@ -120,5 +120,9 @@ "info.progress.launch-lsp": "Digital LSP 言語サーバーを起動する", "info.choose.digital-lsp-targz": "Digital LSPのアーカイブを選択してください", "info.digital-lsp.targz": "デジタルLSPパッケージ", - "error.digital-lsp.incorrect-filename": "提供されたデジタルLSPアーカイブファイル{0}は、現在のシステムアーキテクチャに適合していません。{1}という名前のアーカイブファイルをダウンロードしてください!" + "error.digital-lsp.incorrect-filename": "提供されたデジタルLSPアーカイブファイル{0}は、現在のシステムアーキテクチャに適合していません。{1}という名前のアーカイブファイルをダウンロードしてください!", + "error.not-valid-browser": "{0} は有効なブラウザのパスではありません!", + "info.config-browser-path": "ブラウザのパスを設定", + "info.pdf.exporting": "PDFを{0}にエクスポート中", + "info.generate-pdf-to": "PDFは{0}に生成されました" } \ No newline at end of file diff --git a/l10n/bundle.l10n.zh-cn.json b/l10n/bundle.l10n.zh-cn.json index bb3d0e0..953bc9f 100644 --- a/l10n/bundle.l10n.zh-cn.json +++ b/l10n/bundle.l10n.zh-cn.json @@ -120,5 +120,9 @@ "info.progress.launch-lsp": "启动 Digital LSP 语言服务器", "info.choose.digital-lsp-targz": "选择 Digital LSP 的压缩包", "info.digital-lsp.targz": "Digital LSP 压缩包", - "error.digital-lsp.incorrect-filename": "您提供的 digital lsp 压缩包文件 {0} 并不是一个符合当前系统架构的,请下载名为 {1} 的压缩包文件!" + "error.digital-lsp.incorrect-filename": "您提供的 digital lsp 压缩包文件 {0} 并不是一个符合当前系统架构的,请下载名为 {1} 的压缩包文件!", + "error.not-valid-browser": "{0} 并不是一个有效的浏览器路径!", + "info.config-browser-path": "配置浏览器路径", + "info.pdf.exporting": "正在导出 pdf 到 {0}", + "info.generate-pdf-to": "pdf 已经生成至 {0}" } \ No newline at end of file diff --git a/l10n/bundle.l10n.zh-tw.json b/l10n/bundle.l10n.zh-tw.json index 7c81f56..9ee0e87 100644 --- a/l10n/bundle.l10n.zh-tw.json +++ b/l10n/bundle.l10n.zh-tw.json @@ -120,5 +120,9 @@ "info.progress.launch-lsp": "啟動 Digital LSP 語言伺服器", "info.choose.digital-lsp-targz": "選擇 Digital LSP 的壓縮包", "info.digital-lsp.targz": "數位LSP壓縮包", - "error.digital-lsp.incorrect-filename": "您提供的 digital lsp 壓縮包文件 {0} 並不是一個符合當前系統架構的,請下載名為 {1} 的壓縮包文件!" + "error.digital-lsp.incorrect-filename": "您提供的 digital lsp 壓縮包文件 {0} 並不是一個符合當前系統架構的,請下載名為 {1} 的壓縮包文件!", + "error.not-valid-browser": "{0} 並不是一個有效的瀏覽器路徑!", + "info.config-browser-path": "配置瀏覽器路徑", + "info.pdf.exporting": "正在導出PDF到{0}", + "info.generate-pdf-to": "PDF 已生成至 {0}" } \ No newline at end of file diff --git a/project/property-schema.json b/project/property-schema.json index 364c338..2a329ee 100644 --- a/project/property-schema.json +++ b/project/property-schema.json @@ -198,7 +198,8 @@ "xc7a35tftg256-1", "xc7a35tcsg324-1", "xc7z035ffg676-2", - "xc7z020clg484-1" + "xc7z020clg484-1", + "hello-world" ] } }, diff --git a/src/function/dide-doc/index.ts b/src/function/dide-doc/index.ts index 459fd5f..9e281d5 100644 --- a/src/function/dide-doc/index.ts +++ b/src/function/dide-doc/index.ts @@ -43,6 +43,11 @@ function registerFileDocExport(context: vscode.ExtensionContext) { new ExportFunctionItem('html', ' html', 'only support light theme', exportCurrentFileDocAsHTML) ]; + if (uri === undefined && vscode.window.activeTextEditor) { + // TODO: 制作新的 doc UI + uri = vscode.Uri.file(vscode.window.activeTextEditor.document.fileName); + } + const item = await vscode.window.showQuickPick(items, option); if (item) { item.exportFunc(uri); diff --git a/src/function/dide-doc/pdf.ts b/src/function/dide-doc/pdf.ts index 6130b33..03abc30 100644 --- a/src/function/dide-doc/pdf.ts +++ b/src/function/dide-doc/pdf.ts @@ -5,6 +5,7 @@ import * as puppeteer from 'puppeteer-core'; import { makeShowHTML } from './html'; import { hdlFile, hdlPath } from '../../hdlFs'; import { AbsPath, MainOutput, opeParam, ReportType } from '../../global'; +import { t } from '../../i18n'; // TODO : finish it in each platform function getDefaultBrowerPath(): AbsPath { @@ -27,10 +28,18 @@ function getDefaultBrowerPath(): AbsPath { async function htmlFile2PdfFile(htmlPath: AbsPath, pdfPath: AbsPath) { const pdfConfig = vscode.workspace.getConfiguration("digital-ide.function.doc.pdf"); const platformDefaultBrowerPath = getDefaultBrowerPath(); - const browserPath = pdfConfig.get('browserPath', platformDefaultBrowerPath); + + const browserPath = pdfConfig.get('browserPath') || platformDefaultBrowerPath; if (!fs.existsSync(browserPath)) { - vscode.window.showErrorMessage("Path " + browserPath + " is not a valid browser path!"); + const res = await vscode.window.showErrorMessage( + t('error.not-valid-browser', browserPath), + { title: t('info.config-browser-path'), value: true } + ); + + if (res?.value) { + await vscode.commands.executeCommand('workbench.action.openSettings', 'digital-ide.function.doc.pdf.browserPath'); + } return; } const browser = await puppeteer.launch({ @@ -48,7 +57,7 @@ async function htmlFile2PdfFile(htmlPath: AbsPath, pdfPath: AbsPath) { scale: pdfConfig.scale, displayHeaderFooter: pdfConfig.displayHeaderFooter, headerTemplate: pdfConfig.headerTemplate, - footerTemplate: pdfConfig.footerTemplate, + footerTemplate: `
CodeDoc - Powered By Digital IDE
`, printBackground: pdfConfig.printBackground, landscape: pdfConfig.landscape, format: pdfConfig.format, @@ -74,7 +83,8 @@ async function exportCurrentFileDocAsPDF(uri: vscode.Uri) { return vscode.window.withProgress({ location: vscode.ProgressLocation.Notification, - title: '[Digital-IDE]: Export ' + currentFilePath + '...' + title: t('info.pdf.exporting', currentFilePath), + cancellable: true }, async progress => { try { const html = await makeShowHTML(uri, "pdf"); @@ -102,15 +112,18 @@ async function exportCurrentFileDocAsPDF(uri: vscode.Uri) { fs.writeFileSync(tempHtmlPath, html); await htmlFile2PdfFile(tempHtmlPath, pdfPath); - hdlFile.rmSync(tempHtmlPath); + // hdlFile.rmSync(tempHtmlPath); // 在当前编辑器中打开生成的 pdf - vscode.window.showInformationMessage('pdf generated at ' + pdfPath); + if (fs.existsSync(pdfPath)) { + vscode.window.showInformationMessage(t('info.generate-pdf-to', pdfFolderPath)); + } } catch (error) { MainOutput.report("error happen in export pdf: " + error, { level: ReportType.Error }); + return; } }); } diff --git a/src/function/dide-netlist/api.ts b/src/function/dide-netlist/api.ts index 46ba9df..d0817d5 100644 --- a/src/function/dide-netlist/api.ts +++ b/src/function/dide-netlist/api.ts @@ -170,7 +170,7 @@ async function html2pdf(htmlPath: string, pdfPath: string, moduleName: string, w scale: 1, displayHeaderFooter: true, // headerTemplate: `
module ${moduleName}
`, - footerTemplate: `
Netlist for ${moduleName} - 由 Digital IDE 生成
`, + footerTemplate: `
Netlist for ${moduleName} - Powered By Digital IDE
`, printBackground: true, landscape: true, width: width