Skip to content

Commit

Permalink
Implemented docsetutil path command line and global setting.
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaz committed Dec 13, 2010
1 parent 82f449a commit d8b7aa7
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 3 deletions.
3 changes: 3 additions & 0 deletions Application/GBAppledocApplication.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
static NSString *kGBArgOutputPath = @"output";
static NSString *kGBArgTemplatesPath = @"templates";
static NSString *kGBArgDocSetInstallPath = @"docset-install-path";
static NSString *kGBArgDocSetUtilPath = @"docsetutil-path";
static NSString *kGBArgIgnorePath = @"ignore";

static NSString *kGBArgProjectName = @"project-name";
Expand Down Expand Up @@ -167,6 +168,7 @@ - (void)application:(DDCliApplication *)app willParseOptions:(DDGetoptLongParser
{ kGBArgTemplatesPath, 't', DDGetoptRequiredArgument },
{ kGBArgIgnorePath, 'i', DDGetoptRequiredArgument },
{ kGBArgDocSetInstallPath, 0, DDGetoptRequiredArgument },
{ kGBArgDocSetUtilPath, 0, DDGetoptRequiredArgument },

{ kGBArgProjectName, 'p', DDGetoptRequiredArgument },
{ kGBArgProjectVersion, 'v', DDGetoptRequiredArgument },
Expand Down Expand Up @@ -368,6 +370,7 @@ - (NSString *)description {
- (void)setOutput:(NSString *)path { self.settings.outputPath = path; }
- (void)setTemplates:(NSString *)path { self.settings.templatesPath = path; }
- (void)setDocsetInstallPath:(NSString *)path { self.settings.docsetInstallPath = path; }
- (void)setDocsetutilPath:(NSString *)path { self.settings.docsetUtilPath = path; }
- (void)setIgnore:(NSString *)path {
if ([path hasPrefix:@"*"]) path = [path substringFromIndex:1];
[self.settings.ignoredPaths addObject:path];
Expand Down
7 changes: 5 additions & 2 deletions Application/GBApplicationSettingsProvider.m
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ - (id)init {
self.outputPath = @"";
self.templatesPath = nil;
self.docsetInstallPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Library/Developer/Shared/Documentation/DocSets"];
self.docsetUtilPath = @"/Developer/usr/bin/docsetutil";
self.ignoredPaths = [NSMutableSet set];

self.createHTML = YES;
Expand Down Expand Up @@ -290,10 +291,9 @@ - (NSString *)description {

@synthesize outputPath;
@synthesize docsetInstallPath;
@synthesize docsetUtilPath;
@synthesize templatesPath;
@synthesize ignoredPaths;
@synthesize commentComponents;
@synthesize stringTemplates;

@synthesize docsetBundleIdentifier;
@synthesize docsetBundleName;
Expand Down Expand Up @@ -324,4 +324,7 @@ - (NSString *)description {
@synthesize warnOnUndocumentedObject;
@synthesize warnOnUndocumentedMember;

@synthesize commentComponents;
@synthesize stringTemplates;

@end
3 changes: 3 additions & 0 deletions Application/GBApplicationSettingsProviding.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@
/** The path to which documentation set is to be installed. */
@property (copy) NSString *docsetInstallPath;

/** The path to `docsetutil` tool, including tool filename. */
@property (copy) NSString *docsetUtilPath;

/** The list of all full or partial paths to be ignored.
It's recommended to check if a path string ends with any of the given paths before processing it. This should catch directory and file names properly as directories are processed first.
Expand Down
2 changes: 1 addition & 1 deletion Generating/GBDocSetOutputGenerator.m
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ - (BOOL)indexDocSet:(NSError **)error {
GBTask *task = [GBTask task];
task.reportIndividualLines = YES;
NSArray *args = [NSArray arrayWithObjects:@"index", [self.outputUserPath stringByStandardizingPath], nil];
BOOL result = [task runCommand:@"/Developer/usr/bin/docsetutil" arguments:args block:^(NSString *output, NSString *error) {
BOOL result = [task runCommand:self.settings.docsetUtilPath arguments:args block:^(NSString *output, NSString *error) {
if (output) GBLogDebug(@"> %@", [output stringByTrimmingWhitespaceAndNewLine]);
if (error) GBLogError(@"!> %@", [error stringByTrimmingWhitespaceAndNewLine]);
}];
Expand Down
7 changes: 7 additions & 0 deletions Testing/GBApplicationTesting.m
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ - (void)testDocsetInstallPath_shouldAssignValueToSettings {
assertThat(settings.docsetInstallPath, is(@"path"));
}

- (void)testDocsetUtilPath_shouldAssignValueToSettings {
// setup & execute
GBApplicationSettingsProvider *settings = [self settingsByRunningWithArgs:@"--docsetutil-path", @"path", nil];
// verify
assertThat(settings.docsetUtilPath, is(@"path"));
}

- (void)testIgnore_shouldAssignValueToSettings {
// setup & execute
GBApplicationSettingsProvider *settings = [self settingsByRunningWithArgs:@"--ignore", @"path", nil];
Expand Down

0 comments on commit d8b7aa7

Please sign in to comment.