// // Copyright (c) 2007, Brian Frank and Andy Frank // Licensed under the Academic Free License version 3.0 // // History: // 5 May 07 Brian Frank Creation // using compiler using fandoc ** ** FandocToHtml generates an HTML file for each fandoc file in pod ** class FandocToHtml : DocCompilerSupport { new make(DocCompiler compiler) : super(compiler) { } Void run() { // first find all the fandoc files and see // if we can find the index.fandoc file fandocFiles := File[,] File? indexFile := null compiler.pod.files.each |File file| { if (file.name == "index.fog") indexFile = file else if (file.ext == "fandoc") fandocFiles.add(file) } // if we have an index file process it first if (indexFile != null) { try { log.debug(" FandocIndex [$indexFile]") compiler.fandocIndex = indexFile.in.readObj loc := Location.makeFile(indexFile) outFile := compiler.podDir + "index.html".toUri FandocIndexToHtmlGenerator(compiler, loc, outFile.out).generate } catch (Err e) { errReport(CompilerErr("Cannot read index.fog", Location.makeFile(indexFile), e)) } } // process rest of the files fandocFiles.each |File file| { generate(file) } } Doc? generate(File inFile) { log.debug(" Fandoc [$inFile]") try { doc := FandocParser().parse(inFile.name, inFile.in) loc := Location(compiler.pod + "::" + inFile.name) outFile := compiler.podDir + "${inFile.basename}.html".toUri FandocToHtmlGenerator(compiler, loc, outFile, doc).generate return doc } catch (Err e) { errReport(CompilerErr("Cannot parse fandoc file", Location.makeFile(inFile), e)) return null } } }