
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 06 Brian Frank Creation 7 // 8 9 using compiler 10 using fandoc 11 12 ** 13 ** DocCompiler manages the pipeline of compiling API and 14 ** stand-alone fandoc documents into HTML. 15 ** 16 class DocCompiler 17 { 18 19 ////////////////////////////////////////////////////////////////////////// 20 // Construction 21 ////////////////////////////////////////////////////////////////////////// 22 23 new make() 24 { 25 log = CompilerLog.make 26 errors = CompilerErr[,] 27 outDir = Sys.homeDir + `doc/` 28 uriMapper = UriMapper.make(this) 29 } 30 31 ////////////////////////////////////////////////////////////////////////// 32 // Compile 33 ////////////////////////////////////////////////////////////////////////// 34 35 Void compilePodToHtml() 36 { 37 log.info("DocCompiler [$pod]") 38 Init.make(this).run 39 ApiToHtml.make(this).run 40 SourceToHtml.make(this).run 41 FandocToHtml.make(this).run 42 PodIndexToHtml.make(this).run 43 if (!errors.isEmpty) throw errors.last 44 } 45 46 Void compileTopIndexToHtml() 47 { 48 log.info("DocCompiler [top index]") 49 TopIndexToHtml.make(this).run 50 BuildSearchIndex.make(this).run 51 CopyResources.make(this).run 52 if (!errors.isEmpty) throw errors.last 53 } 54 55 ////////////////////////////////////////////////////////////////////////// 56 // Errors 57 ////////////////////////////////////////////////////////////////////////// 58 59 ** 60 ** Create, log, and return a CompilerErr. 61 ** 62 CompilerErr err(Str msg, Location loc) 63 { 64 return errReport(CompilerErr.make(msg, loc)) 65 } 66 67 ** 68 ** Log, store, and return the specified CompilerErr. 69 ** 70 CompilerErr errReport(CompilerErr e) 71 { 72 log.compilerErr(e) 73 errors.add(e) 74 return e 75 } 76 77 ////////////////////////////////////////////////////////////////////////// 78 // Fields 79 ////////////////////////////////////////////////////////////////////////// 80 81 CompilerLog log // ctor 82 CompilerErr[] errors // accumulated errors 83 File outDir // output directory 84 Pod pod // pod to compile 85 UriMapper uriMapper // normalizes fandoc URIs to HTML 86 File podDir // Init: outDir/podName 87 Obj[] fandocIndex // FandocToHtml if we have "index.fog" 88 Type curType // if running Api generation 89 90 }