Repository navigation
Expand file tree
/
Copy pathmake.bat
More file actions
166 lines (137 loc) · 5.79 KB
/
Copy pathmake.bat
File metadata and controls
166 lines (137 loc) · 5.79 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
@ECHO OFF
:: Request library name
FOR %%a IN ("%cd%") DO set "lib_name=%%~nxa"
echo Used library name: %lib_name%
:: ------------------------------------------------------------------------------------
:: Create HTML documentation
:: ------------------------------------------------------------------------------------
:: Create folder for styles
MD html\styles
MD html\temp_md
:: Copy styles and images to html folder
copy src\_defs\html_style.css html\styles\html_style.css
robocopy src\md\_images html\_images /E
:: Copy all markdown files to temporary folder
FOR /R "src\md" %%x IN (*.md) DO copy "%%x" "html\temp_md"
:: Merge md files to one general documentation
TYPE html\temp_md\*.md >> src\md\TTemp.md
copy /b "src\md\TTemp.md" + "src\_defs\TableOfContents_Collapse.md" "src\md\Temp.md"
:: Generate general html help file
pandoc -s ^
--css styles\html_style.css ^
-f markdown -t html src\md\Temp.md ^
-o html\%lib_name%.html ^
--metadata title=%lib_name%
:: Delete temporary markdown files
del src\md\Temp.md
del src\md\TTemp.md
rmdir /s /q html\temp_md
:: ------------------------------------------------------------------------------------
:: Create PDF documentation
:: ------------------------------------------------------------------------------------
:: Delete old documentation and temp folder
IF EXIST pdf\%lib_name%.pdf DEL pdf\%lib_name%.pdf
IF EXIST pdf\temp rmdir /s /q pdf\temp
:: Create temporary folder and subfolders
MD pdf\temp
MD pdf\temp\md
MD pdf\temp\html
MD pdf\temp\html\styles
:: Copy images and stylesheet file
robocopy src\md\_images pdf\temp\html\_images
copy src\_defs\pdf_style.css pdf\temp\html\styles\pdf_style.css
:: Copy all markdown files (except 00_Table_of_Contents.md and 01_Startpage.md) to temporary folder
FOR /R "src\md" %%i IN (*.md) DO ( ^
IF "%%~ni" neq "00_Table_Of_Contents" ( ^
IF "%%~ni" neq "01_Startpage" ( ^
copy "%%i" "pdf\temp\md" ^
) ^
) ^
)
:: Generate start page and table of contents
copy /b "src\md\01_Startpage.md" + "src\md\00_Table_Of_Contents.md" "pdf\temp\Tmp_Merge1.md"
pandoc -s ^
--css styles\pdf_style.css ^
-f markdown -t html pdf\temp\Tmp_Merge1.md ^
-o pdf\temp\html\Temp1.html ^
--metadata title=%lib_name%
:: Merge md files to one temporary documentation
TYPE pdf\temp\md\*.md >> pdf\temp\Tmp_Merge2.md
copy /b "pdf\temp\Tmp_Merge2.md" + "src\_defs\EmptyTableLines.md" "pdf\temp\TTmp_Merge2.md"
:: Generate temporary html help file
pandoc -s ^
--css styles\pdf_style.css ^
--number-sections ^
--toc-depth=2 ^
-f markdown -t html pdf\temp\TTmp_Merge2.md ^
-o pdf\temp\html\Temp2.html ^
--metadata title="%lib_name%"
copy /b "pdf\temp\html\Temp1.html" + "pdf\temp\html\Temp2.html" "pdf\temp\html\TTmp_Merge.html"
wkhtmltopdf ^
--header-html "file:///%CD%/src/_defs/header.html?lib_name=%lib_name%" ^
--enable-javascript ^
--javascript-delay 500 ^
--margin-top 30 ^
--header-spacing 10 ^
--margin-left 15 ^
--margin-bottom 20 ^
--disable-smart-shrinking ^
--enable-local-file-access ^
--disable-internal-links ^
pdf\temp\html\TTmp_Merge.html ^
pdf\%lib_name%.pdf
:: --header-left %lib_name% ^
:: --header-right [page]/[toPage] ^
:: --header-line ^
:: --footer-line ^
:: --footer-spacing 10 ^
:: --header-spacing 10 ^
:: ------------------------------------------------------------------------------------
:: Create FB related HTML files
:: ------------------------------------------------------------------------------------
setlocal enabledelayedexpansion
:: Source folder
set sourceFolder="src\md\Components"
:: Target folder
set targetFolder="html\Components"
IF not exist "%targetFolder%" mkdir "%targetFolder%"
:: Create files with HTML and JavaScript content
FOR /R "src\md\Components" %%f IN (*.md) DO ( ^
IF EXIST html\Components\%%~nf.html DEL html\Components\%%~nf.html
set htmlFile="html\Components\%%~nf.html"
echo ^<^^!DOCTYPE html^> >> "!htmlFile!"
echo ^<html lang="en"^> >> "!htmlFile!"
echo ^<head^> >> "!htmlFile!"
echo ^<meta charset="UTF-8"^> >> "!htmlFile!"
echo ^<title^>Automatic Redirect^</title^> >> "!htmlFile!"
echo ^<script^> >> "!htmlFile!"
echo // *** Change POU name here: >> "!htmlFile!"
for /f "tokens=2* delims=_" %%a in ("%%~nf") do set "pou_name=%%a_%%b"
echo const pou_name = "!pou_name!"; >> "!htmlFile!"
echo let dots = ""; >> "!htmlFile!"
echo let dotElement; >> "!htmlFile!"
echo window.onload = function^(^) ^{ >> "!htmlFile!"
echo dotElement = document.getElementById^("dots"^); >> "!htmlFile!"
echo let i = 0; >> "!htmlFile!"
echo let dotInterval = setInterval^(function^(^) ^{ >> "!htmlFile!"
echo if ^(i ^< 3^) ^{ >> "!htmlFile!"
echo dots += "."; >> "!htmlFile!"
echo dotElement.textContent = dots; >> "!htmlFile!"
echo i++; >> "!htmlFile!"
echo ^} else ^{ >> "!htmlFile!"
echo clearInterval^(dotInterval^); >> "!htmlFile!"
echo ^} >> "!htmlFile!"
echo ^}, 300^); >> "!htmlFile!"
echo ^}; >> "!htmlFile!"
echo setTimeout^(function^(^) ^{ >> "!htmlFile!"
echo window.location.href = ^`./Overview.htm#$^{pou_name^}^`; >> "!htmlFile!"
echo ^}, 1000^); >> "!htmlFile!"
echo ^</script^> >> "!htmlFile!"
echo ^</head^> >> "!htmlFile!"
echo ^<body^> >> "!htmlFile!"
echo ^<h1^>You will be redirected^<span id="dots"^>^</span^>^</h1^> >> "!htmlFile!"
echo ^<p^>If the redirect does not work, please click ^<a href="./Overview.htm" onclick="location.href=this.href+'#'+pou_name;return false;"^>here^</a^>.^</p^> >> "!htmlFile!"
echo ^</body^> >> "!htmlFile!"
echo ^</html^> >> "!htmlFile!"
)
endlocal