Skip to content

Commit d5b39ca

Browse files
committed
Docs use static markdown translation.
Building the documentation now does compile time translation from markdown to HTML, rather than dynamic translation of hidden content via script after loading the page. That takes a dependency on npm, and it uses the latest marked instead of one contained in this repo. I'd rather not have either of those dependencies, but I can accept them in order to improve the outputed documentation.
1 parent bd7e3fe commit d5b39ca

File tree

4 files changed

+38
-29
lines changed

4 files changed

+38
-29
lines changed

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,18 @@ Clink can be extended through its Lua API which allows easy creation context sen
4242

4343
### Building Clink
4444

45-
Clink's uses [Premake](http://premake.github.io) to generate Visual Studio solutions or makefiles for MinGW. Note that Premake >= 5.0-alpha12 is required.
45+
Clink uses [Premake](http://premake.github.io) to generate Visual Studio solutions or makefiles for MinGW. Note that Premake >= 5.0-alpha12 is required.
4646

4747
1. Cd to your clone of Clink.
4848
2. Run `premake5.exe <toolchain>` (where `<toolchain>` is one of Premake's actions - see `premake5.exe --help`)
4949
3. Build scripts will be generated in `.build\<toolchain>`. For example `.build\vs2013\clink.sln`.
5050
4. Call your toolchain of choice (VS, mingw32-make.exe, msbuild.exe, etc). GNU makefiles (Premake's *gmake* target) have a **help** target for more info.
5151

52+
### Building Documentation
53+
54+
1. Run `npm install marked` to install the [marked](https://marked.js.org) markdown library.
55+
2. Run `premake5.exe docs`.
56+
5257
### License
5358

5459
Clink is distributed under the terms of the GNU General Public License v3.0.

TODO.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ Lua support changed significantly. Explore how to support backward compatibilit
4646
- What to do about completion colors in popup list?
4747
- Make it owner draw and add text like "dir", "doskey", etc?
4848
- Add stat chars when so configured?
49+
- Use `npm` to run `marked.min.js` at compile time to produce static documentation rather than dynamic scripted documentation with embedded copies of marked.min.js and highlight.js.
4950

5051
## Questions
5152
- What is `set-mark`?

docs/clink.html

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,10 @@
99
$(INCLUDE docs/atom-one-light.css)
1010
</style>
1111
<script type="text/javascript">
12-
$(INCLUDE docs/marked.min.js)
1312
$(INCLUDE docs/highlight.pack.js)
1413

1514
function go()
1615
{
17-
// Convert markdown to HTML.
18-
var content = document.getElementById("content");
19-
var mds = document.getElementsByTagName("md");
20-
for (var i = 0; i < mds.length; ++i)
21-
{
22-
var md = mds[i];
23-
var div = document.getElementById(md.getAttribute("fill_id"));
24-
div.innerHTML = marked(md.innerText);
25-
}
26-
2716
// Generate a table of contents from h* tags.
2817
var toc = document.getElementById("toc");
2918
toc.innerHTML = "";
@@ -70,23 +59,19 @@
7059
</div>
7160
<div id="toc"></div>
7261
<div id="content">
73-
<div class="section" id="documentation"></div>
62+
<div class="section" id="documentation">
63+
$(MARKDOWN docs/clink.md)
64+
</div>
7465
<h1 id="lua-api">Lua API Reference</h1>
7566
<div class="section" id="api">
7667
$(INCLUDE .build/docs/api_html)
7768
</div>
78-
<div class="section" id="changes"></div>
79-
<div class="section" id="credits"></div>
80-
<!-- All md tags must come last, otherwise they interfere with each other -->
81-
<md fill_id="credits" style="display: none;">
82-
$(INCLUDE docs/credits.md)
83-
</md>
84-
<md fill_id="documentation" style="display: none;">
85-
$(INCLUDE docs/clink.md)
86-
</md>
87-
<md fill_id="changes" style="display: none;">
88-
$(INCLUDE CHANGES)
89-
</md>
69+
<div class="section" id="changes">
70+
$(MARKDOWN CHANGES)
71+
</div>
72+
<div class="section" id="credits">
73+
$(MARKDOWN docs/credits.md)
74+
</div>
9075
</div>
9176
</body>
9277

docs/premake5.lua

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
11
-- Copyright (c) 2012 Martin Ridgers
22
-- License: http://opensource.org/licenses/MIT
33

4+
--------------------------------------------------------------------------------
5+
local function markdown_file(source_path, out)
6+
print(" << " .. source_path)
7+
8+
local out_file = '.build\\docs\\'..source_path:match('([^/\\]+)$')..'.html'
9+
os.execute('marked -o '..out_file..' < '..source_path)
10+
11+
local line_reader = io.lines(out_file)
12+
for line in line_reader do
13+
out:write(line .. "\n")
14+
end
15+
end
16+
417
--------------------------------------------------------------------------------
518
local function generate_file(source_path, out)
619
print(" << " .. source_path)
@@ -9,10 +22,15 @@ local function generate_file(source_path, out)
922
if include then
1023
generate_file(include, out)
1124
else
12-
line = line:gsub("%$%(CLINK_VERSION%)", clink_git_name:upper())
13-
line = line:gsub("<(/?kbd)>", "&lt;%1&gt;")
14-
line = line:gsub("<br>", "&lt;br&gt;")
15-
out:write(line .. "\n")
25+
local md = line:match("%$%(MARKDOWN +([^)]+)%)")
26+
if md then
27+
markdown_file(md, out)
28+
else
29+
line = line:gsub("%$%(CLINK_VERSION%)", clink_git_name:upper())
30+
line = line:gsub("<(/?kbd)>", "&lt;%1&gt;")
31+
line = line:gsub("<br>", "&lt;br&gt;")
32+
out:write(line .. "\n")
33+
end
1634
end
1735
end
1836
end

0 commit comments

Comments
 (0)