forked from playframework/play1
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#1660] Add support for project documentation in docviewer plugin
- Loading branch information
1 parent
2df91dc
commit 0b12575
Showing
16 changed files
with
625 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
modules/docviewer/app/controllers/ProjectDocumentation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package controllers; | ||
|
||
import play.modules.docviewer.DocumentationGenerator; | ||
import play.mvc.Controller; | ||
|
||
import java.io.File; | ||
|
||
/** | ||
* Controller to render project documentation. | ||
* Allows to embed textile docs inside project and access it via browser | ||
* in development mode. | ||
* | ||
* @author Marek Piechut | ||
*/ | ||
public class ProjectDocumentation extends Controller { | ||
|
||
public static DocumentationGenerator generator = new DocumentationGenerator(); | ||
|
||
public static void index() throws Exception { | ||
String indexHtml = generator.generateIndex(); | ||
|
||
//We need trailing slash or links won't work | ||
if (!request.url.endsWith("/")) { | ||
redirect(request.url + "/"); | ||
} | ||
renderHtml(indexHtml); | ||
} | ||
|
||
public static void page(String id) { | ||
String html = generator.generatePage(id); | ||
if (html == null) { | ||
notFound("Documentation page for " + id + " not found"); | ||
} | ||
renderHtml(html); | ||
} | ||
|
||
|
||
public static void file(String name) { | ||
File file = new File(generator.projectDocsPath, "files/" + name); | ||
if (!file.exists()) { | ||
notFound(); | ||
} | ||
renderBinary(file); | ||
} | ||
|
||
public static void image(String name) { | ||
File image = new File(generator.projectDocsPath, "images/" + name); | ||
|
||
if (!image.exists()) { | ||
notFound(); | ||
} | ||
renderBinary(image); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<project name="Docviewer" default="build" basedir="."> | ||
|
||
<path id="project.classpath"> | ||
<pathelement path="${play.path}/framework/classes"/> | ||
<fileset dir="${play.path}/framework/lib"> | ||
<include name="*.jar"/> | ||
</fileset> | ||
</path> | ||
|
||
<target name="build" depends="compile"> | ||
|
||
<copy todir="tmp/classes"> | ||
<fileset dir="src"> | ||
<include name="**/*.properties"/> | ||
<include name="**/*.xml"/> | ||
<include name="**/play.plugins"/> | ||
<include name="**/play.static"/> | ||
</fileset> | ||
</copy> | ||
<jar destfile="lib/play-docviewer.jar" basedir="tmp/classes"> | ||
<manifest> | ||
<section name="Play"> | ||
<attribute name="Specification-Title" value="Docviewer"/> | ||
</section> | ||
</manifest> | ||
</jar> | ||
<delete dir="tmp" /> | ||
</target> | ||
|
||
<target name="compile"> | ||
<mkdir dir="tmp/classes" /> | ||
<javac srcdir="src" destdir="tmp/classes" source="1.6" target="1.6" debug="true"> | ||
<classpath refid="project.classpath" /> | ||
</javac> | ||
</target> | ||
|
||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# Here you can create play commands that are specific to the module, and extend existing commands | ||
import os, os.path | ||
import getopt | ||
import sys | ||
import subprocess | ||
|
||
MODULE = 'docviewer' | ||
|
||
# Commands that are specific to your module | ||
|
||
COMMANDS = ['doc:export'] | ||
|
||
def execute(**kargs): | ||
command = kargs.get("command") | ||
app = kargs.get("app") | ||
args = kargs.get("args") | ||
env = kargs.get("env") | ||
|
||
if command == "doc:export": | ||
print "~ Generating project documentation" | ||
print "~ " | ||
java_cmd = app.java_cmd([], None, "play.modules.docviewer.ExportDocumentationGenerator", args) | ||
try: | ||
subprocess.call(java_cmd, env=os.environ) | ||
except OSError: | ||
print "Could not execute the java executable, please make sure the JAVA_HOME environment variable is set properly (the java executable should reside at JAVA_HOME/bin/java). " | ||
sys.exit(-1) | ||
|
||
# This will be executed before any command (new, run...) | ||
def before(**kargs): | ||
command = kargs.get("command") | ||
app = kargs.get("app") | ||
args = kargs.get("args") | ||
env = kargs.get("env") | ||
|
||
|
||
# This will be executed after any command (new, run...) | ||
def after(**kargs): | ||
command = kargs.get("command") | ||
app = kargs.get("app") | ||
args = kargs.get("args") | ||
env = kargs.get("env") | ||
|
||
if command == "new": | ||
pass | ||
|
Oops, something went wrong.