Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit48f0a47

Browse files
committed
a bit more documentation
1 parent7891a1a commit48f0a47

File tree

11 files changed

+86
-6
lines changed

11 files changed

+86
-6
lines changed

‎README.md‎

Lines changed: 51 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,48 @@
11
#js-scala: JavaScript as an embedded DSL in Scala #
22

3-
###Documentation
3+
js-scala is a Scala library providing composable JavaScript code generators as embedded DSLs. Generate (optimized) JavaScript code from Scala-like code:
4+
5+
```scala
6+
importscala.js.language.JS
7+
traitJavaScriptGreetextendsJS {
8+
9+
defgreet(name:Rep[String]):Rep[Unit]= {
10+
println("Hello,"+ name+"!")
11+
}
12+
13+
}
14+
```
15+
16+
`greet` is a JavaScript program generator that produces a program that prints a message in the console. The JavaScript code can be produced as follows:
17+
18+
```scala
19+
importscala.js.exp.JSExp
20+
importscala.js.gen.js.GenJS
21+
objectGeneratorextendsApp {
22+
valjavaScriptGreet=newJavaScriptGreetwithJSExp
23+
valcodeGen=newGenJS {valIR: javaScriptGreet.type= javaScriptGreet }
24+
codeGen.emitSource(javaScriptGreet.greet,"greet",new java.io.PrintWriter(System.out))
25+
}
26+
```
27+
28+
Running the above Scala program will print the following on the standard output:
29+
30+
```javascript
31+
functiongreet(x0) {
32+
var x1="Hello,"+x0;
33+
var x2= x1+"!";
34+
var x3=console.log(x2);
35+
}
36+
```
37+
38+
##Publications and talks
439

540
* ECOOP 2012 paper ([PDF](http://infoscience.epfl.ch/record/179888/files/js-scala-ecoop.pdf)) and slides ([PDF](http://pldi12.cs.purdue.edu/sites/default/files/slides_ecoop_gkossakowski.pdf))
641
*[Scala Days 2012 talk](http://skillsmatter.com/podcast/scala/javascript-embedded-dsl-scala)
42+
* mloc-js'13 talk ([slides](http://prezi.com/l23gghh7c27t/?utm_campaign=share&utm_medium=copy&rc=ex0share))
43+
* GPCE'13 paper ([PDF](https://github.com/js-scala/js-scala/raw/master/papers/gpce2013/gpce19c-foy.pdf)) and[slides](https://docs.google.com/presentation/d/1ErPjZMTheuKwp428QpxWibZlyjK3PKijwKtYEaXWoxQ/pub?start=false&loop=false&delayms=3000)
744

8-
###Setup
45+
##Setup
946

1047
1. Setup[virtualization-lms-core](http://github.com/TiarkRompf/virtualization-lms-core):
1148
-`$ git clone git@github.com:TiarkRompf/virtualization-lms-core.git`
@@ -20,11 +57,14 @@
2057
-`> test`
2158
4. Publish it (if you want to use it in your project):
2259
-`> publish-local`
23-
5. Run the examples:
60+
5. Generate the API documentation:
61+
-`> doc`
62+
- The documentation is generated in the`core/target/scala-2.10/api/` directory.
63+
6. Run the examples:
2464
-`> project examples`
2565
-`> run`
2666

27-
###Use it in your project
67+
##Use it in your project
2868

2969
1. Add a dependency on js-scala 0.4-SNAPSHOT
3070
-`libraryDependencies += "EPFL" %% "js-scala" % "0.4-SNAPSHOT"`
@@ -34,8 +74,14 @@
3474
3. Set the`-Yvirtualize` compiler option
3575
-`scalacOptions += "-Yvirtualize"`
3676

37-
###Further projects
77+
##Further projects
3878

3979
*[play-js-validation](http://github.com/js-scala/play-js-validation) uses this DSL to enable form validation code in Play 2.0 to be written once and checked on both client and server sides.
4080

4181
*[forest](http://github.com/js-scala/forest) uses this DSL to enable HTML templates to be written once and shared between client and server sides, both for initial rendering and automatic updating.
82+
83+
##Quick start
84+
85+
First, be sure to be familiar with[LMS tutorials](http://scala-lms.github.io/tutorials).
86+
87+
(More to come!)

‎core/src/main/scala/scala/js/language/JS.scala‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,7 @@ package scala.js.language
55
*/
66
traitJSBaseextendsJsScalaBasewithDynamicswithArrayswithRegExpswithOptionOps
77

8+
/**
9+
* Same as [[scala.js.language.JSBase]] but with implicit conversions automatically lifting values to `Rep` values when needed.
10+
*/
811
traitJSextendsJSBasewithJsScala

‎core/src/main/scala/scala/js/language/JsScala.scala‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,15 @@ import scala.virtualization.lms.common._
55
/**
66
* Trait aggregating several DSLs providing a base language for Web programming with the ability to share code
77
* between server and client sides.
8+
*
9+
* Integrates most of the language units defined by LMS.
810
*/
911
traitJsScalaBaseextendsBasewithNumericOpswithOrderingOpswithEqualwithIfThenElse
1012
withWhilewithBooleanOpswithStringOpswithVariableswithListOpswithObjectOps
1113
withTupledFunctionswithStructswithPrimitiveOpswithMiscOpswithTupleOpswithListOps2
1214

15+
/**
16+
* Same as [[scala.js.language.JsScala]] but with implicit conversions automatically lifting values to `Rep` values when needed.
17+
*/
1318
traitJsScalaextendsJsScalaBasewithLiftVariableswithLiftEqualswithLiftNumericwithLiftStringwithLiftBoolean
1419
withLiftPrimitives

‎core/src/main/scala/scala/js/language/ListOps2.scala‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ package scala.js.language
22

33
importscala.virtualization.lms.common.Base
44

5+
/**
6+
* Add more operations on lists than those provided by LMS.
7+
*/
58
traitListOps2extendsBase {
69
implicitclassListOps2[A](l:Rep[List[A]]) {
710
defmkString2(sep:Rep[String])= list_mkString2(l, sep)

‎core/src/main/scala/scala/js/language/OptionOps.scala‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ package scala.js.language
22

33
importscala.virtualization.lms.common.Base
44

5+
/**
6+
* Language unit for optional values manipulation (similar to [[scala.Option]] type).
7+
*/
58
traitOptionOpsextendsBase {
69

710
valnone:Rep[None.type]

‎core/src/main/scala/scala/js/language/dom/Browser.scala‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ package scala.js.language.dom
22

33
importscala.virtualization.lms.common.Base
44

5+
/**
6+
* Web browser related API.
7+
*/
58
traitBrowserextendsBasewithSelectorOpswithEventOpswithElementOps {
69

710
traitWindowextendsEventTarget
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
packagescala.js.language.dom
22

3+
/**
4+
* Aggregates all the DOM API.
5+
*/
36
traitDomextendsCorewithElementOpswithEventOpswithNodeListOpswithBrowserwithSelectorOps

‎core/src/main/scala/scala/js/language/dom/ElementOps.scala‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ package scala.js.language.dom
22

33
importscala.virtualization.lms.common.Base
44

5+
/**
6+
* [[org.w3c.dom.Element]] manipulation.
7+
*/
58
traitElementOpsextendsBasewithEventOpswithSelectorOpswithCore {
69

710
traitCSSStyleDeclaration

‎core/src/main/scala/scala/js/language/dom/EventOps.scala‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
packagescala.js.language.dom
22

33
importscala.virtualization.lms.common.Base
4-
4+
5+
/**
6+
* [[org.w3c.dom.events.Event]] manipulation.
7+
*/
58
traitEventOpsextendsBase {
69

710
traitEventTarget

‎core/src/main/scala/scala/js/language/dom/NodeListOps.scala‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ package scala.js.language.dom
22

33
importscala.virtualization.lms.common.Base
44

5+
/**
6+
* [[org.w3c.dom.NodeList]] manipulation.
7+
*/
58
traitNodeListOpsextendsBase {
69

710
classNodeList[A]

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp