-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmaker.ts
105 lines (91 loc) · 2.08 KB
/
maker.ts
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
// 生成 algorithms/*/index.ts
export class MarkTS {
// 注释
// code snippet
}
// 生成 algorithms/*/index.jest.ts
export class MarkTest {
private template: string;
constructor() {
const template: string = `
import * as asserts from "https://deno.land/std@0.125.0/testing/asserts.ts";
import * as log from "https://deno.land/std@0.125.0/log/mod.ts"
import { } from "./index.ts";
log.info("")
Deno.test({
name: \`
\`,
fn(): void {
},
});
`;
this.template = template;
}
}
// 生成 algorithms/*/index.js
export class MarkJS {
//
constructor(data: any) {}
// write async
write(path: string) {
//
}
}
// 生成 algorithms/*/README.md
export class MarkMD {
private readonly roma: string = "I,II,III,IV,V,VI,VII,VIII,IX,X,XI,XII";
//
}
// 生成 ~/README.md
export class MarkRootMD {
private readonly fileName: string = "README.md";
constructor(data: any) {
// 8304 -> ⁰, 8313 -> ⁹
// 8320 -> ⁰, 8329 -> ₉
String.fromCharCode(8304); // 上标
String.fromCharCode(8329); // 下标
}
/**
* load files
*/
public load = ({ filePath }: any): void => {
let file = readFileStrSync(filePath, { encoding: "utf8" });
// this.md = file.split('\n## Submissions')[0];
};
/**
* json to markdown syntax strings
*/
public print = (submissions: any[]): void => {
let str: string = "## Submissions\n\n";
// title
submissions.forEach((s: any, k: number) => {
const { name, info } = s;
str += `### ${name}\n\n`;
str += `\t${info}\n\n`;
const { time, status, runtime, memory } = s;
str +=
`|Time|Status|Runtime|Memory|\\n|:--:|:----:|:-----:|:----:|\\n|${time}|${status}|${runtime}|${memory}|\\n`;
const { code } = s;
str += `\`\`\`typescript\\n${code}\\n\\n\`\`\``;
});
// code
};
}
// 生成 ~/TOPICS.md
export class MarkTopics {
constructor(data: any) {
//
}
}
/**
* @author yalda
* @date 2019.08
*/
export default {
MarkTS,
MarkTest,
MarkJS,
MarkMD,
MarkRootMD,
MarkTopics,
};