实现文档化的定义跳转和依赖上的lib标记
This commit is contained in:
parent
b00c1649e2
commit
abb463e334
@ -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) {
|
||||
|
@ -29,6 +29,22 @@ function makeFinalHTML(body: string, style: string): string {
|
||||
</div>
|
||||
</div>
|
||||
</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>
|
||||
@ -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;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
@ -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<MarkdownString> {
|
||||
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;
|
||||
|
@ -186,7 +186,7 @@ class XilinxOperation {
|
||||
|
||||
const onVivadoClose = debounce(() => {
|
||||
_this.onVivadoClose();
|
||||
}, 200);
|
||||
}, 100);
|
||||
|
||||
function launchScript(): Promise<ChildProcessWithoutNullStreams> {
|
||||
// 执行 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");
|
||||
|
Loading…
x
Reference in New Issue
Block a user