Skip to content

Commit 15bbecd

Browse files
authored
Merge pull request #3063 from maxhaton/tryBook
Book
2 parents 7ff516b + c98fa8d commit 15bbecd

File tree

167 files changed

+58348
-2
lines changed

Some content is hidden

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

167 files changed

+58348
-2
lines changed

book/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Ali Cehreli's book
2+
3+
This is (currently) just the English version of the book.
4+
5+
To build, run `rdmd build.d`, files will be emitted to `web/book`.
6+
7+
Of note: The index currently does not work, and thus has been omitted for now.
8+
9+
```
10+
CODE_NAME=
11+
CODE_XREF=
12+
CODE_DONT_TEST=
13+
CODE_COMMENT_OUT=
14+
```

book/aliBook.ddoc

Lines changed: 218 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,218 @@
1+
ROOT_DIR=../
2+
DOCTYPE = <!DOCTYPE html>
3+
CODE_NAME=
4+
CODE_XREF=
5+
CODE_DONT_TEST=
6+
CODE_COMMENT_OUT=
7+
WORK_IN_PROCESS=
8+
COMMENTED_OUT=
9+
new=
10+
Ergin=
11+
P1= $(I $0)
12+
katma=
13+
sablon=
14+
XXX=
15+
16+
DEL = <span style="text-decoration:line-through">$0</span>
17+
TITLE = $(RED $0)
18+
H1 = <h1>$0</h1>
19+
H2 = <h2>$0</h2>
20+
H3 = <h3>$0</h3>
21+
H4 = <h4>$0</h4>
22+
H5 = <h5 class="subsection">$0</h5>
23+
H5_FRONTMATTER = <h5 class="frontmatter">$0</h5>
24+
H6 = <h6>$0</h6>
25+
SMALL=<small>$0</small>
26+
HR = <hr/>
27+
BR = <br/>
28+
SUP= <sup>$0</sup>
29+
SUB= <sub>$0</sub>
30+
CENTER = <center>$0</center>
31+
MONO = <pre class="mono">$0</pre>
32+
MONO_NOBOLD = <pre class="mono_nobold">$0</pre>
33+
CODE = <code class="d_inline">$0</code>
34+
CODE_SMALL = <code class="d_inline_index">$0</code>
35+
C=$(CODE $0)
36+
CH4=$(C $0)
37+
c=$(CODE_SMALL $0)
38+
INDEX_KEYWORDS=&nbsp;&nbsp;&nbsp;&nbsp;$(c $0)
39+
40+
LINK_TARGET=<a target="$1" href="$2">$3</a>
41+
LINK_DOWNLOAD = <a href="$1" domnload>$+</a>
42+
43+
SHELL = <pre class="shell">$0</pre>
44+
SHELL_SMALL = $(SHELL $0)
45+
SHELL_NOTE = <span class="shell_note">← $0</span>
46+
SHELL_NOTE_WRONG = <span class="shell_note_wrong">← $0</span>
47+
48+
SHELL_OBSERVED= <span class="shell_observed">$0</span>
49+
50+
C_CODE = <pre class="c_code">$0</pre>
51+
UL_FARK=<ul class="fark">$0</ul>
52+
UL_CLASS=<ul class="$1">$+</ul>
53+
FARK_INDEX=<li>$(LINK2 #$1, $2)</li>
54+
FARK=$(BR)$(HR)<h5 class="fark"><a name="$1">$2</a></h5>
55+
FARK_C=$(H6 C)$(C_CODE $0)
56+
FARK_CPP=$(H6 C++)$(C_CODE $0)
57+
FARK_D=$(H6 D)$0
58+
59+
HEADER_INDEX=$(FARK_INDEX $1, $2)
60+
HEADER=<h5><a name="$1">$2</a></h5>
61+
62+
STEPS = <ol class="steps">$0</ol>
63+
64+
QUOTE = <div class="quote">$0</div>
65+
66+
RED = <span style="color:red">$0</span>
67+
BLUE = <span style="color:blue">$0</span>
68+
GREEN = <span style="color:green">$0</span>
69+
YELLOW = <span style="color:yellow">$0</span>
70+
BLACK = <span style="color:black">$0</span>
71+
WHITE = <span style="color:white">$0</span>
72+
DARKRED= <span style="color:darkred">$0</span>
73+
ORANGE= <span style="color:orange">$0</span>
74+
GRAY= <span style="color:gray">$0</span>
75+
LIGHT_GRAY= <span style="color:#c0c0c0">$0</span>
76+
DARK_GRAY= <span style="color:#404040">$0</span>
77+
HILITE= <span class="hilite">$0</span>
78+
COLOR= <span style="color:$1">$+</span>
79+
80+
STRING = $(CODE <span class="d_string">$0</span>)
81+
COMMENT = <span class="d_comment">$0</span>
82+
KEYWORD = <span class="d_keyword">$0</span>
83+
84+
D_COMMENT = <span class="d_comment">$0</span>
85+
D_STRING = <span class="d_string">$0</span>
86+
D_KEYWORD = <span class="d_keyword">$0</span>
87+
D_PSYMBOL = <span class="d_psymbol">$0</span>
88+
D_PARAM = <span class="d_param">$0</span>
89+
90+
UNORDERED_FALSE = <span class="unordered_false">$0</span>
91+
UNORDERED_TRUE = <span class="unordered_true">$0</span>
92+
UNORDERED_NO = <span class="unordered_no">$0</span>
93+
UNORDERED_YES = <span class="unordered_yes">$0</span>
94+
95+
GULEN = $(DARKRED $(B :)o&#41;)
96+
PERCENT = &#37;
97+
PARANTEZ_AC = &#40;
98+
PARANTEZ_KAPA = &#41;
99+
VIRGUL = &#44;
100+
DOLAR = &#36;
101+
BACK_TICK = &#96;
102+
HYPHEN = &#8209;
103+
ASIL = <span style="color:#666666">($0)</span>
104+
105+
DERLEME_HATASI_METIN=derleme HATASI
106+
DERLEME_HATASI = <span class="d_comment">// ← <span class="d_hata">$(DERLEME_HATASI_METIN)</span></span>
107+
CODE_NOTE = $(COMMENT // ← $0)
108+
CODE_NOTE_WRONG = $(COMMENT // ← <span class="code_note_wrong">$0</span>)
109+
CODE_COMMENT = $(COMMENT // $0)
110+
111+
IMG_D = <img class="d_harfi" src="$(ROOT_DIR)/image/d_harfi.jpg" width="180" height="180" alt="D harfi"/>
112+
113+
BREADCRUMBS=$(BREADCRUMBS_FULL)
114+
115+
BREADCRUMBS_DIV=<div id="$(BREADCRUMBS_ID)">&nbsp;$(BREADCRUMBS)</div>
116+
117+
FOOTER_DIV=<div id="footer">$(SMALL Original design by $(LINK2 http://www.zilladesigns.net, Jeremy D.))</div>
118+
119+
HEADER_SECONDARY_DIV=<div id="headersecondary">$(HORIZNAV_CONTENT)</div>
120+
121+
VERTINAV_DIV=<div id="vertinav">
122+
$(BR)
123+
$(VERTINAV_CONTENT)
124+
$(BR)
125+
</div>
126+
127+
CLASS=chapter
128+
DIV_CLASS=<div class="$1">$+</div>
129+
130+
HEADER1_ID=header1
131+
132+
DERSHANE_LINK2=$(LINK2 $1, $2)
133+
134+
IMG=<img src="$(ROOT_DIR)/image/$0" border="0" />
135+
136+
DERS_BOLUMU =
137+
DERS_BOLUMU_CLASS =
138+
COZUM_BOLUMU = $(H4 $0 Dersi Problem Çözümleri)
139+
140+
UYARI=<center>
141+
<font size="4"> <strong> UYARI:&nbsp;&nbsp;</strong>$0</font></center>
142+
143+
TABLE=<table class="$1" border="1" cellpadding="4" cellspacing="0">$+</table>
144+
HEAD=<th scope="col">$0</th>
145+
HEAD2=$(ROW $(HEAD $1) $(HEAD $2))
146+
HEAD3=$(ROW $(HEAD $1) $(HEAD $2) $(HEAD $3))
147+
HEAD4=$(ROW $(HEAD $1) $(HEAD $2) $(HEAD $3) $(HEAD $4))
148+
HEAD5=$(ROW $(HEAD $1) $(HEAD $2) $(HEAD $3) $(HEAD $4) $(HEAD $5))
149+
HEAD6=$(ROW $(HEAD $1) $(HEAD $2) $(HEAD $3) $(HEAD $4) $(HEAD $5) $(HEAD $6))
150+
ROW2=$(ROW $(DATA $1) $(DATA $2))
151+
ROW3=$(ROW $(DATA $1) $(DATA $2) $(DATA $3))
152+
ROW4=$(ROW $(DATA $1) $(DATA $2) $(DATA $3) $(DATA $4))
153+
ROW5=$(ROW $(DATA $1) $(DATA $2) $(DATA $3) $(DATA $4) $(DATA $5))
154+
ROW6=$(ROW $(DATA $1) $(DATA $2) $(DATA $3) $(DATA $4) $(DATA $5) $(DATA $6))
155+
ROW=<tr align="center">$0</tr>
156+
DATA=<td>$0</td>
157+
158+
ESKI_KARSILASTIRMA=$(P $(CENTER $(HILITE $(I $(B Not:) Bu bir D1 karşılaştırmasıdır. Modern D'nin başka farklılıkları da var.))))
159+
160+
161+
MAIN_TITLE=D.ershane
162+
163+
SUB_MAIN_TITLE=$(SUB_MAIN_TITLE_DERSE_OZEL)
164+
165+
HEADER_ID=header_ders
166+
167+
BREADCRUMBS_ID=breadcrumbs_ders
168+
169+
CONTAINER_ID=container
170+
171+
PROBLEM= $(LI $0)
172+
173+
IX=<a id="ix_$(TITLE).$0" content="$0"></a>
174+
175+
GERI_METIN=Geri
176+
ILERI_METIN=İleri
177+
PROBLEM_METIN=Problem
178+
PROBLEM_COK_METIN=Problemler
179+
PROBLEM_TEK_COZUMSUZ_METIN=çözümü sonra gelecek
180+
PROBLEM_COK_COZUMSUZ_METIN=çözümler sonra gelecek
181+
COZUM_METIN=çözüm
182+
COZUMLER_METIN=çözümler
183+
184+
PROBLEM_TEK_IMPL=$(H5 $(PROBLEM_METIN))
185+
$+ $1
186+
187+
PROBLEM_TEK=$(PROBLEM_TEK_IMPL $(DIV_CLASS cozum_link_tek, $(P $(LINK_TARGET ddili_cozum, $(COZUM_HTML), $(I ... $(COZUM_METIN))))), $0)
188+
PROBLEM_TEK_COZUMSUZ=$(PROBLEM_TEK_IMPL $(P $(I ($(PROBLEM_TEK_COZUMSUZ_METIN ...)))), $0)
189+
190+
191+
PROBLEM_COK_IMPL=$(H5 $(PROBLEM_COK_METIN))
192+
$(OL $+) $1
193+
194+
PROBLEM_COK=$(PROBLEM_COK_IMPL $(DIV_CLASS cozum_link_cok, $(P $(LINK_TARGET ddili_cozum, $(COZUM_HTML), $(I ... $(COZUMLER_METIN))))), $0)
195+
196+
PROBLEM_COK_COZUMSUZ=$(PROBLEM_COK_IMPL $(P $(I ($(PROBLEM_COK_COZUMSUZ_METIN ...)))), $0)
197+
198+
199+
VERTINAV_CONTENT=$(MINI_SOZLUK $(SOZLER))
200+
$(DUSEY_NAVIGASYON)
201+
202+
HORIZNAV_CONTENT=$(HORIZNAV_CONTENT_DERSE_OZEL)
203+
204+
DERS_NAV_BAS=<div id="ders_nav_bas">
205+
$(DERS_NAV_GERI)&nbsp;&nbsp;&nbsp;$(DERS_NAV_ILERI)
206+
</div>
207+
208+
DERS_NAV_SON=<div id="ders_nav_son">
209+
$(DERS_NAV_GERI)&nbsp;&nbsp;&nbsp;$(DERS_NAV_ILERI)
210+
</div>
211+
212+
MINI_SOZLUK=<div class="mini_sozluk">$0</div>
213+
<span class="butun_sozluk">$(I $(LINK_TARGET ddili_sozluk, $(ROOT_DIR)/sozluk.html, ...&nbsp;bütün&nbsp;sözlük))</span>
214+
$(BR)$(BR)
215+
216+
DERSHANE_LINK2=<span style="margin:0 0 0 12px">$2</span>
217+
218+
D_CODE = <pre class="d_code">$0</pre>

book/build.d

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
module book.build;
2+
import std.string;
3+
import std.process;
4+
import std.algorithm;
5+
import std.file;
6+
import std.stdio;
7+
import std.exception;
8+
import std.path;
9+
void compileToPath(string compileThis, string outputPath, bool loud = false)
10+
{
11+
import std.compiler;
12+
import core.stdc.stdlib;
13+
string[string] contextMacros;
14+
contextMacros["DVER"] = format!"%u.%03u"(version_major, version_minor);
15+
if(outputPath.indexOf("cozum") == -1)
16+
{
17+
//We need to build a little .ddoc file to set the right predefined build macros - these are context dependant.
18+
19+
const cozumHtml = outputPath.baseName.replace(".html", ".cozum.html");
20+
contextMacros["COZUM_HTML"] = cozumHtml;
21+
//exit(0);
22+
}
23+
auto macroOut = File("contextMacros.ddoc", "w");
24+
25+
foreach(key, value; contextMacros)
26+
{
27+
macroOut.writefln!"%s = %s"(key, value);
28+
}
29+
macroOut.flush();
30+
const compileString = format!"dmd -revert=markdown -D contextMacros.ddoc macros.ddoc html.ddoc dlang.org.ddoc doc.ddoc aliBook.ddoc %s -Df%s "(compileThis, outputPath);
31+
if(loud)
32+
writefln!"%s:%s |> %s"(compileThis, outputPath, compileString);
33+
const res = executeShell(compileString);
34+
35+
if(res.status != 0) {
36+
write(res.output);
37+
38+
exit(0);
39+
}
40+
}
41+
int main(string[] args)
42+
{
43+
import std.typecons;
44+
import std.path;
45+
import std.parallelism;
46+
import std.conv : to;
47+
const jobs = args.length == 2 ? args[1].to!ubyte : 1;
48+
const outDir = "../web/book";
49+
writeln("Building the book at ", outDir);
50+
51+
enforce(executeShell("which dmd").output != "", "dmd doesn't seem to be present");
52+
if(outDir.exists) {
53+
executeShell("rm -rf " ~ outDir);
54+
}
55+
dirEntries("d.en", "*.d", SpanMode.shallow)
56+
.map!(dFile => tuple(dFile.name, buildPath(outDir, baseName(dFile).setExtension("html"))))
57+
//.parallel(jobs)
58+
.each!(elem => compileToPath(elem.tupleof));
59+
dirEntries("d.en", "*.png", SpanMode.shallow)
60+
.each!(p => copy(p, buildPath(outDir, baseName(p).setExtension("png"))));
61+
return 0;
62+
}

0 commit comments

Comments
 (0)