实现文档化的定义跳转和依赖上的lib标记
This commit is contained in:
parent
b00c1649e2
commit
abb463e334
@ -125,7 +125,6 @@ input {
|
|||||||
}
|
}
|
||||||
|
|
||||||
a {
|
a {
|
||||||
color: #4078c0;
|
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -498,11 +497,11 @@ img {
|
|||||||
|
|
||||||
|
|
||||||
.vscode-dark #write table thead th {
|
.vscode-dark #write table thead th {
|
||||||
background-color: rgb(76,55,114);
|
background-color: rgb(76, 55, 114);
|
||||||
}
|
}
|
||||||
|
|
||||||
.vscode-light #write table thead th {
|
.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) {
|
.vscode-dark table tr:nth-child(even) {
|
||||||
|
@ -29,6 +29,22 @@ function makeFinalHTML(body: string, style: string): string {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
<script>
|
||||||
|
const vscode = acquireVsCodeApi();
|
||||||
|
|
||||||
|
document.querySelectorAll('a').forEach(link => {
|
||||||
|
link.addEventListener('click', (event) => {
|
||||||
|
event.preventDefault();
|
||||||
|
const href = link.getAttribute('href');
|
||||||
|
if (href.startsWith('file://')) {
|
||||||
|
vscode.postMessage({
|
||||||
|
command: 'openFile',
|
||||||
|
filePath: href
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
<style>
|
<style>
|
||||||
${style}
|
${style}
|
||||||
</style>
|
</style>
|
||||||
@ -157,7 +173,20 @@ async function showDocWebview() {
|
|||||||
|
|
||||||
webview.iconPath = hdlIcon.getIconConfig('documentation');
|
webview.iconPath = hdlIcon.getIconConfig('documentation');
|
||||||
webview.webview.html = await htmlPromise;
|
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;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -31,8 +31,23 @@ function selectFieldValue(obj: any, subName: string, ws: string, name: string):
|
|||||||
return '——';
|
return '——';
|
||||||
}
|
}
|
||||||
let value = obj[subName];
|
let value = obj[subName];
|
||||||
|
|
||||||
|
// 对于 source ,支持跳转
|
||||||
if (subName === 'instModPath' && value) {
|
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) {
|
if (value && value.trim().length === 0) {
|
||||||
@ -159,19 +174,16 @@ async function getDocsFromModule(module: HdlModule): Promise<MarkdownString> {
|
|||||||
['Port Name', 'Direction', 'Range', 'Description']);
|
['Port Name', 'Direction', 'Range', 'Description']);
|
||||||
md.addEnter();
|
md.addEnter();
|
||||||
|
|
||||||
|
|
||||||
// dependency section
|
// dependency section
|
||||||
md.addTitle('Dependency', 2);
|
md.addTitle('Dependency', 2);
|
||||||
const insts = [];
|
const insts = [];
|
||||||
for (const inst of module.getAllInstances()) {
|
for (const inst of module.getAllInstances()) {
|
||||||
insts.push(inst);
|
insts.push(inst);
|
||||||
}
|
}
|
||||||
console.log('文档化 debug');
|
|
||||||
console.log(insts);
|
|
||||||
|
|
||||||
makeTableFromObjArray(md, insts, 'Dependencies',
|
makeTableFromObjArray(md, insts, 'Dependencies',
|
||||||
['name', 'type', 'instModPath'],
|
['name', 'type', 'instModPath'],
|
||||||
['name', 'module', 'path']);
|
['name', 'module', 'source']);
|
||||||
|
|
||||||
md.addEnter();
|
md.addEnter();
|
||||||
return md;
|
return md;
|
||||||
|
@ -186,7 +186,7 @@ class XilinxOperation {
|
|||||||
|
|
||||||
const onVivadoClose = debounce(() => {
|
const onVivadoClose = debounce(() => {
|
||||||
_this.onVivadoClose();
|
_this.onVivadoClose();
|
||||||
}, 200);
|
}, 100);
|
||||||
|
|
||||||
function launchScript(): Promise<ChildProcessWithoutNullStreams> {
|
function launchScript(): Promise<ChildProcessWithoutNullStreams> {
|
||||||
// 执行 cmd 启动
|
// 执行 cmd 启动
|
||||||
@ -599,7 +599,7 @@ file delete ${scriptPath} -force\n`;
|
|||||||
public addFiles(files: string[], context: PLContext) {
|
public addFiles(files: string[], context: PLContext) {
|
||||||
const { t } = vscode.l10n;
|
const { t } = vscode.l10n;
|
||||||
|
|
||||||
if (!this.guiLaunched) {
|
if (!this.guiLaunched && files.length > 0) {
|
||||||
const filesString = files.join("\n");
|
const filesString = files.join("\n");
|
||||||
HardwareOutput.report(t('info.pl.add-files.title') + '\n' + filesString);
|
HardwareOutput.report(t('info.pl.add-files.title') + '\n' + filesString);
|
||||||
this.processFileInPrj(files, context, "add_file");
|
this.processFileInPrj(files, context, "add_file");
|
||||||
@ -609,7 +609,7 @@ file delete ${scriptPath} -force\n`;
|
|||||||
public delFiles(files: string[], context: PLContext) {
|
public delFiles(files: string[], context: PLContext) {
|
||||||
const { t } = vscode.l10n;
|
const { t } = vscode.l10n;
|
||||||
|
|
||||||
if (!this.guiLaunched) {
|
if (!this.guiLaunched && files.length > 0) {
|
||||||
const filesString = files.join("\n");
|
const filesString = files.join("\n");
|
||||||
HardwareOutput.report(t('info.pl.del-files.title') + '\n' + filesString);
|
HardwareOutput.report(t('info.pl.del-files.title') + '\n' + filesString);
|
||||||
this.processFileInPrj(files, context, "remove_files");
|
this.processFileInPrj(files, context, "remove_files");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user