diff --git a/_includes/_haml/header.haml b/_includes/_haml/header.haml index 9e6ad4eaab73..d5e3108a75b5 100644 --- a/_includes/_haml/header.haml +++ b/_includes/_haml/header.haml @@ -17,9 +17,9 @@ %div %span Download %a{:href => "https://github.com/manastech/crystal/zipball/master"} .zip - / %li - / %a{:href => "#", :title => "Bookmark"} - / %i.ic.bookmark + %li + %a{:href => "/docs.html", :title => "Documentation"} + %i.ic.bookmark / %a.ico{:href => "#"} / %i.ip.downg / icosahedron.cr diff --git a/_includes/footer.html b/_includes/footer.html index 66786942528f..f8188c7013c8 100644 --- a/_includes/footer.html +++ b/_includes/footer.html @@ -1,10 +1,10 @@ diff --git a/_includes/header.html b/_includes/header.html index db16a35bb822..4ba16ac38abe 100644 --- a/_includes/header.html +++ b/_includes/header.html @@ -26,9 +26,11 @@ - - - +
  • + + + +
  • diff --git a/docs.html b/docs.html new file mode 100644 index 000000000000..407d3b8e8fa1 --- /dev/null +++ b/docs.html @@ -0,0 +1,1147 @@ + + + + + +The Crystal Programming Language + + + + + +
    +
    +
    +

    This is the documentation for the Crystal programming language.

    +
    + + + +
    +Caution +This is a work in progress. Anything written here is subject to change.
    +
    +
    +
    +
    +

    About

    +
    +

    Crystal is a programming language that resembles Ruby but compiles to native code and tries to be much more efficient, at the cost of disallowing certain dynamic aspects of Ruby.

    +
    +
    +
    +

    Installing

    +
    +
      +
    1. +

      +Clone the repository: git clone git@github.com:manastech/crystal.git +

      +
    2. +
    3. +

      +Execute bin/crystal --setup +

      +
    4. +
    5. +

      +You will need libgc. In mac: brew install bdw-gc. In Ubuntu: sudo apt-get install libgc. +

      +
    6. +
    +

    Then you will have available the bin/crystal executable.

    +
    + + + +
    +Caution +For now you can only use the compiler if you at the the cloned repository directory.
    +
    +
    +
    +
    +

    Syntax

    +
    +
    +

    Comments

    +

    Only one line comments are supported for now.

    +
    +
    # This is a comment
    +
    +
    +
    +

    Literals

    +
    +
    # The only instance of the Nil class
    +nil
    +
    +# The only instances of Bool
    +true
    +false
    +
    +# Integers. Without a suffix they are instances of Int32
    +1234
    +1_000_000
    +
    +# Hexadecimal
    +0xABCD_1234
    +
    +# Binary
    +0b1010_0110
    +
    +# With a suffix they can be Int64, UInt16, etc.
    +12_i64
    +45_u16
    +
    +# Floats. Without a suffix they are instances of Float64
    +1234.56
    +123e-09
    +
    +# With a suffix they can be Float32 or Float64
    +12.34_f32
    +68.91_f64
    +
    +# Characters
    +'a'
    +'\n'
    +
    +# With octal notation
    +'\033'
    +
    +# Strings
    +"hello world"
    +"escapes: \n \t \\ \" etc.'
    +"octals: \123 \12 \8"
    +"interpolation also allowed: 1 + 2 = #{1 + 2}"
    +%(this is also a string (supports nested parenthesis) as well as "quotes")
    +
    +# Symbols
    +:foo
    +:"another symbol"
    +
    +# Array
    +[1, 2, 3]
    +
    +# Empty Array (must indicate element type)
    +[] of String
    +
    +# Hash
    +{1 => 2, 3 => 4}
    +{"foo" => "bar"}
    +{:foo => 1}
    +{foo: 1} # same as above
    +
    +# Empty Hash (must indicate key and value types)
    +{} of Symbol => Int32
    +
    +# Ranges
    +1..5  # inclusive end
    +1...5 # exclusive end
    +
    +# Regular expressions
    +/foo\s+bar/
    +
    +
    +
    +
    +
    +

    + + + diff --git a/docs/about.asciidoc b/docs/about.asciidoc new file mode 100644 index 000000000000..c79e29b3297c --- /dev/null +++ b/docs/about.asciidoc @@ -0,0 +1,4 @@ +== About == + +Crystal is a programming language that resembles Ruby but compiles to native code and tries to be much more efficient, at the cost of disallowing certain dynamic aspects of Ruby. + diff --git a/docs/build.sh b/docs/build.sh new file mode 100755 index 000000000000..af81fa61377c --- /dev/null +++ b/docs/build.sh @@ -0,0 +1 @@ +asciidoc -b html5 -a icons -a toc2 -a iconsdir=`brew --prefix asciidoc`/etc/asciidoc/images/icons -a data-uri -a theme=flask -a source-highlighter=pygments -o ../docs.html index.asciidoc diff --git a/docs/index.asciidoc b/docs/index.asciidoc new file mode 100644 index 000000000000..7a7c73681c94 --- /dev/null +++ b/docs/index.asciidoc @@ -0,0 +1,10 @@ += The Crystal Programming Language = +:doctype: book + +This is the documentation for the Crystal programming language. + +CAUTION: This is a work in progress. Anything written here is subject to change. + +include::about.asciidoc[] +include::installing.asciidoc[] +include::syntax.asciidoc[] diff --git a/docs/installing.asciidoc b/docs/installing.asciidoc new file mode 100644 index 000000000000..9c8ed0f01f29 --- /dev/null +++ b/docs/installing.asciidoc @@ -0,0 +1,10 @@ +== Installing == + + 1. Clone the repository: `git clone git@github.com:manastech/crystal.git` + 2. Execute `bin/crystal --setup` + 3. You will need libgc. In mac: `brew install bdw-gc`. In Ubuntu: `sudo apt-get install libgc`. + +Then you will have available the `bin/crystal` executable. + +CAUTION: For now you can only use the compiler if you at the the cloned repository directory. + diff --git a/docs/syntax.asciidoc b/docs/syntax.asciidoc new file mode 100644 index 000000000000..d83922b6dc5f --- /dev/null +++ b/docs/syntax.asciidoc @@ -0,0 +1,84 @@ +== Syntax == + +=== Comments === + +Only one line comments are supported for now. + +[source,ruby] +------------- +# This is a comment +------------- + +=== Literals === + +[source,ruby] +------------- +# The only instance of the Nil class +nil + +# The only instances of Bool +true +false + +# Integers. Without a suffix they are instances of Int32 +1234 +1_000_000 + +# Hexadecimal +0xABCD_1234 + +# Binary +0b1010_0110 + +# With a suffix they can be Int64, UInt16, etc. +12_i64 +45_u16 + +# Floats. Without a suffix they are instances of Float64 +1234.56 +123e-09 + +# With a suffix they can be Float32 or Float64 +12.34_f32 +68.91_f64 + +# Characters +'a' +'\n' + +# With octal notation +'\033' + +# Strings +"hello world" +"escapes: \n \t \\ \" etc.' +"octals: \123 \12 \8" +"interpolation also allowed: 1 + 2 = #{1 + 2}" +%(this is also a string (supports nested parenthesis) as well as "quotes") + +# Symbols +:foo +:"another symbol" + +# Array +[1, 2, 3] + +# Empty Array (must indicate element type) +[] of String + +# Hash +{1 => 2, 3 => 4} +{"foo" => "bar"} +{:foo => 1} +{foo: 1} # same as above + +# Empty Hash (must indicate key and value types) +{} of Symbol => Int32 + +# Ranges +1..5 # inclusive end +1...5 # exclusive end + +# Regular expressions +/foo\s+bar/ +-------------