Bugfix in recent changes.
* The generators originally had two phases, *parse* and *emit*. The *parse* phase allowed the generator to walk the AST for every document noting things it would need when emitting output. So the *parse* phase looked over every input document before the *emit* phase ran. During the refactor this changed and for each file the *emit* phase was running immediately after the *parse* phase, when it should have been run only after all inputs had been through the *parse* phase. * Fixed a type in the ``LiterateMarkdownGenerator``: an extra '`/`' was being inserted into the url for link targets.
This commit is contained in:
parent
d31d17d1e2
commit
75103b4bb5
@ -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
|
||||
|
@ -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) } }
|
||||
|
||||
|
@ -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 }
|
||||
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user