diff --git a/libraries/pom.xml b/libraries/pom.xml
index e4912da3dea..b767bc3c687 100644
--- a/libraries/pom.xml
+++ b/libraries/pom.xml
@@ -56,7 +56,7 @@
stdlib
kunit
kdoc
- apidocs
+ website
diff --git a/libraries/apidocs/apidocs.iml b/libraries/website/apidocs.iml
similarity index 53%
rename from libraries/apidocs/apidocs.iml
rename to libraries/website/apidocs.iml
index 6add695202e..cca07125daf 100644
--- a/libraries/apidocs/apidocs.iml
+++ b/libraries/website/apidocs.iml
@@ -4,10 +4,19 @@
+
+
+
+
+
+
+
+
+
diff --git a/libraries/apidocs/pom.xml b/libraries/website/pom.xml
similarity index 94%
rename from libraries/apidocs/pom.xml
rename to libraries/website/pom.xml
index a86d507f4c4..1ba05f585fe 100644
--- a/libraries/apidocs/pom.xml
+++ b/libraries/website/pom.xml
@@ -11,9 +11,14 @@
1.0-SNAPSHOT
- apidocs
+ website
+
+ org.jetbrains.kotlin
+ stdlib
+ ${project.version}
+
org.pegdown
pegdown
diff --git a/libraries/website/src/main/kotlin/org/jetbrains/kotlin/site/SiteGenerator.kt b/libraries/website/src/main/kotlin/org/jetbrains/kotlin/site/SiteGenerator.kt
new file mode 100644
index 00000000000..bb5bc44a4d8
--- /dev/null
+++ b/libraries/website/src/main/kotlin/org/jetbrains/kotlin/site/SiteGenerator.kt
@@ -0,0 +1,45 @@
+package org.jetbrains.kotlin.site
+
+import kotlin.io.*
+
+import java.io.File
+import org.pegdown.Extensions
+import org.pegdown.PegDownProcessor
+import org.pegdown.LinkRenderer
+
+class SiteGenerator(val sourceDir: File, val outputDir: File) : Runnable {
+ public var markdownProcessor: PegDownProcessor = PegDownProcessor(Extensions.ALL)
+ public var linkRendered: LinkRenderer = LinkRenderer()
+
+ override fun run() {
+ println("Generating the site to $outputDir")
+
+ sourceDir.recurse {
+ if (it.isFile()) {
+ var relativePath = sourceDir.relativePath(it)
+ println("Processing ${relativePath}")
+ var text = it.readText()
+ if (it.extension == "md") {
+ text = markdownProcessor.markdownToHtml(text, linkRendered) ?: ""
+ relativePath = relativePath.trimTrailing(it.extension) + "html"
+ }
+ text = layout(relativePath, it, text)
+ val outFile = File(outputDir, relativePath)
+ outFile.directory.mkdirs()
+ outFile.writeText(text)
+ }
+ }
+ }
+
+ /**
+ * Applies a layout to the given file
+ */
+ fun layout(uri: String, file: File, text: String): String {
+ return """
+
+$text
+
+
+"""
+ }
+}
\ No newline at end of file
diff --git a/libraries/website/src/main/templates/apidocs/resources/bkgheader.png b/libraries/website/src/main/templates/apidocs/resources/bkgheader.png
new file mode 100644
index 00000000000..145cc11d2bd
Binary files /dev/null and b/libraries/website/src/main/templates/apidocs/resources/bkgheader.png differ
diff --git a/libraries/website/src/main/templates/apidocs/resources/gradient-sand-white.png b/libraries/website/src/main/templates/apidocs/resources/gradient-sand-white.png
new file mode 100644
index 00000000000..3fca67807c0
Binary files /dev/null and b/libraries/website/src/main/templates/apidocs/resources/gradient-sand-white.png differ
diff --git a/libraries/website/src/main/templates/apidocs/stylesheet.css b/libraries/website/src/main/templates/apidocs/stylesheet.css
new file mode 100644
index 00000000000..48fdeb5a61c
--- /dev/null
+++ b/libraries/website/src/main/templates/apidocs/stylesheet.css
@@ -0,0 +1,118 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ *
+ * Red Hat licenses this file to you under the Apache License, version 2.0
+ * (the "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+/* Javadoc style sheet */
+
+/* Define colors, fonts and other style attributes here to override the defaults */
+
+/* Page background color */
+body {
+ background-color: #FFFFFF;
+ background-image:url(resources/gradient-sand-white.png);
+ background-repeat: repeat-x;
+ margin:0 auto;
+ font-family:'Lucida Grande', Geneva, Verdana, Arial, sans-serif;
+ font-size:12px;
+ padding:0em 1em;
+ color:#333;
+
+ }
+
+/* Common elements */
+
+font {
+ font-family: inherit;
+ font-size: inherit;
+ color: inherit;
+ font-weight: inherit; }
+
+hr {
+ border-top: 1px solid #A9A89B;
+ border-bottom: 0 none;
+}
+
+tt, tt *, pre, pre *, code, code * {
+ font-family: "Liberation Mono", "DejaVu Sans Mono", Consolas, Monaco, "Vera Sans Mono", "Lucida Console", "Courier New", monospace !important;
+}
+a:link { color:#5d5c50; }
+a:visited { color:#5d5c50; }
+a:hover { color:#5d5c50; }
+
+
+/* Headings */
+h1 {
+ font-size: 145%;
+ border-top:1px dotted #CCCCCC;
+ line-height:1.2em;
+ color:#CC333A;
+ font-size:2em;
+ padding:1.5em;
+ margin-top: 0px;
+ text-align:left;
+}
+
+
+/* Default Table elements and colors */
+
+th, table { border-collapse:collapse;border-color: #A9A89B; }
+
+
+.TableHeadingColor {
+ background:#EBE7C4 url(resources/bkgheader.png) no-repeat right top;
+ color:#CC333A;
+ font-size:12px;
+ font-weight:bold;
+ height:31px;
+ text-align:left;
+ padding:1.5em;
+}
+
+.TableHeadingColor th {
+ padding-left: 10px;
+}
+
+
+.TableSubHeadingColor { background-color:#EBE7C4; }
+.TableRowColor { background: white; border-color: #A9A89B;}
+.TableRowColor td { line-height: 175%; padding-left: 10px;}
+
+/* Font used in left-hand frame lists */
+.FrameTitleFont { font-size: 125%; font-family: Helvetica, Arial, sans-serif; font-weight: bold; margin-top: 1em; display: block; }
+.FrameHeadingFont { font-size: 125%; font-family: 'Lucida Grande', Geneva, Verdana, Arial, sans-serif; font-weight: bold; margin-top: 1em; display: block; }
+.FrameItemFont { font-size: 100%; font-family: Helvetica, Arial, sans-serif }
+
+/* Navigation bar fonts and colors */
+
+.NavBarCell1 {
+ background:#EBE7C4;
+ line-height:2em;
+ padding-left:6px;
+ padding-right:6px;
+}
+
+.NavBarFont1 {
+ color: #CC333A;
+}
+.NavBarCell1 a {
+ color: #CC333A;
+}
+
+.NavBarCell1Rev { background:#EBE7C4; padding-left:6px; padding-right:6px;}
+.NavBarFont1 { color:#CC333A;}
+.NavBarFont1Rev { color:#243446;}
+
+.NavBarCell2 { background-color:#FFFFFF;}
+.NavBarCell3 { background-color:#FFFFFF;}
diff --git a/libraries/website/src/main/templates/index.md b/libraries/website/src/main/templates/index.md
new file mode 100644
index 00000000000..44a0d4b7d97
--- /dev/null
+++ b/libraries/website/src/main/templates/index.md
@@ -0,0 +1,20 @@
+# Kotlin Programming Language
+
+Welcome to [Kotlin](http://www.jetbrains.com/kotlin)!
+
+Some handy links
+
+ * [API Docs](apidocs/index.html)
+ * [Kotlin Blog](http://blog.jetbrains.com/kotlin/)
+ * [Web Demo](http://kotlin-demo.jetbrains.com/)
+ * [Issue Tracker](http://youtrack.jetbrains.com/issues/KT)
+ * [follow Kotlin on twitter](http://twitter.com/#!/project_kotlin)
+
+## Editing Kotlin
+
+ * [Kotlin IDEA Plugin](http://hadihariri.com/2012/02/17/the-kotlin-journey-part-i-getting-things-set-up/)
+ * [Kotlin TextMate Bundle](https://github.com/k33g/kotlin-textmate-bundle#readme)
+
+## Kommitter links
+
+* [TeamCity CI build](http://teamcity.jetbrains.com/project.html?projectId=project67&tab=projectOverview)
\ No newline at end of file
diff --git a/libraries/website/src/test/kotlin/org/jetbrains/kotlin/site/GenerateSiteTest.kt b/libraries/website/src/test/kotlin/org/jetbrains/kotlin/site/GenerateSiteTest.kt
new file mode 100644
index 00000000000..fbf4e4bce80
--- /dev/null
+++ b/libraries/website/src/test/kotlin/org/jetbrains/kotlin/site/GenerateSiteTest.kt
@@ -0,0 +1,25 @@
+package org.jetbrains.kotlin.site
+
+import junit.framework.TestCase
+import java.io.File
+import kotlin.util.arrayList
+
+class GenerateSiteTest : TestCase() {
+
+ fun testGenerateSite(): Unit {
+ val srcDir = findTemplateDir()
+ val generator = SiteGenerator(srcDir, File(srcDir, "../../../target/site"))
+ generator.run()
+ }
+
+ fun findTemplateDir(): File {
+ val path = "src/main/templates"
+ for (p in arrayList(".", "apidocs", "library/apidocs")) {
+ val sourceDir = File(".", path)
+ if (sourceDir.exists()) {
+ return sourceDir
+ }
+ }
+ throw IllegalArgumentException("Could not find template directory: $path")
+ }
+}
\ No newline at end of file