Skip to content
This repository
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 124 lines (104 sloc) 4.316 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
//
// DoxygenConverter.m
// appledoc
//
// Created by Tomaz Kragelj on 11.4.09.
// Copyright 2009 Tomaz Kragelj. All rights reserved.
//

#import "DoxygenConverter.h"
#import "Constants.h"
#import "Systemator.h"
#import "LoggingProvider.h"
#import "CommandLineParser.h"

#import "DoxygenOutputGenerator.h"
#import "XMLOutputGenerator.h"
#import "MarkdownOutputGenerator.h"
#import "XHTMLOutputGenerator.h"
#import "DocSetOutputGenerator.h"

@implementation DoxygenConverter

//////////////////////////////////////////////////////////////////////////////////////////
/// @name Initialization & disposal
//////////////////////////////////////////////////////////////////////////////////////////

//----------------------------------------------------------------------------------------
- (id)init
{
self = [super init];
if (self)
{
cmd = [CommandLineParser sharedInstance];
database = [[NSMutableDictionary alloc] init];

// Setup all output generators.
DoxygenOutputGenerator* doxygenGenerator = [[DoxygenOutputGenerator alloc] initWithDatabase:database];
XMLOutputGenerator* xmlGenerator = [[XMLOutputGenerator alloc] initWithDatabase:database];
MarkdownOutputGenerator* markdownGenerator = [[MarkdownOutputGenerator alloc] initWithDatabase:database];
XHTMLOutputGenerator* xhtmlGenerator = [[XHTMLOutputGenerator alloc] initWithDatabase:database];
DocSetOutputGenerator* docSetGenerator = [[DocSetOutputGenerator alloc] initWithDatabase:database];

// Setup all dependencies.
[doxygenGenerator registerDependentGenerator:xmlGenerator];
[xmlGenerator registerDependentGenerator:xhtmlGenerator];
[xmlGenerator registerDependentGenerator:markdownGenerator];
[xhtmlGenerator registerDependentGenerator:docSetGenerator];
xmlGenerator.doxygenInfoProvider = doxygenGenerator;
docSetGenerator.documentationFilesInfoProvider = xhtmlGenerator;

// Setup top level generators.
topLevelGenerators = [[NSMutableArray alloc] init];
[topLevelGenerators addObject:doxygenGenerator];

// We can now release generators because they are retained by their parents.
[doxygenGenerator release];
[xmlGenerator release];
[markdownGenerator release];
[xhtmlGenerator release];
[docSetGenerator release];
}
return self;
}

//----------------------------------------------------------------------------------------
- (void) dealloc
{
cmd = nil;
[database release], database = nil;
[topLevelGenerators release], topLevelGenerators = nil;
[super dealloc];
}

//////////////////////////////////////////////////////////////////////////////////////////
#pragma mark Converting handling
//////////////////////////////////////////////////////////////////////////////////////////

//----------------------------------------------------------------------------------------
- (void) convert
{
logNormal(@"Creating documentation...");

NSFileManager* manager = [NSFileManager defaultManager];

// If required, remove output directory to get a fresh start.
if (cmd.cleanOutputFilesBeforeBuild && [manager fileExistsAtPath:cmd.outputPath])
{
logNormal(@"Removing previous output files...");
[Systemator removeItemAtPath:cmd.outputPath];
logInfo(@"Finished removing previous output files.");
}

// If output directory doesn't yet exist, create it.
if (![manager fileExistsAtPath:cmd.outputPath])
{
logNormal(@"Creating output path...");
[Systemator createDirectory:cmd.outputPath];
logInfo(@"Finished creating output path.");
}

// Clear common variables.
[database removeAllObjects];
[database setObject:[NSMutableDictionary dictionary] forKey:kTKDataMainObjectsKey];
[database setObject:[NSMutableDictionary dictionary] forKey:kTKDataMainHierarchiesKey];
[database setObject:[NSMutableDictionary dictionary] forKey:kTKDataMainDirectoriesKey];

// Create all top level outputs. Note that this will in turn start all their
// dependent output generations.
logNormal(@"Generating output documentation...");
for (id<OutputProcessing> topLevelGenerator in topLevelGenerators)
{
if (topLevelGenerator.isOutputGenerationEnabled)
{
[topLevelGenerator generateOutput];
}
}
logInfo(@"Finished generating output documentation.");

// Notify the users that creation was succesful.ß
logNormal(@"Succesfully created output documentation.");
}

@end
Something went wrong with that request. Please try again.