Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit 012fc85

Browse files
livecodealilivecodeali
authored andcommitted
[[ User Guide ]] Use already generated distributed guide json to build user guide pdf"
1 parent 9d1d62f commit 012fc85

File tree

2 files changed

+29
-63
lines changed

2 files changed

+29
-63
lines changed

builder/user-guide-template.html

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -659,12 +659,10 @@
659659
</head>
660660
<body>
661661
<div id="content"/>
662+
<script charset="UTF-8" src="@GUIDE_JSON@"></script>
662663
<script>
663-
var prefix = '@prefix@';
664-
var ide_markdown = '@ide-guides@';
665-
var repo_markdown = '@repo-guides@';
666-
667664
function regenerate() {
665+
var prefix = '@PREFIX@';
668666
// Override the markdown parser's heading generation in order to
669667
// generate table of contents.
670668
var renderer = new marked.Renderer();
@@ -765,13 +763,14 @@
765763
{
766764
return '<code class="inline">' + code + '</code>';
767765
}
768-
769-
var content_html = marked(prefix, { renderer: renderer });
770-
guide_source = 'ide';
771-
content_html += marked(ide_markdown, { renderer: renderer });
772-
guide_source = 'repo';
773-
content_html += marked(repo_markdown, { renderer: renderer });
774766

767+
var content_html = marked(prefix, { renderer: renderer });
768+
769+
$.each(tUserGuideData.guides, function( index, value ) {
770+
guide_source = value.location;
771+
content_html += marked(value.data, { renderer: renderer });
772+
});
773+
775774
document.getElementById('content').innerHTML = content_html;
776775

777776
var toc = document.getElementById('table_of_contents');

builder/user_guide_builder.livecodescript

Lines changed: 20 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@ command guideBuilderRun pEdition, pVersion, pReleaseType, pOutputDir
3030
Initialize pVersion, pOutputDir
3131

3232
BaseCreate
33-
34-
AddIDEGuides
35-
AddRepoGuides
3633

3734
OutputGuide
3835

@@ -61,23 +58,11 @@ private function OutputGetGuideTitle
6158
end OutputGetGuideTitle
6259

6360
private command OutputGuide
64-
OutputGuideMarkdown
61+
OutputGuideJson
6562
OutputGuideHtml
6663
OutputGuidePdf
6764
end OutputGuide
6865

69-
private command OutputGuideMarkdown
70-
local tPath
71-
put OutputGetGuideFilename("md") into tPath
72-
builderLog "report", merge("Writing [[tPath]]")
73-
74-
local tMarkdown
75-
put sMarkdownText["guide"] into tMarkdown
76-
put return & sMarkdownText["ide-guides"] after tMarkdown
77-
put return & sMarkdownText["repo-guides"] after tMarkdown
78-
FileSetUTF8Contents tPath, tMarkdown
79-
end OutputGuideMarkdown
80-
8166
private function OutputEscape pMarkdown, pEscapeHtml
8267
-- Try to do the minimum possible escaping to be able to insert the
8368
-- markdown into a JavaScript string
@@ -92,16 +77,32 @@ private function OutputEscape pMarkdown, pEscapeHtml
9277
return pMarkdown
9378
end OutputEscape
9479

80+
private command OutputGuideJson
81+
local tGuideJsonPath
82+
put builderGuideFolder() & slash & "distributed_guide.js" into tGuideJsonPath
83+
84+
local tGuideJson
85+
put FileGetUTF8Contents(tGuideJsonPath) into tGuideJson
86+
87+
local tJS
88+
put "var tUserGuideData =" & return & "{" & return & tab & quote & "guides" & quote & ":[" into tJS
89+
put tGuideJson after tJS
90+
put return & tab & "]" & return & "}" after tJS
91+
92+
local tGuideJSPath
93+
put OutputGetGuideFilename("js") into tGuideJSPath
94+
FileSetUTF8Contents tGuideJSPath, tJS
95+
end OutputGuideJson
96+
9597
private command OutputGuideHtml
9698
local tHtmlTemplatePath
9799
put builderSystemFolder() & "/user-guide-template.html" into tHtmlTemplatePath
98100

99101
local tHtml
100102
put FileGetUTF8Contents(tHtmlTemplatePath) into tHtml
101103

102-
replace "@prefix@" with OutputEscape(sMarkdownText["guide"], false) in tHtml
103-
replace "@ide-guides@" with OutputEscape(sMarkdownText["ide-guides"], true) in tHtml
104-
replace "@repo-guides@" with OutputEscape(sMarkdownText["repo-guides"], true) in tHtml
104+
replace "@PREFIX@" with OutputEscape(sMarkdownText["guide"], false) in tHtml
105+
replace "@GUIDE_JSON@" with OutputGetGuideFilename("js") in tHtml
105106

106107
local tOutpath
107108
put OutputGetGuideFilename("html") into tOutpath
@@ -164,40 +165,6 @@ private command BaseCreate
164165

165166
end BaseCreate
166167

167-
----------------------------------------------------------------
168-
-- Guide Contents
169-
----------------------------------------------------------------
170-
171-
private command AddGuide pWhich, pFolder, pFilename
172-
local tGuidePath
173-
put pFolder & slash & pFilename into tGuidePath
174-
175-
local tGuideContents
176-
put FileGetUTF8Contents(tGuidePath) into tGuideContents
177-
178-
MarkdownAppend pWhich, tGuideContents
179-
end AddGuide
180-
181-
private command AddGuides pWhich
182-
local tFolder
183-
put FileGetPath(pWhich) into tFolder
184-
185-
local tGuides
186-
put FolderListFiles(tFolder, "md") into tGuides
187-
188-
repeat for each line tGuide in tGuides
189-
AddGuide pWhich, tFolder, tGuide
190-
end repeat
191-
end AddGuides
192-
193-
private command AddRepoGuides
194-
AddGuides "repo-guides"
195-
end AddRepoGuides
196-
197-
private command AddIDEGuides
198-
AddGuides "ide-guides"
199-
end AddIDEGuides
200-
201168
----------------------------------------------------------------
202169
-- File helpers
203170
----------------------------------------------------------------

0 commit comments

Comments
 (0)