-
Notifications
You must be signed in to change notification settings - Fork 66
Expand file tree
/
Copy pathtest_keepports_diagram.ts
More file actions
54 lines (44 loc) · 1.96 KB
/
test_keepports_diagram.ts
File metadata and controls
54 lines (44 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import { documenter_factory } from "../src/colibri/documenter/factory";
import { HDL_LANG } from "../src/colibri/common/general";
import { Diagram } from "../src/colibri/documenter/diagram";
import * as fs from "fs";
import * as path from "path";
async function test_keepports_diagram() {
const test_file = path.join(__dirname, "test_keepports_diagram.vhdl");
const vhdl_code = fs.readFileSync(test_file, "utf8");
console.log("Testing @keepports diagram functionality...");
// Create documenter
const documenter = documenter_factory(HDL_LANG.VHDL);
// Parse the VHDL code
const result = await documenter.get_documentation(vhdl_code, {
language: HDL_LANG.VHDL,
path: test_file,
configuration: {
enable_markdown: true,
enable_comments: true
}
});
console.log("Parsed entities:", result.length);
if (result.length > 0) {
const entity = result[0];
console.log("Entity name:", entity.name);
console.log("Number of ports:", entity.port.length);
console.log("Virtual buses:", entity.virtual_bus);
// Create diagram
const diagram = new Diagram();
const svg_content = diagram.get_entity_as_svg(entity);
// Save diagram to file for visual inspection
const output_file = path.join(__dirname, "keepports_diagram_test.svg");
fs.writeFileSync(output_file, svg_content);
console.log("Diagram saved to:", output_file);
// Check virtual bus properties
entity.virtual_bus.forEach((vbus, index) => {
console.log(`Virtual bus ${index + 1}:`);
console.log(` Name: ${vbus.name}`);
console.log(` Description: ${vbus.description}`);
console.log(` Keepports: ${vbus.keepports}`);
console.log(` Ports: ${vbus.port_list.map(p => p.name).join(", ")}`);
});
}
}
test_keepports_diagram().catch(console.error);