diff --git a/project.properties b/project.properties index d4e378d..d7c14df 100644 --- a/project.properties +++ b/project.properties @@ -1,6 +1,6 @@ -#Fri, 09 Sep 2011 14:26:03 -0500 +#Fri, 09 Sep 2011 14:55:32 -0500 name=jlp version=0.3 -build.number=1 +build.number=7 lib.local=true release.dir=release diff --git a/src/main/com/jdblabs/jlp/JLPBaseGenerator.groovy b/src/main/com/jdblabs/jlp/JLPBaseGenerator.groovy index 91f0697..320fb17 100644 --- a/src/main/com/jdblabs/jlp/JLPBaseGenerator.groovy +++ b/src/main/com/jdblabs/jlp/JLPBaseGenerator.groovy @@ -11,14 +11,6 @@ public abstract class JLPBaseGenerator { protected JLPBaseGenerator(Processor processor) { this.processor = processor } - protected String generate(SourceFile source) { - - // run the parse phase - parse(source) - - // run the emit phase - return emit(source) } - protected void parse(SourceFile sourceFile) { sourceFile.blocks.each { block -> parse(block) } } diff --git a/src/main/com/jdblabs/jlp/LiterateMarkdownGenerator.groovy b/src/main/com/jdblabs/jlp/LiterateMarkdownGenerator.groovy index ae4d2a2..054e950 100644 --- a/src/main/com/jdblabs/jlp/LiterateMarkdownGenerator.groovy +++ b/src/main/com/jdblabs/jlp/LiterateMarkdownGenerator.groovy @@ -199,17 +199,17 @@ public class LiterateMarkdownGenerator extends JLPBaseGenerator { // The link should point to a different document. else { - thisDoc = processor.currentDoc - linkDoc = processor.docs[link.sourceDocId] + TargetDoc thisDoc = processor.currentDoc + TargetDoc linkDoc = processor.docs[link.sourceDocId] - pathToLinkedDoc = processor.getRelativePath( + String pathToLinkedDoc = processor.getRelativeFilepath( thisDoc.sourceFile.parentFile, - thatDoc.sourceFile) + linkDoc.sourceFile) // The target document may not be in the same directory // as us, backtrack to the (relative) top of our directory // structure. - newLink = pathToLinkedDoc + "/" + ".html#${linkId}" } + newLink = pathToLinkedDoc + ".html#${linkId}" } return newLink } diff --git a/src/main/com/jdblabs/jlp/Processor.groovy b/src/main/com/jdblabs/jlp/Processor.groovy index 82ec9c5..958a3e6 100644 --- a/src/main/com/jdblabs/jlp/Processor.groovy +++ b/src/main/com/jdblabs/jlp/Processor.groovy @@ -66,13 +66,22 @@ public class Processor { currentDoc.sourceAST = parseRunner.run( currentDoc.sourceFile.text).resultValue } - // generate output + // run our generator parse phase (first pass over the ASTs) processDocs { // TODO: add logic to configure or autodetect the correct generator // for each file def generator = getGenerator(LiterateMarkdownGenerator) - currentDoc.output = generator.generate(currentDoc.sourceAST) } + generator.parse(currentDoc.sourceAST) } + + + // Second pass by the generators, create output. + processDocs { + + // TODO: add logic to configure or autodetect the correct generator + // for each file + def generator = getGenerator(LiterateMarkdownGenerator) + currentDoc.output = generator.emit(currentDoc.sourceAST) } // Write the output to the output directory processDocs {