Permalink
Browse files

Added support for browsing documentation set class hierarchy within t…

…he Xcode documentation window.
  • Loading branch information...
1 parent fe4e023 commit e6cf82be21a3cbb15915cb17b01c47de279b807c @tomaz committed Jun 5, 2009
Showing with 79 additions and 2 deletions.
  1. +15 −0 DoxygenConverter+DocSet.h
  2. +56 −0 DoxygenConverter+DocSet.m
  3. +8 −2 DoxygenConverter.h
View
15 DoxygenConverter+DocSet.h
@@ -50,6 +50,7 @@ This message is automatically sent from @c DoxygenConverter::convert() in the pr
@see createDocSetSourcePlistFile
@see createDocSetTokesFile
@see createDocSetBundle
+@see addDocSetNodeToElement:fromHierarchyData:
*/
- (void) createDocSetNodesFile;
@@ -83,4 +84,18 @@ This message is automatically sent from @c DoxygenConverter::convert() in the pr
*/
- (void) createDocSetBundle;
+/** Adds a new DocSet node as the child of the given parent element.
+
+The given hierarchy data contains the description of the node to add. The added node is
+either of the type folder if it contains children or it is a leaf otherwise. The methods
+will recursively add all subnodes as well.
+
+@param parent The Nodes.xml element to which to add new node.
+@param data The hierarchy object data that describes the node.
+@exception NSException Thrown if adding fails.
+@see createDocSetNodesFile
+*/
+- (void) addDocSetNodeToElement:(NSXMLElement*) parent
+ fromHierarchyData:(NSDictionary*) data;
+
@end
View
56 DoxygenConverter+DocSet.m
@@ -145,6 +145,25 @@ - (void) createDocSetNodesFile
}
}
+ // At the end of the directories create class hierarchy.
+ NSXMLElement* hierarchyNodeElement = [NSXMLNode elementWithName:@"Node"];
+ [hierarchyNodeElement addAttribute:[NSXMLNode attributeWithName:@"type" stringValue:@"folder"]];
+ [indexSubnodesElement addChild:hierarchyNodeElement];
+ NSXMLElement* hierarchyNameElement = [NSXMLNode elementWithName:@"Name" stringValue:@"Class hierarchy"];
+ [hierarchyNodeElement addChild:hierarchyNameElement];
+ NSXMLElement* hierarchyPathElement = [NSXMLNode elementWithName:@"Path" stringValue:@"hierarchy.html"];
+ [hierarchyNodeElement addChild:hierarchyPathElement];
+ NSXMLElement* hierarchySubnodesElement = [NSXMLNode elementWithName:@"Subnodes"];
+ [hierarchyNodeElement addChild:hierarchySubnodesElement];
+
+ // Scan for all classes in the hierarchy.
+ NSMutableDictionary* hierarchies = [database objectForKey:kTKDataMainHierarchiesKey];
+ for (NSString* objectName in hierarchies)
+ {
+ NSDictionary* hierarchyData = [hierarchies objectForKey:objectName];
+ [self addDocSetNodeToElement:hierarchySubnodesElement fromHierarchyData:hierarchyData];
+ }
+
// Save the document.
NSError* error = nil;
NSString* filename = [cmd.outputDocSetResourcesPath stringByAppendingPathComponent:@"Nodes.xml"];
@@ -354,4 +373,41 @@ - (void) createDocSetBundle
logInfo(@"Finished creating DocSet bundle.");
}
+//----------------------------------------------------------------------------------------
+- (void) addDocSetNodeToElement:(NSXMLElement*) parent
+ fromHierarchyData:(NSDictionary*) data
+{
+ NSDictionary* children = [data objectForKey:kTKDataHierarchyChildrenKey];
+ NSDictionary* objectData = [data objectForKey:kTKDataHierarchyObjectDataKey];
+ NSString* objectName = [data objectForKey:kTKDataHierarchyObjectNameKey];
+ NSString* objectPath = [objectData objectForKey:kTKDataObjectRelPathKey];
+ if (!objectPath) objectPath = @"hierarchy.html";
+
+ // Create the main node that will represent the object.
+ NSXMLElement* node = [NSXMLNode elementWithName:@"Node"];
+ [parent addChild:node];
+
+ // Create the name and path subnodes. Note that the path will be the main hierarchy
+ // index file if the node is not documented.
+ NSXMLElement* nameElement = [NSXMLNode elementWithName:@"Name" stringValue:objectName];
+ [node addChild:nameElement];
+ NSXMLElement* pathElement = [NSXMLNode elementWithName:@"Path" stringValue:objectPath];
+ [node addChild:pathElement];
+
+ // If there are children, set the node type to folder and add subnodes.
+ if ([children count] > 0)
+ {
+ [node addAttribute:[NSXMLNode attributeWithName:@"type" stringValue:@"folder"]];
+
+ NSXMLElement* subnodesElement = [NSXMLNode elementWithName:@"Subnodes"];
+ [node addChild:subnodesElement];
+
+ for (NSString* childName in children)
+ {
+ NSDictionary* childHierarchyData = [children objectForKey:childName];
+ [self addDocSetNodeToElement:subnodesElement fromHierarchyData:childHierarchyData];
+ }
+ }
+}
+
@end
View
10 DoxygenConverter.h
@@ -69,10 +69,16 @@ is a standard @c NSDictionary of the following layout:
- @c "Hierarchy" key: contains a @c NSXMLDocument with clean hierarchy XML.
- @c "Hierarchies" key: contains a @c NSMutableDictionary with classes hierarchy tree.
- @c "<ObjectName>" key: contains a @c NSMutableDictionary describing the object:
+ - @c "ObjectName" key: contains the object name. This is the same name as used
+ for the key in the parent dictionary. It still serves a purpose for the
+ non-documented objects which are part of the hierarchy - for there we can't
+ use the @c "ObjectData" key since we have no entry...
- @c "ObjectData" key: contains a pointer to the object's data under the main
- @c "Objects" key list.
+ @c "Objects" key list. Note that this is @c nil if the object is not
+ documented.
- @c "Children" key: contains a @c NSMutableDictionary with all children of
- this object. The dictionary has the same structure as the main @c "Hierarchy"
+ this object. If the object doesn't have any children, empty dictionary is
+ used. The dictionary has the same structure as the main @c "Hierarchies"
dictionary:
- @c "<ObjectName>"...
- ...

0 comments on commit e6cf82b

Please sign in to comment.