diff options
-rw-r--r-- | doc/introduction/Makefile | 163 | ||||
-rw-r--r-- | doc/introduction/ScalaIntro.tex | 51 | ||||
-rw-r--r-- | doc/introduction/ScalaIntro.xsl | 166 |
3 files changed, 380 insertions, 0 deletions
diff --git a/doc/introduction/Makefile b/doc/introduction/Makefile new file mode 100644 index 0000000000..3bcb5d75cc --- /dev/null +++ b/doc/introduction/Makefile @@ -0,0 +1,163 @@ +############################################################-*-Makefile-*-#### +# Scala Introduction +############################################################################## +# $Id$ + +############################################################################## +# Configuration + +ROOT = ../.. + +include $(ROOT)/Makefile.import + +############################################################################## +# Variables + +WEBSITE_PROJECT_ROOT ?= $(ROOT)/../scala-website +WEBSITE_SOURCEDIR ?= $(WEBSITE_PROJECT_ROOT)/sources + +# project +PROJECT_SOURCES += default.dtd +PROJECT_SOURCES += $(XML_SOURCES) + +PROJECT_XSLFILE = ScalaIntro.xsl +PROJECT_BUILDDATE = $(shell date "+%B %d, %Y") + +#XML_SOURCES += index.xml +#XML_SOURCES += $(shell cd $(WEBSITE_SOURCEDIR); ls intro/*.xml) + +# We preserve section order of PDF document generated by Acrobat +XML_FILES += index +XML_FILES += intro/unifiedtypes +XML_FILES += intro/classes +XML_FILES += intro/traits +XML_FILES += intro/subclassing +XML_FILES += intro/mixin +XML_FILES += intro/funsyntax +XML_FILES += intro/hofuns +XML_FILES += intro/funnesting +XML_FILES += intro/currying +XML_FILES += intro/caseclasses +XML_FILES += intro/patmatch +XML_FILES += intro/xml +XML_FILES += intro/regexppat +XML_FILES += intro/comprehensions +XML_FILES += intro/generics +XML_FILES += intro/variances +XML_FILES += intro/upbounds +XML_FILES += intro/lowbounds +XML_FILES += intro/innerclasses +XML_FILES += intro/abstracttypes +XML_FILES += intro/compoundtypes +XML_FILES += intro/selfrefs +XML_FILES += intro/views +XML_FILES += intro/polymethods +XML_FILES += intro/inference +XML_FILES += intro/operators +XML_FILES += intro/targettyping +XML_FILES += intro/coercions +XML_SOURCES += $(XML_FILES:%=%.xml) + +PNG_FILES += images/classhierarchy +PNG_FILES += images/colpoint2d +PNG_FILES += images/colpoint3d +PNG_FILES += images/scala_logo +PNG_SOURCES += $(PNG_FILES:%=%.png) + +# latex +LATEX_FORMATS += dvi +LATEX_FORMATS += ps +LATEX_FORMATS += pdf + +LATEX_TARGETS += $(LATEX_FORMATS:%=ScalaIntro.%) + +LATEX_SOURCES += MainPart.tex +LATEX_SOURCES += ScalaIntro.tex + +# latex +TEXINPUTS := $(PROJECT_SUPPORTDIR)/latex:$(TEXINPUTS): + +############################################################################## +# Includes + +include $(PROJECT_SUPPORTDIR)/make/latex.mk + +AWK ?= awk +CYGWIN ?= $(filter CYGWIN%,$(shell uname)) + +############################################################################## +# XSLT processor + +XSLTPROC ?= xsltproc +XSLTPROC_FLAGS += + +############################################################################## +# convert + +CONVERT ?= convert +CONVERT_FLAGS += -sharpen 0.1 -flatten -trim + +############################################################################## +# PDF viewer + +ACROREAD_WIN32 ?= c:/Progra~1/Adobe/Acrobat\ 7.0/Reader/AcroRd32.exe +ACROREAD_UNIX ?= acroread + +PDF_VIEWER ?= $(if $(CYGWIN),$(ACROREAD_WIN32),$(ACROREAD_UNIX)) + +############################################################################## +# PS viewer + +GSVIEW_WIN32 ?= gsview32 +GSVIEW_UNIX ?= gv + +PS_VIEWER ?= $(if $(CYGWIN),$(GSVIEW_WIN32),$(GSVIEW_UNIX)) + +############################################################################## +# Commands + +clean: + @$(RM) -r images intro MainPart.tex default.dtd index.xml ScalaIntro.out + +view: viewpdf + +viewpdf: ScalaIntro.pdf + $(PDF_VIEWER) $< & + +viewps: ScalaIntro.ps + $(PS_VIEWER) $< & + +.PHONY: clean +.PHONY: view +.PHONY: viewpdf +.PHONY: viewps + +############################################################################## +# Rules + +images : + @[ -d $@ ] || $(MKDIR) -p $@ + for file in $(PNG_SOURCES); do \ + $(CONVERT) $(CONVERT_FLAGS) \ + PNG:$(WEBSITE_SOURCEDIR)/$$file EPS:images/`$(BASENAME) $$file .png`.eps; \ + $(CONVERT) $(CONVERT_FLAGS) \ + PNG:$(WEBSITE_SOURCEDIR)/$$file PDF:images/`$(BASENAME) $$file .png`.pdf; \ + done + +intro : + @[ -d $@ ] || $(MKDIR) -p $@ + @for file in $(PROJECT_SOURCES); do \ + $(AWK) '/<src/{on=1};/<\/src>/{on=0};{if(on){gsub("{","\\{");gsub("}","\\}")};print $0}' \ + $(WEBSITE_SOURCEDIR)/$$file > $$file; \ + done + +MainPart.tex : images intro $(PROJECT_XSLFILE) + $(ECHO) "%% Generated file: $@" > $@ + $(ECHO) "%% Build date : $(PROJECT_BUILDDATE)" >> $@ + $(XSLTPROC) $(XSLTPROC_FLAGS) $(PROJECT_XSLFILE) $(XML_SOURCES) | \ + $(SED) -e 's/% 2/\\% 2/g' | \ + $(SED) -e 's/<%/<\\%/g' | \ + $(SED) -e 's/#Node/\\#Node/g' | \ + $(SED) -e 's/{_/{\\_/g' >> $@ + +############################################################################## diff --git a/doc/introduction/ScalaIntro.tex b/doc/introduction/ScalaIntro.tex new file mode 100644 index 0000000000..059634f215 --- /dev/null +++ b/doc/introduction/ScalaIntro.tex @@ -0,0 +1,51 @@ +% $Id$ + +\documentclass[a4paper,12pt,twoside,titlepage]{book} + +\usepackage{alltt}% Verbatim extended with the ability to use normal commands +\usepackage{scaladoc} +\usepackage{url} +\usepackage{xspace} + +\newcommand{\docversion}{1.1} +\renewcommand{\doctitle}{An Introduction \\ to Scala} +\renewcommand{\docsubtitle}{Version \docversion} +\renewcommand{\docauthor}{Martin Odersky \\ +Philippe Altherr \\ +Vincent Cremet \\ +Burak Emir \\ +St\'ephane Micheloud \\ +Nikolay Mihaylov \\ +Michel Schinz \\ +Erik Stenman \\ +Matthias Zenger \\[25mm]\ } + +\newcommand{\langname}[1]{#1\xspace} +\newcommand{\CSharp}{\langname{C\#}} +\newcommand{\DotNet}{\langname{.NET}} +\newcommand{\Scala}{\langname{Scala}} + +% \lfoot{\small\copyright 2000-2005 EPFL/LAMP} +% \cfoot{} +% \rfoot{\small v\docversion} + + +\begin{document} +\frontmatter +\makedoctitle +\clearemptydoublepage +\tableofcontents +\mainmatter + +\begin{center} +\LARGE\textbf{\\ An Introduction to \Scala} +\end{center} + +% disables chapter, section and subsection numbering +\setcounter{secnumdepth}{-1} + +\section{The \Scala Programming Language} + +\input{MainPart} + +\end{document} diff --git a/doc/introduction/ScalaIntro.xsl b/doc/introduction/ScalaIntro.xsl new file mode 100644 index 0000000000..0cd68aec59 --- /dev/null +++ b/doc/introduction/ScalaIntro.xsl @@ -0,0 +1,166 @@ +<?xml version="1.0" encoding="utf-8"?> +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + version="1.0"> + <xsl:output method="text" encoding="iso-8859-1" indent="no" /> + + <!-- ##################### Match Rules ####################### --> + + <xsl:template match="/"><xsl:apply-templates /></xsl:template> + + + <!-- ELEMENT source --> + + <xsl:template match="source"> +<xsl:apply-templates /> +\newpage + </xsl:template> + + + <!-- ELEMENT header --> + + <xsl:template match="header"> +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% Author: <xsl:value-of select="author" /> +%% Keywords: <xsl:value-of select="keywords" /> + </xsl:template> + + + <!-- ELEMENT content --> + + <xsl:template match="content"> +<xsl:apply-templates /> + </xsl:template> + + + <!-- ELEMENT csharp, dotnet, scala --> + + <xsl:template match="csharp">\CSharp</xsl:template> + <xsl:template match="dotnet">\DotNet</xsl:template> + <xsl:template match="scala">\Scala</xsl:template> + + + <!-- ELEMENT title, h, h3 --> + + <xsl:template match="title"> + <xsl:variable name="_subtitle"><xsl:apply-templates /></xsl:variable> + <xsl:variable name="subtitle"><xsl:value-of select="substring-after($_subtitle, ': ')" /></xsl:variable> +\section{<xsl:value-of select="$subtitle" />} + </xsl:template> + <xsl:template match="h">\subsection*{<xsl:apply-templates />}</xsl:template> + <xsl:template match="h3">\subsubsection*{<xsl:apply-templates />}</xsl:template> + + <!-- ELEMENT a, code, em, i, p, tt --> + + <xsl:template match="a"> + <xsl:choose> + <xsl:when test="starts-with(@href, 'http://')"> +\href{<xsl:value-of select="@href" />}{<xsl:apply-templates />} + </xsl:when> +<!-- + <xsl:when test="starts-with(@href, 'intro/')"> +\hypertarget{<xsl:value-of select="translate(substring-before(@href, '.html'), '/', ':')" />}{<xsl:apply-templates />} + </xsl:when> + <xsl:when test="not(@name)"> +<xsl:apply-templates /> [\nolinkurl{<xsl:value-of select="@href" />}] + </xsl:when> +--> + <xsl:otherwise> + <xsl:apply-templates /> + </xsl:otherwise> + </xsl:choose> + </xsl:template> + <xsl:template match="code">\texttt{<xsl:apply-templates />}</xsl:template> + <xsl:template match="em">\emph{<xsl:apply-templates />}</xsl:template> + <xsl:template match="i">\emph{<xsl:apply-templates />}</xsl:template> + <xsl:template match="p"> +\noindent <xsl:apply-templates /> + </xsl:template> + <xsl:template match="tt">\texttt{<xsl:apply-templates />}</xsl:template> + + + <!-- ELEMENT img --> + + <xsl:template match="img"> + <xsl:variable name="_src"> + <xsl:value-of select="substring-before(substring-after(@src, '/'), '.')" /> + </xsl:variable> +\begin{figure}[ht] <!-- h:here, t:top, b:bottom, p:separate page --> +\begin{center} + <xsl:choose> + <xsl:when test="contains($_src,'classhierarchy')"> +\scalebox{0.75}[0.75]{\includegraphics{<xsl:value-of select="$_src" />}} + </xsl:when> + <xsl:otherwise> +\includegraphics{<xsl:value-of select="$_src" />} + </xsl:otherwise> + </xsl:choose> +\end{center} +\end{figure} + </xsl:template> + + + <!-- ELEMENT ul, li --> + + <xsl:template match="ul">\begin{list}{-}{\setlength{\topsep}{0.0em}\setlength{\itemsep}{0.0em}} + <xsl:apply-templates /> +\end{list}</xsl:template> + <xsl:template match="li">\item<xsl:apply-templates /></xsl:template> + + + <!-- ELEMENT pre --> + + <xsl:template match="pre"> +\begin{small} +\begin{alltt}<xsl:apply-templates />\end{alltt} +\end{small} + </xsl:template> + + + <!-- ELEMENT src (Scala source code) --> + + <xsl:template match="src"> + <xsl:if test="not(@action) or @action!='hide'"> +\begin{small} +\begin{alltt}<xsl:apply-templates />\end{alltt} +\end{small} + </xsl:if> + </xsl:template> + + + <!-- ELEMENT key (Scala keyword) --> + + <xsl:template match="key">\textbf{<xsl:apply-templates />}</xsl:template> + + + <!-- ELEMENT chr (character literal) --> + + <xsl:template match="chr"><xsl:apply-templates /></xsl:template> + + + <!-- ELEMENT str (string literal) --> + + <xsl:template match="str"><xsl:apply-templates /></xsl:template> + + + <!-- ELEMENT cmt (comment) --> + + <xsl:template match="cmt"><xsl:apply-templates /></xsl:template> + + + <!-- ELEMENT div, hidden --> + + <xsl:template match="div" /> + <xsl:template match="hidden"></xsl:template> + + + <!-- otherwise --> + + <xsl:template match="*"> + <xsl:copy> + <xsl:copy-of select="@*"/> + <xsl:apply-templates/> + </xsl:copy> + </xsl:template> + + +</xsl:stylesheet> |