Added hello world example
:100644 100644 75e3598... 01d8a4c... M css/site.css
:100644 100644 ffb8a92... 08939b4... M wml/Makefile
:100644 100644 261f5ed... 07db43f... M wml/doc/examples.wml
:000000 100644 0000000... c59b79f... A wml/doc/examples/basic/hello.wml
:000000 100644 0000000... 2452a72... A wml/doc/syntax.inc
diff --git a/css/site.css b/css/site.css
index 75e3598..01d8a4c 100644
--- a/css/site.css
+++ b/css/site.css
@@ -13,11 +13,17 @@ ul, li, div, table, tr, td {
pre {
display: inline;
font-family: courier;
- padding: 0;
- margin: 0;
+ padding: 0 0 0 0;
+ margin: 0 0 0 0;
color: darkred;
}
+code {
+ display: block;
+ font-family: courier;
+ margin: 0.5em 0 0.5em 1em;
+}
+
table {
width: 100%;
}
diff --git a/wml/Makefile b/wml/Makefile
index ffb8a92..08939b4 100644
--- a/wml/Makefile
+++ b/wml/Makefile
@@ -1,20 +1,26 @@
TOPDIR=..
LATEST=0.1.7
INCS=$(wildcard *.inc)
-CC=wml $(patsubst %,-i%,$(INCS))
-SRCS=$(wildcard *.wml) $(wildcard doc/*.wml)
+CC=wml -DLATEST=$(LATEST) $(patsubst %,-i%,$(INCS))
+DOCINCS=$(wildcard doc/*.inc)
+CCDOC=$(CC) $(patsubst %,-i%,$(DOCINCS))
+SRCS=$(wildcard *.wml) $(wildcard doc/*.wml) $(wildcard doc/examples/basic/*.wml)
+OBJDIRS=$(TOPDIR)/doc $(TOPDIR)/doc/examples/basic
OBJS=$(patsubst %,$(TOPDIR)/%,$(SRCS:.wml=.html))
ARCHIVEDIR=$(subst .,_,$(LATEST))
ARCHIVESRCS=$(patsubst %,$(ARCHIVEDIR)/%,install.wml features.wml release-notes.wml)
ARCHIVEOBJS=$(patsubst %,$(TOPDIR)/%,$(ARCHIVESRCS:.wml=.html))
-all: $(TOPDIR)/doc $(OBJS) $(ARCHIVESRCS) $(TOPDIR)/$(ARCHIVEDIR) $(ARCHIVEOBJS)
+all: $(OBJDIRS) $(OBJS) $(ARCHIVESRCS) $(TOPDIR)/$(ARCHIVEDIR) $(ARCHIVEOBJS)
# Directories creation
$(TOPDIR)/doc:
mkdir -p $(TOPDIR)/doc
+$(TOPDIR)/doc/examples/basic:
+ mkdir -p $(TOPDIR)/doc/examples/basic
+
$(ARCHIVEDIR):
mkdir -p $(ARCHIVEDIR)
@@ -28,17 +34,16 @@ $(ARCHIVEDIR)/%.wml: $(ARCHIVEDIR)
# HTML generation
-$(TOPDIR)/%.html: %.wml $(INCS)
- $(CC) -DLATEST=$(LATEST) -o $@ $<
-
-$(TOPDIR)/doc/%.html: doc/%.wml $(INCS)
- $(CC) -DLATEST=$(LATEST) -o $@ $<
+$(TOPDIR)/doc/%.html: doc/%.wml $(INCS) $(DOCINCS)
+ $(CCDOC) -o $@ $<
-$(TOPDIR)/$(ARCHIVEDIR)/%.html: $(ARCHIVEDIR)/%.wml
- $(CC) -DLATEST=$(LATEST) -o $@ $<
+$(TOPDIR)/%.html: %.wml $(INCS)
+ $(CC) -o $@ $<
clean:
rm -f $(OBJS)
+ rmdir $(TOPDIR)/doc/examples/basic
+ rmdir $(TOPDIR)/doc/examples
rmdir $(TOPDIR)/doc
rm -f $(ARCHIVEOBJS)
rmdir $(TOPDIR)/$(ARCHIVEDIR)
diff --git a/wml/doc/examples.wml b/wml/doc/examples.wml
index 261f5ed..07db43f 100644
--- a/wml/doc/examples.wml
+++ b/wml/doc/examples.wml
@@ -8,7 +8,7 @@
<h3>Basic</h3>
<p>
- Say Hello world! in Smalltalk YX
+ Say <a href="$(ROOT)/doc/examples/basic/hello.html">Hello world!</a> in Smalltalk YX
</p>
<h3>Console</h3>
diff --git a/wml/doc/examples/basic/hello.wml b/wml/doc/examples/basic/hello.wml
new file mode 100644
index 0000000..c59b79f
--- /dev/null
+++ b/wml/doc/examples/basic/hello.wml
@@ -0,0 +1,66 @@
+{#TITLE#:Hello world!:##}
+
+<items>
+ <item "Introduction">
+ <p>
+ Smalltalk YX is an interpreted programming language based on the Smalltalk-80 standard. "Interpreted programming language" means the code is not compiled in machine code instead each command is interpreted at run-time.
+ </p>
+
+ <p>
+ The interpreter frontend of Smalltalk YX is called syx. On Linux it's an ELF file, on Windows it's an executable file with the EXE extension, and so on other platforms.
+ All you need is a Syx version <a href="$(ROOT)/install.html">working on your computer</a>.
+ </p>
+ </item>
+
+ <item "Launch Syx">
+ <p>
+ To launch Syx on Linux just type syx as follows:
+ <pre>
+ $ syx
+ </pre>
+ </p>
+
+ <p>
+ On Windows, if you used the installer, you'll find the executable in Start->Programs->Smalltalk YX menu.
+ You'll see this once Syx has been launched:
+ <pre>
+ >
+ </pre>
+ </p>
+ <p>
+ This means Syx is ready and it's waiting for your input.
+ </p>
+ </item>
+
+ <item "Say Hello World">
+ <p>
+ Let's say something for the first time with Syx, type the following in the syx interpreter:
+ <code><span style="color: #7f0000;">'Hello world'</span>!</code>
+ Well, you can see now <out Hello world> in output.
+ </p>
+ <h3>Explanation</h3>
+ <p>
+ Strings in Smalltalk are represented using single quotes. The exclamation mark at the end says to Syx to end the current block of statements.
+ </p>
+ <p>
+ Anyway, what you did was only creating a string, not printing it. It has been printed out because Syx automatically prints the latest evaluated object, which in this case was our input string <s Hello world>.
+ </p>
+ <p>
+ To really print our string type the following command:
+ <code><span style="color: #7f0000;">'Hello world'</span> printNl!</code>
+ </p>
+ <p>
+ You'll see <out Hello world> printed two times. This because we print the <s Hello world> string and finally Syx prints the latest evaluated object, which is <s Hello world> as explained above.
+ </p>
+ </item>
+
+ <item "Standard Hello world">
+ <p>
+ The _printNl method used above is a method introduced by Syx to print objects out the easy way. By default on other Smalltalk, this is done by using the _Transcript object, which represent an output buffer shown to the user. We are working on a console, in fact our _Transcript is just the stdout stream. Try it:
+ <code>
+ <span style="color: #0000ff;">Transcript</span> showCr: <span style="color: #7f0000;">'Hello world'</span>!
+ </code>
+ You'll see <out Hello world> and a _TextCollector printed below. What's that? Well, each object in Syx has a class. Here, the _Transcript is an object created by the _TextCollector class. Since here the latest evaluated object is the _Transcript, Syx will print out the class to which the object belongs to.
+ </p>
+ </item>
+</items>
diff --git a/wml/doc/syntax.inc b/wml/doc/syntax.inc
new file mode 100644
index 0000000..2452a72
--- /dev/null
+++ b/wml/doc/syntax.inc
@@ -0,0 +1,16 @@
+# Classes
+m4_define(_Transcript, <em>Transcript</em>)
+m4_define(_TextCollector, <em>TextCollector</em>)
+
+# Methods
+m4_define(_printNl, <em>printNl</em>)
+
+# Output
+<define-tag out>
+ <b>%attributes</b>
+</define-tag>
+
+# String
+<define-tag s>
+ <b>'%attributes'</b>
+</define-tag>
\ No newline at end of file