Skip to content

Commit cc75523

Browse files
committed
Huge merge commit, hope there's no trouble...
2 parents c4695d9 + 705d150 commit cc75523

File tree

97 files changed

+5638
-2355
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+5638
-2355
lines changed

Book/build.py

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import os
99
import shutil
10-
import subprocess
10+
from subprocess import Popen, PIPE
1111

1212
def read_file(filepath):
1313
with open(filepath, "r") as f:
@@ -27,12 +27,12 @@ def write_string_to_file(s, filepath):
2727
f.write(s)
2828

2929
def render_lhs(lhs_filepath):
30-
return subprocess.check_output([
31-
"pandoc", lhs_filepath,
32-
"-f", "markdown+lhs",
33-
"-t", "html",
34-
"--mathjax"
35-
]).decode("utf8")
30+
cmd = ["pandoc", lhs_filepath, "-f", "markdown+lhs", "-t", "html", "--mathjax"]
31+
p = Popen(cmd, stdout=PIPE, stderr=PIPE)
32+
stdout, stderr = p.communicate()
33+
if stderr != b"":
34+
print("file: {}, stderr: {}".format(lhs_filepath, stderr))
35+
return stdout.decode("utf8")
3636

3737
def has_image_ext(filename):
3838
_, ext = os.path.splitext(filename)
@@ -58,15 +58,22 @@ def build_sections(sources):
5858
if not os.path.exists(section):
5959
os.makedirs(section)
6060
chapter_path = "../../" + chapter_source
61+
lhs_source_href = "https://github.com/DSLsofMath/BScProj2018/blob/master/{}".format(chapter_source)
62+
prefix = "Physics/src/"
63+
lhs_source_name = chapter_source[len(prefix):] if chapter_source.startswith(prefix) else chapter_source
6164
content = render_lhs(chapter_path)
6265
chapter = apply_template(
6366
chapter_templ,
6467
{
68+
"section-name": section,
69+
"chapter-name": chapter_name,
6570
"content": content,
6671
"previous-href": prev_chap_href,
6772
"previous-name": prev_chap_name,
6873
"next-href": next_chap_href,
6974
"next-name": next_chap_name,
75+
"lhs-source-href": lhs_source_href,
76+
"lhs-source-name": lhs_source_name,
7077
})
7178
out_path = "{}/{}.html".format(section, chapter_name)
7279
write_string_to_file(chapter, out_path)
@@ -89,6 +96,9 @@ def build_index(sources):
8996
write_string_to_file(index, "index.html")
9097

9198
sources = [
99+
("Introduction", [
100+
("Introduction'", "Physics/src/Introduction/Introduction.lhs"),
101+
]),
92102
("Dimensions", [
93103
("Introduction", "Physics/src/Dimensions/Intro.lhs"),
94104
("Value-level dimensions", "Physics/src/Dimensions/ValueLevel.lhs"),
@@ -104,8 +114,11 @@ def build_index(sources):
104114
("Vector", "Physics/src/Vector/Vector.lhs")
105115
]),
106116
("Calculus", [
107-
("Calculus", "Physics/src/Calculus/Calculus.lhs"),
108-
("Syntax Tree", "Physics/src/Calculus/SyntaxTree.lhs"),
117+
("Introduction", "Physics/src/Calculus/Intro.lhs"),
118+
("Function expressions", "Physics/src/Calculus/FunExpr.lhs"),
119+
("Differential calculus", "Physics/src/Calculus/DifferentialCalc.lhs"),
120+
("Integral calculus", "Physics/src/Calculus/IntegralCalc.lhs"),
121+
("Visualization, Verification, and Application", "Physics/src/Calculus/VisVerApp.lhs"),
109122
]),
110123
("Newtonian Mechanics", [
111124
("Single particle mechanics", "Physics/src/NewtonianMechanics/SingleParticle.lhs")

Book/chapter.template

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
<header>
1212
<a href="../index.html"><h1>Learn You a <span class="physics">Physics</span> for Great Good!</h1></a>
1313
<h1>&gt;&gt;&gt; WORK IN PROGRESS &lt;&lt;&lt;</h1>
14+
<h2>{section-name} / {chapter-name}</h2>
1415
<nav>
16+
<span>[src: <a href="{lhs-source-href}">{lhs-source-name}</a>]</span>
1517
<span>Previous: <a href="{previous-href}">{previous-name}</a></span>
1618
<a href="../index.html">Table of contents</a>
1719
<span>Next: <a href="{next-href}">{next-name}</a></span>
@@ -24,11 +26,12 @@
2426

2527
<footer>
2628
<nav>
29+
<span>[src: <a href="{lhs-source-href}">{lhs-source-name}</a>]</span>
2730
<span>Previous: <a href="{previous-href}">{previous-name}</a></span>
2831
<a href="../index.html">Table of contents</a>
2932
<span>Next: <a href="{next-href}">{next-name}</a></span>
3033
</nav>
31-
Licensed under the GPL by the Kandidatboisen (2018)
34+
© Kandidatboisen (2018), GPL
3235
</footer>
3336
</body>
3437
</html>

Book/index.template

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@
1414
</header>
1515

1616
<main>
17-
{toc}
17+
<div id="toc">
18+
{toc}
19+
</div>
1820
</main>
1921

2022
<footer>
21-
Licensed under the GPL by the Kandidatboisen (2018)
23+
© Kandidatboisen (2018), GPL
2224
</footer>
2325
</body>
2426
</html>

0 commit comments

Comments
 (0)