Release 0.1 is ready

* Tweaked CSS.
* Finished basic implementation of JLPMain (lots of thihngs are hardwired).
This commit is contained in:
Jonathan Bernard 2011-09-06 17:10:36 -05:00
parent bab1943120
commit 4bac35ef0b
7 changed files with 49 additions and 13 deletions

1
jlp Executable file
View File

@ -0,0 +1 @@
ng com.jdblabs.jlp.JLPMain "$@"

Binary file not shown.

Binary file not shown.

View File

@ -1,4 +1,5 @@
#Tue, 06 Sep 2011 17:09:38 -0500
name=jlp name=jlp
version=alpha1 version=alpha1
build.number=0 build.number=6
lib.local=true lib.local=true

View File

@ -50,7 +50,7 @@ td.docs, th.docs {
.docs table { .docs table {
border: thin solid #dedede; border: thin solid #dedede;
margin-left: 30px; } margin-left: 60px; }
td.code, th.code { td.code, th.code {
padding: 14px 15px 16px 25px; padding: 14px 15px 16px 25px;

View File

@ -1,6 +1,7 @@
package com.jdblabs.jlp package com.jdblabs.jlp
import com.jdblabs.jlp.ast.ASTNode import com.jdblabs.jlp.ast.ASTNode
import com.jdblabs.jlp.ast.SourceFile
import org.parboiled.Parboiled import org.parboiled.Parboiled
import org.parboiled.parserunners.ReportingParseRunner import org.parboiled.parserunners.ReportingParseRunner
@ -18,6 +19,8 @@ public class JLPMain {
// define options // define options
cli.h('Print this help information.', longOpt: 'help', required: false) cli.h('Print this help information.', longOpt: 'help', required: false)
cli.o("Output directory (defaults to 'jlp-docs').",
longOpt: 'output-dir', required: false)
// parse options // parse options
def opts = cli.parse(args) def opts = cli.parse(args)
@ -27,31 +30,62 @@ public class JLPMain {
cli.usage() cli.usage()
return } return }
// get the output directory and create it if necessary
def outputDir = opts.o ? new File(opts.o) : new File("jlp-docs")
if (!outputDir.exists()) outputDir.mkdirs()
// get the CSS theme to use
def css = JLPMain.class.getResourceAsStream("/jlp.css") // TODO: make an option
css = css.text
// get files passed in // get files passed in
def filenames = opts.getArgs() def filenames = opts.getArgs()
def files = filenames.collect { new File(it) }
// -------- parse input -------- // // -------- parse input -------- //
Map parsedFiles = files.inject([:]) { acc, file -> Map parsedFiles = filenames.inject([:]) { acc, filename ->
def parsed = inst.parse(new File(file)) acc[filename] = inst.parse(new File(filename))
acc[file.canonicalPath] = parsed
return acc } return acc }
// -------- generate output -------- // // -------- generate output -------- //
Map htmlDocs = LiterateMarkdownGenerator.generateDocuments(parsedFiles)
// -------- write output files ------- //
htmlDocs.each { filename, html ->
// split the path into parts
def fileParts = filename.split(/[\.\/]/)
File subDir = new File('.')
if (fileParts.length > 2) {
// find the relative subdirectory of this file
subDir = new File(outputDir, fileParts[0..-3].join('/'))
if (!subDir.exists()) subDir.mkdirs()
}
// recreate the output filename
def outputFilename = fileParts[-2] + ".html"
// write the HTML to the file
new File(subDir, outputFilename).withWriter { fileOut ->
// write the CSS if it is not present
File cssFile = new File(subDir, "jlp.css")
if (!cssFile.exists()) cssFile.withWriter { cssOut ->
cssOut.println css }
// write the file
fileOut.println html } }
} }
public JLPMain() { public JLPMain() {
parser = Parboiled.createParser(JLPPegParser.class) parser = Parboiled.createParser(JLPPegParser.class)
} }
public Map parse(File inputFile) { public SourceFile parse(File inputFile) {
def parseRunner = new ReportingParseRunner(parser.SourceFile()) def parseRunner = new ReportingParseRunner(parser.SourceFile())
// parse the file // parse the file
return parseRunner.run(inputFile).resultValue return parseRunner.run(inputFile.text).resultValue
}
public def generate(def emitter, List<ASTNode> blocks) {
// second pass, semantics
} }
} }

View File

@ -50,7 +50,7 @@ public class LiterateMarkdownGenerator extends JLPBaseGenerator {
<head> <head>
<title>${docState.currentDocId}</title> <title>${docState.currentDocId}</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"> <meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link rel="stylesheet" media="all" href="docco.css"/> <link rel="stylesheet" media="all" href="jlp.css"/>
</head> </head>
<body> <body>
<div id="container"> <div id="container">