-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerateDoc.js
More file actions
executable file
·93 lines (79 loc) · 3.31 KB
/
generateDoc.js
File metadata and controls
executable file
·93 lines (79 loc) · 3.31 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
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
#!/usr/bin/env node
"use strict";
const fs = require("fs");
require("qcobjects");
const lang = "en";
const readme = fs.readFileSync("./README.md").toString();
const routings = [];
function writeContent (lang, index, content, level){
let routingpath = content.split("\n")[0].split("# ")[1].toLowerCase().replace(/\s/g,"-").replace(":","");
// eslint-disable-next-line no-useless-escape
routingpath = routingpath.replace("\(","").replace("\)","");
routingpath = routingpath.replace(/(á|é|í|ó|ú)/g,"");
routingpath = routingpath.replace(".","");
routingpath = encodeURI(routingpath);
const rtext = `\t<routing path="^/${routingpath}$" name="markdown/${lang}/page_${lang}_${index}"></routing>`;
routings.push(rtext);
fs.writeFileSync(`./src/templates/components/markdown/${lang}/page_${lang}_${index}.md`,`${content}`);
}
readme.split("\n# ").map ((content, index1) => writeContent(lang, `${index1}`, `# ${content}` , 1));
readme.split("\n# ").map( (content1, index1) => content1.split("\n\#\# ").map ((content, index2) => writeContent(lang, `${index1}_${index2}`, `## ${content}`,2 ) ) );
readme.split("\n# ").map( (content1, index1) => content1.split("\n\#\# ").map( (content2, index2) => content2.split( "\n\#\#\# " ).map ((content, index3) => writeContent(lang, `${index1}_${index2}_${index3}`, `### ${content}` , 3 ) ) ) );
readme.split("\n# ").map( (content1, index1) => content1.split("\n\#\# ").map( (content2, index2) => content2.split( "\n\#\#\# " ).map( (content3, index3) => content3.split("\n\#\#\#\# ").map ((content, index4) => writeContent(lang, `${index1}_${index2}_${index3}_${index4}`, `#### ${content}` , 4 ) ) ) ) );
let sectionTemplate = `
<style>
@import url('./css/github-style.css');
@import url('./css/snippet.css');
/* If you use shadowed=true
This style will be automatically shadowed in the browser */
article {
box-shadow: rgba(0, 0, 0, 0.2) 0px 1px 2px 0px, rgba(228, 228, 234, 0.5) 0px 9px 23px 0px;
transition: all 0.3s ease-in-out;
width: 100%;
margin: 0 auto;
min-height: 100%;
height: auto;
border-radius: 30px;
display: block;
padding: 3%;
background-color: #ffffff;
}
a{
/* These are technically the same, but use both */
overflow-wrap: break-word;
word-wrap: break-word;
-ms-word-break: break-all;
/* This is the dangerous one in WebKit, as it breaks things wherever */
word-break: break-all;
/* Instead use this non-standard one: */
word-break: break-word;
/* Adds a hyphen where the word breaks, if supported (No Blink) */
-ms-hyphens: auto;
-moz-hyphens: auto;
-webkit-hyphens: auto;
hyphens: auto;
}
p:not(:first-child) {
margin: 1% 5%;
font-size: medium;
display: block;
}
h1, h2 {
margin: 2% 3%;
}
ul {
margin: auto 4%;
}
</style>
</style>
<article>
<component name="blank" tplextension="md" componentClass="MarkdownComponent" controllerClass="MarkdownController">
<routing path="^/author$" name="markdown/en/AUTHOR" ></routing>
{{routings}}
<routing path="^/$" name="markdown/en/page_en_1" ></routing>
<routing path="^$" name="markdown/en/page_en_1" ></routing>
</component>
</article>
`;
sectionTemplate = sectionTemplate.replace(/{{routings}}/g, routings.join("\n"));
fs.writeFileSync("./src/templates/components/section1.tpl.html",`${sectionTemplate}`);