Skip to content

Commit

Permalink
Improved the docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
nmihajlovski committed Aug 14, 2015
1 parent 525cd2c commit de56ce2
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 20 deletions.
6 changes: 3 additions & 3 deletions rapidoid-docs/src/main/java/org/rapidoid/docs/Docs.java
Expand Up @@ -73,8 +73,8 @@ private static void generateIndex(String path) {

IntWrap nn = new IntWrap();

// processFirst(examples, nn, 3);
processAll(examples, nn);
processFirst(examples, nn, 3);
// processAll(examples, nn);

Map<String, ?> model = U.map("examples", examples);
String html = Templates.fromFile("docs.html").render(model);
Expand Down Expand Up @@ -193,7 +193,7 @@ private static Map<String, String> getResult(String line) {
}
} catch (Exception e) {
e.printStackTrace();
result = "<b>404 Not found!</b>";
result = "<span class=\"not-found\">404 Not found!</span>";
}

if (result == null) {
Expand Down
13 changes: 12 additions & 1 deletion rapidoid-docs/src/main/java/org/rapidoid/docs/eg001/Main.java
Expand Up @@ -3,6 +3,7 @@
import org.rapidoid.annotation.Page;
import org.rapidoid.annotation.Web;
import org.rapidoid.main.Rapidoid;
import org.rapidoid.util.U;

/*
* #%L
Expand All @@ -24,7 +25,7 @@
* #L%
*/

// Hello, world! :: Let's start Rapidoid:
// Hello, web pages! :: Let's start Rapidoid and implement some web pages:

@Web
public class Main {
Expand All @@ -38,4 +39,14 @@ public String hello() {
return "Hello, world!";
}

@Page(title = "Saying 'hi'")
public String hi(String name) {
return U.format("Hi, %s!", name);
}

@Page(raw = true)
public Object simple() {
return "<p><b>RAW</b> HTML!<p>";
}

}
18 changes: 8 additions & 10 deletions rapidoid-docs/src/main/java/org/rapidoid/docs/eg002/Main.java
@@ -1,8 +1,11 @@
package org.rapidoid.docs.eg002;

import java.util.Map;

import org.rapidoid.annotation.GET;
import org.rapidoid.annotation.Web;
import org.rapidoid.main.Rapidoid;
import org.rapidoid.util.U;

/*
* #%L
Expand All @@ -24,7 +27,7 @@
* #L%
*/

// Hello, world 2! :: Let's start Rapidoid:
// Hello, RESTful services! :: Let's start Rapidoid and implement a RESTful service:

@Web
public class Main {
Expand All @@ -34,15 +37,10 @@ public static void main(String[] args) {
}

@GET
public String upper(String s) {
return s.toUpperCase();
public Map<String, ?> upper(String s) {
String up = s.toUpperCase();
int len = s.length();
return U.map("src", s, "upper", up, "length", len);
}
}

@Web
class Opa {
@GET
public String iha() {
return "jee";
}
}
5 changes: 3 additions & 2 deletions rapidoid-docs/src/main/java/org/rapidoid/docs/eg003/Main.java
Expand Up @@ -8,6 +8,7 @@
import org.rapidoid.annotation.Param;
import org.rapidoid.annotation.Web;
import org.rapidoid.main.Rapidoid;
import org.rapidoid.util.U;

/*
* #%L
Expand All @@ -29,7 +30,7 @@
* #L%
*/

// RESTful services :: It is very easy to create RESTful services
// More RESTful services :: Let's create more RESTful services:

@Web
public class Main {
Expand All @@ -40,7 +41,7 @@ public static void main(String[] args) {

@GET
public String hey(String name, int age) {
return "Hey " + name + " (" + age + ")";
return U.format("Hey %s (%s)", name, age);
}

@GET("/hello")
Expand Down
6 changes: 3 additions & 3 deletions rapidoid-docs/src/main/resources/eg/001.txt
@@ -1,4 +1,4 @@
GET /
GET /abc
POST /abc
POST /xy
GET /hi/Rapidoid
POST /hi/there
GET /simple
4 changes: 3 additions & 1 deletion rapidoid-docs/src/main/resources/eg/003.txt
@@ -1,5 +1,7 @@
GET /
GET /hey/Joe/50
GET /hello?name=Highlander&age=900
GET /foo
GET /foo/x/y
POST /foo/aaa/123/bc
GET /barbar?x=1&y=23
GET /barbar?name=Abc&year=2015
2 changes: 2 additions & 0 deletions rapidoid-docs/src/main/resources/eg/004.txt
@@ -0,0 +1,2 @@
GET /params?x=1&y=2
POST /params?title=Rapidoid&year=2015

0 comments on commit de56ce2

Please sign in to comment.