Skip to content
This repository
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 78 lines (62 sloc) 2.331 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
//
// GBDocumentData.m
// appledoc
//
// Created by Tomaz Kragelj on 10.2.11.
// Copyright 2011 Gentle Bytes. All rights reserved.
//

#import "GBApplicationSettingsProvider.h"
#import "GBDataObjects.h"
#import "GBDocumentData.h"

@implementation GBDocumentData

#pragma mark Initialization & disposal

+ (id)documentDataWithContents:(NSString *)contents path:(NSString *)path {
return [[[self alloc] initWithContents:contents path:path] autorelease];
}

+ (id)documentDataWithContents:(NSString *)contents path:(NSString *)path basePath:(NSString *)basePath {
id result = [self documentDataWithContents:contents path:path];
[result setBasePathOfDocument:basePath];
return result;
}

- (id)initWithContents:(NSString *)contents path:(NSString *)path {
NSParameterAssert(contents != nil);
GBLogDebug(@"Initializing document with contents %@...", [contents normalizedDescription]);
self = [super init];
if (self) {
GBSourceInfo *info = [GBSourceInfo infoWithFilename:path lineNumber:1];
[self registerSourceInfo:info];
self.nameOfDocument = [path lastPathComponent];
self.pathOfDocument = path;
self.basePathOfDocument = @"";
self.comment = [GBComment commentWithStringValue:contents];
self.comment.sourceInfo = info;
_adoptedProtocols = [[GBAdoptedProtocolsProvider alloc] initWithParentObject:self];
_methods = [[GBMethodsProvider alloc] initWithParentObject:self];
        
        self.prettyNameOfDocument = [[self.nameOfDocument stringByDeletingPathExtension]stringByReplacingOccurrencesOfString:@"-template" withString:@""];
}
return self;
}

#pragma mark Overriden methods

- (NSString *)description {
return self.nameOfDocument;
}

- (NSString *)debugDescription {
return [NSString stringWithFormat:@"document %@", self.nameOfDocument];
}

- (BOOL)isStaticDocument {
return YES;
}

#pragma mark Properties

- (NSString *)subpathOfDocument {
NSString *result = [self.pathOfDocument stringByReplacingOccurrencesOfString:self.basePathOfDocument withString:@""];
if ([result hasPrefix:@"/"]) result = [result substringFromIndex:1];
return result;
}

@synthesize isCustomDocument;
@synthesize nameOfDocument;
@synthesize pathOfDocument;
@synthesize basePathOfDocument;
@synthesize adoptedProtocols = _adoptedProtocols;
@synthesize methods = _methods;
@synthesize prettyNameOfDocument;

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