
1 // 2 // Copyright (c) 2007, Brian Frank and Andy Frank 3 // Licensed under the Academic Free License version 3.0 4 // 5 // History: 6 // 5 May 07 Brian Frank Creation 7 // 8 9 using compiler 10 using fandoc 11 12 ** 13 ** FandocToHtml generates an HTML file for each fandoc file in pod 14 ** 15 class FandocToHtml : DocCompilerSupport 16 { 17 18 new make(DocCompiler compiler) 19 : super(compiler) 20 { 21 } 22 23 Void run() 24 { 25 // first find all the fandoc files and see 26 // if we can find the index.fandoc file 27 fandocFiles := File[,] 28 File indexFile := null 29 compiler.pod.files.each |File file| 30 { 31 if (file.name == "index.fog") 32 indexFile = file 33 else if (file.ext == "fandoc") 34 fandocFiles.add(file) 35 } 36 37 // if we have an index file process it first 38 if (indexFile != null) 39 { 40 try 41 { 42 log.debug(" FandocIndex [$indexFile]") 43 compiler.fandocIndex = indexFile.in.readObj 44 loc := Location.makeFile(indexFile) 45 outFile := compiler.podDir + "index.html".toUri 46 FandocIndexToHtmlGenerator.make(compiler, loc, outFile.out).generate 47 } 48 catch (Err e) 49 { 50 errReport(CompilerErr.make("Cannot read index.fog", 51 Location.makeFile(indexFile), e)) 52 } 53 } 54 55 // process rest of the files 56 fandocFiles.each |File file| { generate(file) } 57 } 58 59 Doc generate(File inFile) 60 61 { 62 log.debug(" Fandoc [$inFile]") 63 try 64 { 65 doc := FandocParser.make.parse(inFile.name, inFile.in) 66 loc := Location.make(compiler.pod + "::" + inFile.name) 67 68 outFile := compiler.podDir + "${inFile.basename}.html".toUri 69 FandocToHtmlGenerator.make(compiler, loc, outFile.out, doc).generate 70 71 return doc 72 } 73 catch (Err e) 74 { 75 errReport(CompilerErr.make("Cannot parse fandoc file", Location.makeFile(inFile), e)) 76 return null 77 } 78 } 79 80 }