Permalink
Browse files

Support for Programming guides in TOC and Index Page. repeating short…

…Description in discussion disabled by default.
  • Loading branch information...
1 parent e81e2f8 commit 8dac7749e3a8eda76da35a9fc602d9764d9fc90e smorel committed Mar 6, 2012
@@ -78,7 +78,7 @@ - (id)init {
self.createDocSet = YES;
self.installDocSet = YES;
self.publishDocSet = NO;
- self.repeatFirstParagraphForMemberDescription = YES;
+ self.repeatFirstParagraphForMemberDescription = NO;
self.useSingleStarForBold = NO;
self.keepIntermediateFiles = NO;
self.cleanupOutputPathBeforeRunning = NO;
@@ -101,6 +101,7 @@ - (NSDictionary *)indexPage {
if (!result) {
result = [[NSMutableDictionary alloc] init];
[result setObject:@"%@ Reference" forKey:@"titleTemplate"];
+ [result setObject:@"Programming Guides" forKey:@"docsTitle"];
[result setObject:@"Class References" forKey:@"classesTitle"];
[result setObject:@"Category References" forKey:@"categoriesTitle"];
[result setObject:@"Protocol References" forKey:@"protocolsTitle"];
@@ -126,6 +127,7 @@ - (NSDictionary *)docset {
static NSMutableDictionary *result = nil;
if (!result) {
result = [[NSMutableDictionary alloc] init];
+ [result setObject:@"Programming Guides" forKey:@"docsTitle"];
[result setObject:@"Classes" forKey:@"classesTitle"];
[result setObject:@"Categories" forKey:@"categoriesTitle"];
[result setObject:@"Protocols" forKey:@"protocolsTitle"];
@@ -28,6 +28,8 @@ - (void)addTokensXmlModelObjectDataForObject:(GBModelBase *)object toData:(NSMut
- (void)initializeSimplifiedObjects;
- (NSArray *)simplifiedObjectsFromObjects:(NSArray *)objects value:(NSString *)value index:(NSUInteger *)index;
- (NSString *)tokenIdentifierForObject:(GBModelBase *)object;
+
+@property (retain) NSArray *documents;
@property (retain) NSArray *classes;
@property (retain) NSArray *categories;
@property (retain) NSArray *protocols;
@@ -133,9 +135,11 @@ - (BOOL)processNodesXml:(NSError **)error {
NSMutableDictionary *vars = [NSMutableDictionary dictionary];
[vars setObject:self.settings.projectName forKey:@"projectName"];
[vars setObject:@"index.html" forKey:@"indexFilename"];
+ [vars setObject:([self.documents count] > 0) ? [GRYes yes] : [GRNo no] forKey:@"hasDocs"];
[vars setObject:([self.classes count] > 0) ? [GRYes yes] : [GRNo no] forKey:@"hasClasses"];
[vars setObject:([self.categories count] > 0) ? [GRYes yes] : [GRNo no] forKey:@"hasCategories"];
[vars setObject:([self.protocols count] > 0) ? [GRYes yes] : [GRNo no] forKey:@"hasProtocols"];
+ [vars setObject:self.documents forKey:@"docs"];
[vars setObject:self.classes forKey:@"classes"];
[vars setObject:self.categories forKey:@"categories"];
[vars setObject:self.protocols forKey:@"protocols"];
@@ -166,6 +170,7 @@ - (BOOL)processTokensXml:(NSError **)error {
// Write each object as a separate token file.
NSUInteger index = 1;
+ if (![self processTokensXmlForObjects:self.documents type:@"doc" template:templatePath index:&index error:error]) return NO;
if (![self processTokensXmlForObjects:self.classes type:@"cl" template:templatePath index:&index error:error]) return NO;
if (![self processTokensXmlForObjects:self.categories type:@"cat" template:templatePath index:&index error:error]) return NO;
if (![self processTokensXmlForObjects:self.protocols type:@"intf" template:templatePath index:&index error:error]) return NO;
@@ -313,11 +318,14 @@ - (NSString *)tokenIdentifierForObject:(GBModelBase *)object {
} else if ([object isKindOfClass:[GBCategoryData class]]) {
NSString *objectName = [(GBCategoryData *)object idOfCategory];
return [NSString stringWithFormat:@"//apple_ref/occ/cat/%@", objectName];
- } else {
+ } else if ([object isKindOfClass:[GBProtocolData class]]){
NSString *objectName = [(GBProtocolData *)object nameOfProtocol];
return [NSString stringWithFormat:@"//apple_ref/occ/intf/%@", objectName];
}
- } else if (!object.isStaticDocument) {
+ } else if ([object isKindOfClass:[GBDocumentData class]]){
+ NSString *objectName = [(GBDocumentData *)object prettyNameOfDocument];
+ return [NSString stringWithFormat:@"//apple_ref/occ/doc/%@", objectName];
+ } else if (!object.isStaticDocument) {
// Members are slighly more complex - their identifier is different regarding to whether they are part of class or category/protocol. Then it depends on whether they are method or property. Finally their parent object (class/category/protocol) name (again class name for category) and selector should be added.
if (!object.parentObject) [NSException raise:@"Can't create token identifier for %@; object is not top level and has no parent assigned!", object];
@@ -350,6 +358,7 @@ - (void)initializeSimplifiedObjects {
// Prepare flat list of objects for library nodes.
GBLogDebug(@"Initializing simplified object representations...");
NSUInteger index = 1;
+ self.documents = [self simplifiedObjectsFromObjects:[self.store documentsSortedByName] value:@"prettyNameOfDocument" index:&index];
self.classes = [self simplifiedObjectsFromObjects:[self.store classesSortedByName] value:@"nameOfClass" index:&index];
self.categories = [self simplifiedObjectsFromObjects:[self.store categoriesSortedByName] value:@"idOfCategory" index:&index];
self.protocols = [self simplifiedObjectsFromObjects:[self.store protocolsSortedByName] value:@"nameOfProtocol" index:&index];
@@ -389,6 +398,7 @@ - (NSMutableSet *)temporaryFiles {
return result;
}
+@synthesize documents;
@synthesize classes;
@synthesize categories;
@synthesize protocols;
@@ -12,6 +12,7 @@
#import "GBApplicationSettingsProvider.h"
#import "GBObjectDataProviding.h"
#import "GBDataObjects.h"
+#import "GBDocumentData.h"
#import "GBHTMLTemplateVariablesProvider.h"
#pragma mark -
@@ -62,6 +63,7 @@ @interface GBHTMLTemplateVariablesProvider (IndexVariables)
- (NSString *)pageTitleForIndex;
- (NSString *)pageTitleForHierarchy;
+- (NSArray *)documentsForIndex;
- (NSArray *)classesForIndex;
- (NSArray *)categoriesForIndex;
- (NSArray *)protocolsForIndex;
@@ -166,6 +168,7 @@ - (NSDictionary *)variablesForIndexWithStore:(id)store {
[self addFooterVarsToDictionary:page];
NSMutableDictionary *result = [NSMutableDictionary dictionary];
[result setObject:page forKey:@"page"];
+ [result setObject:[self documentsForIndex] forKey:@"docs"];
[result setObject:[self classesForIndex] forKey:@"classes"];
[result setObject:[self protocolsForIndex] forKey:@"protocols"];
[result setObject:[self categoriesForIndex] forKey:@"categories"];
@@ -203,6 +206,7 @@ - (NSString *)hrefForObject:(id)object fromObject:(id)source {
if ([object isKindOfClass:[GBClassData class]] && ![[self.store classes] containsObject:object]) return nil;
if ([object isKindOfClass:[GBCategoryData class]] && ![[self.store categories] containsObject:object]) return nil;
if ([object isKindOfClass:[GBProtocolData class]] && ![[self.store protocols] containsObject:object]) return nil;
+ if ([object isKindOfClass:[GBDocumentData class]] && ![[self.store documents] containsObject:object]) return nil;
return [self.settings htmlReferenceForObject:object fromSource:source];
}
@@ -422,6 +426,18 @@ - (NSString *)pageTitleForHierarchy {
return [NSString stringWithFormat:template, self.settings.projectName];
}
+- (NSArray*)documentsForIndex{
+ NSArray *documents = [self.store documentsSortedByName];
+ NSMutableArray *result = [NSMutableArray arrayWithCapacity:[documents count]];
+ for (GBDocumentData *document in documents) {
+ NSMutableDictionary *data = [NSMutableDictionary dictionaryWithCapacity:2];
+ [data setObject:[self hrefForObject:document fromObject:nil] forKey:@"href"];
+ [data setObject:document.prettyNameOfDocument forKey:@"title"];
+ [result addObject:data];
+ }
+ return result;
+}
+
- (NSArray *)classesForIndex {
NSArray *classes = [self.store classesSortedByName];
NSMutableArray *result = [NSMutableArray arrayWithCapacity:[classes count]];
@@ -519,9 +535,11 @@ - (NSArray *)arrayFromHierarchyLevel:(NSDictionary *)level {
}
- (void)registerObjectsUsageForIndexInDictionary:(NSMutableDictionary *)dict {
+ BOOL documents = [self.store.documents count] > 0;
BOOL classes = [self.store.classes count] > 0;
BOOL categories = [self.store.categories count] > 0;
BOOL protocols = [self.store.protocols count] > 0;
+ [dict setObject:documents ? [GRYes yes] : [GRNo no] forKey:@"hasDocs"];
[dict setObject:classes ? [GRYes yes] : [GRNo no] forKey:@"hasClasses"];
[dict setObject:categories ? [GRYes yes] : [GRNo no] forKey:@"hasCategories"];
[dict setObject:protocols ? [GRYes yes] : [GRNo no] forKey:@"hasProtocols"];
@@ -30,6 +30,8 @@
/** Returns a new autoreleased `GBTemplateHandler`. */
+ (id)handler;
+- (NSString*)templateString;
+
///---------------------------------------------------------------------------------------
/// @name Parsing
///---------------------------------------------------------------------------------------
@@ -35,6 +35,10 @@ + (id)handler {
return [[[self alloc] init] autorelease];
}
+- (NSString*)templateString{
+ return _templateString;
+}
+
- (id)init {
self = [super init];
if (self) {
View
@@ -68,6 +68,7 @@
@see basePathOfDocument
*/
@property (copy) NSString *nameOfDocument;
+@property (copy) NSString *prettyNameOfDocument;
/** Full path of the document source, including the file name and extension.
View
@@ -38,6 +38,8 @@ - (id)initWithContents:(NSString *)contents path:(NSString *)path {
self.comment.sourceInfo = info;
_adoptedProtocols = [[GBAdoptedProtocolsProvider alloc] initWithParentObject:self];
_methods = [[GBMethodsProvider alloc] initWithParentObject:self];
+
+ self.prettyNameOfDocument = [[self.nameOfDocument stringByDeletingPathExtension]stringByReplacingOccurrencesOfString:@"-template" withString:@""];
}
return self;
}
@@ -70,5 +72,6 @@ - (NSString *)subpathOfDocument {
@synthesize basePathOfDocument;
@synthesize adoptedProtocols = _adoptedProtocols;
@synthesize methods = _methods;
+@synthesize prettyNameOfDocument;
@end
View
@@ -218,6 +218,9 @@
///---------------------------------------------------------------------------------------
/** Returns all registered classes sorted by their name. */
+- (NSArray *)documentsSortedByName;
+
+/** Returns all registered classes sorted by their name. */
- (NSArray *)classesSortedByName;
/** Returns all registered categories sorted by their name. */
View
@@ -38,6 +38,11 @@ - (NSString *)debugDescription {
#pragma mark Helper methods
+- (NSArray *)documentsSortedByName{
+ NSArray *descriptors = [NSArray arrayWithObject:[NSSortDescriptor sortDescriptorWithKey:@"prettyNameOfDocument" ascending:YES]];
+ return [[self.documents allObjects] sortedArrayUsingDescriptors:descriptors];
+}
+
- (NSArray *)classesSortedByName {
NSArray *descriptors = [NSArray arrayWithObject:[NSSortDescriptor sortDescriptorWithKey:@"nameOfClass" ascending:YES]];
return [[self.classes allObjects] sortedArrayUsingDescriptors:descriptors];
@@ -5,6 +5,16 @@
<Name>{{projectName}}</Name>
<Path>{{indexFilename}}</Path>
<Subnodes>
+ {{#hasDocs}}
+ <Node type="folder">
+ <Name>{{strings/docset/docsTitle}}</Name>
+ <Path>{{indexFilename}}</Path>
+ <Subnodes>
+ {{#docs}}{{>NodeRef}}
+ {{/docs}}
+ </Subnodes>
+ </Node>
+ {{/hasDocs}}
{{#hasClasses}}
<Node type="folder">
<Name>{{strings/docset/classesTitle}}</Name>
@@ -39,6 +49,8 @@
</Node>
</TOC>
<Library>
+ {{#docs}}{{>Node}}
+ {{/docs}}
{{#classes}}{{>Node}}
{{/classes}}
{{#categories}}{{>Node}}
@@ -39,6 +39,17 @@ <h1 class="title title-header">{{page/title}}</h1>
{{/comment}}
</div>
{{/indexDescription}}
+
+ {{#hasDocs}}
+ <div class="index-column">
+ <h2 class="index-title">{{strings/indexPage/docsTitle}}</h2>
+ <ul>
+ {{#docs}}
+ <li><a href="{{href}}">{{title}}</a></li>
+ {{/docs}}
+ </ul>
+ </div>
+ {{/hasDocs}}
{{#hasClasses}}
<div class="index-column">

0 comments on commit 8dac774

Please sign in to comment.