forked from tomaz/appledoc
/
XMLOutputGenerator.h
406 lines (329 loc) · 17.3 KB
/
XMLOutputGenerator.h
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
//
// XMLOutputGenerator.h
// appledoc
//
// Created by Tomaz Kragelj on 11.6.09.
// Copyright (C) 2009, Tomaz Kragelj. All rights reserved.
//
#import "OutputGenerator.h"
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
/** Defines a concrete @c OutputGenerator which generates clean XML documentation.
The generator depends on @c DoxygenOutputGenerator output. It scans the doxygen XML
documentation and converts it to a cleaner XML which can be used for easier processing
by other generators. The generator also fixes member or inter-objects links and other
Objective-C specifics which are missed or not supported by doxygen.
*/
@interface XMLOutputGenerator : OutputGenerator
{
id<OutputInfoProvider> doxygenInfoProvider;
}
//////////////////////////////////////////////////////////////////////////////////////////
/// @name Clean XML handling
//////////////////////////////////////////////////////////////////////////////////////////
/** Creates clean object XML markups.
This method scans the doxygen XML output. For each file it checks if it contains
a known object (by testing the file name) and that the file is documented. For each
known documented file, it adds the original markup in the form of the @c NSXMLParser
to the @c data dictionary. The key of the dictionary is the name of the described
object.
Note that this method doesn't save the clean XML file yet, it only prepares the
proper name including full path and adds all the data, including cleaned XML tree
into the database. Until the utility finishes working, it works on in-memory XML
representation and only save after all steps are finished.
This message is automatically sent from @c generateSpecificOutput() in the proper order.
It is not designed to be sent manually from the clients.
@exception NSException Thrown if convertion fails.
@see mergeCleanCategoriesToKnownObjects
@see updateCleanObjectsDatabase
@see createCleanIndexDocumentationFile
@see createCleanHierarchyDocumentationFile
@see fixCleanObjectDocumentation
@see saveCleanObjectDocumentationFiles
*/
- (void) createCleanObjectDocumentationMarkup;
/** Merges known object categories to their parent objects is desired.
The categories can either be merged into single sections, or their sections may be
preserved, based on the user command line options or global parameters.
@exception NSException Thrown if convertion fails.
@see createCleanObjectDocumentationMarkup
@see updateCleanObjectsDatabase
@see createCleanIndexDocumentationFile
@see createCleanHierarchyDocumentationFile
@see fixCleanObjectDocumentation
@see saveCleanObjectDocumentationFiles
*/
- (void) mergeCleanCategoriesToKnownObjects;
/** Updates clean objects XML database by integrating data dependent on the XML itself.
This message needs to be sent after @c mergeCleanCategoriesToKnownObjects() and
before @c fixCleanObjectDocumentation(). It handles the following:
- Creation of object members database entries.
@exception NSException Thrown if conversion fails.
@see createCleanObjectDocumentationMarkup
@see mergeCleanCategoriesToKnownObjects
@see createCleanIndexDocumentationFile
@see createCleanHierarchyDocumentationFile
@see fixCleanObjectDocumentation
@see saveCleanObjectDocumentationFiles
@see createMembersDataForObject:objectData:
*/
- (void) updateCleanObjectsDatabase;
/** Creates clean index XML file.
This method uses the data generated by the @c createCleanObjectDocumentationMarkup() and
creates the index file, so it is required that @c createCleanObjectDocumentationMarkup()
is sent to the receiver before sending this message!
This message is automatically sent from @c generateSpecificOutput() in the proper order.
It is not designed to be sent manually from the clients.
@exception NSException Thrown if index file creation fails.
@see createCleanObjectDocumentationMarkup
@see mergeCleanCategoriesToKnownObjects
@see updateCleanObjectsDatabase
@see createCleanHierarchyDocumentationFile
@see createCleanHierarchyDocumentationFile
@see fixCleanObjectDocumentation
@see saveCleanObjectDocumentationFiles
*/
- (void) createCleanIndexDocumentationFile;
/** Creates clean hieararchy XML file.
This method uses the data generated by the @c createCleanObjectDocumentationMarkup() and
creates the hierarchy file, so it is required that @c createCleanObjectDocumentationMarkup()
is sent to the receiver before sending this message!
This message is automatically sent from @c generateSpecificOutput() in the proper order.
It is not designed to be sent manually from the clients.
@exception NSException Thrown if index file creation fails.
@see createCleanObjectDocumentationMarkup
@see mergeCleanCategoriesToKnownObjects
@see updateCleanObjectsDatabase
@see createCleanIndexDocumentationFile
@see fixCleanObjectDocumentation
@see saveCleanObjectDocumentationFiles
@see createHierarchyDataForObject:withinNode:
*/
- (void) createCleanHierarchyDocumentationFile;
/** Fixes the clean object XML documentation.
This method will scan through all XML files generated in @c createCleanObjectDocumentationMarkup()
and will fix all things cannot be (easily) treated by the xslt. Note that this method
will not do any fixing or convertion itself. Instead it will scan through all documented
objects and will pass each one to the "child" methods that will do the actual work. The
methods that get called are:
- @c fixInheritanceForObject:objectData:objects:().
- @c fixReferencesForObject:objectData:objects:().
- @c fixParaLinksForObject:objectData:objects:().
- @c fixEmptyParaForObject:objectData:objects:().
This message is automatically sent from @c generateSpecificOutput() in the proper order.
It is not designed to be sent manually from the clients.
@exception NSException Thrown if fixing XML fails.
@see createCleanObjectDocumentationMarkup
@see mergeCleanCategoriesToKnownObjects
@see updateCleanObjectsDatabase
@see createCleanIndexDocumentationFile
@see createCleanHierarchyDocumentationFile
@see saveCleanObjectDocumentationFiles
*/
- (void) fixCleanObjectDocumentation;
/** Saved clean object XML markups to proper files.
This method will save all clean XML markups in the database to proper files.
This message is automatically sent from @c generateSpecificOutput() in the proper order.
It is not designed to be sent manually from the clients.
@exception NSException Thrown if saving fails.
@see createCleanObjectDocumentationMarkup
@see mergeCleanCategoriesToKnownObjects
@see updateCleanObjectsDatabase
@see createCleanIndexDocumentationFile
@see createCleanHierarchyDocumentationFile
@see fixCleanObjectDocumentation
*/
- (void) saveCleanObjectDocumentationFiles;
//////////////////////////////////////////////////////////////////////////////////////////
/// @name Clean XML "makeup" handling
//////////////////////////////////////////////////////////////////////////////////////////
/** Creates the members entry within the given object data.
This scans the actual object document and extracts all members data which is later used
when handling references. Note that this should be sent only after categories are merged
so that the correct data is used for generation.
This message is automatically sent from @c updateCleanObjectsDatabase for each documented
object and should not be sent otherwise. It is used to simplify otherwise large and
difficult to manage parent method.
@param objectName The name of the object for which we should create members.
@param objectData The data of the object into which to create the members.
@exception NSException Thrown if creation fails.
@see updateCleanObjectsDatabase
*/
- (void) createMembersDataForObject:(NSString*) objectName
objectData:(NSMutableDictionary*) objectData;
/** Creates the given object's hierarchy clean XML inside the given node.
The method will recursively handle all object's children as well. It is sent from
@c createCleanHierarchyDocumentationFile() for each root level node. It should not
be used otherwise.
@param objectHierarchyData The object's @c NSDictionary from the hierarchies data.
@param node The @c NSXMLElement parent within which to create the given object's nodes.
@exception NSException Thrown if creation fails.
*/
- (void) createHierarchyDataForObject:(NSDictionary*) objectHierarchyData
withinNode:(NSXMLElement*) node;
/** Fixes inheritance links for the given object.
This fixes base class and protocols links. If the base class or protocol is one of the
known objects, the link reference is added to the clean document. Additionally, all
protocol @c <base> nodes are renamed to @c <conforms> so that the html creation is
easier later on. This is also where full hierarchy for classes is generated (note that
this relies on the data generated by @c createCleanHierarchyDocumentationFile(), so
this message should be sent afterwards).
This message is sent automatically from @c fixCleanObjectDocumentation() and should not
be sent otherwise. It is used to simplify otherwise large and difficult to manage parent
method.
@param objectName The name of the object that should be fixed.
@param objectData The data of the object that should be fixed.
@param objects The dictionary of all objects.
@exception NSException Thrown if fixing fails.
@see fixLocationForObject:objectData:objects:
@see fixReferencesForObject:objectData:objects:
@see fixParaLinksForObject:objectData:objects:
@see fixEmptyParaForObject:objectData:objects:
*/
- (void) fixInheritanceForObject:(NSString*) objectName
objectData:(NSMutableDictionary*) objectData
objects:(NSDictionary*) objects;
/** Fixes location for classes if necessary.
For some reason doxygen uses a location of one of the class categories for the class
itself if the categories are defined in separate files. This is where we fix such links.
Note that this should optionally be enabled in @c CommandLineParser.
This message is sent automatically from @c fixCleanObjectDocumentation() and should not
be sent otherwise. It is used to simplify otherwise large and difficult to manage parent
method.
@param objectName The name of the object that should be fixed.
@param objectData The data of the object that should be fixed.
@param objects The dictionary of all objects.
@exception NSException Thrown if fixing fails.
@see fixInheritanceForObject:objectData:objects:
@see fixReferencesForObject:objectData:objects:
@see fixParaLinksForObject:objectData:objects:
@see fixEmptyParaForObject:objectData:objects:
*/
- (void) fixLocationForObject:(NSString*) objectName
objectData:(NSMutableDictionary*) objectData
objects:(NSDictionary*) objects;
/** Fixes doxygen references links for the given object.
This updates all doxygen created references specified by @c <ref> tag so that their
reference points to the correct file and/or member. The result is that all @c <ref>
nodes now have correct references prepared for the html generation later on.
This message is sent automatically from @c fixCleanObjectDocumentation() and should not
be sent otherwise. It is used to simplify otherwise large and difficult to manage parent
method.
@param objectName The name of the object that should be fixed.
@param objectData The data of the object that should be fixed.
@param objects The dictionary of all objects.
@exception NSException Thrown if fixing fails.
@see fixInheritanceForObject:objectData:objects:
@see fixLocationForObject:objectData:objects:
@see fixParaLinksForObject:objectData:objects:
@see fixEmptyParaForObject:objectData:objects:
*/
- (void) fixReferencesForObject:(NSString*) objectName
objectData:(NSMutableDictionary*) objectData
objects:(NSDictionary*) objects;
/** Fixes all objective-c links ignored by doxygen for the given object.
This will actually check all description paragraphs and scan word by word to see if a
known object is being addressed. If so, it will convert the word to the proper @c <ref>
tag. Therefore all links to classes, protocols and categories are properly handled.
In addition, the code will also convert any word that starts with @c :: or ends with @c ()
to a @c <ref> for the given member. The code will not check if a member with that name
exists or not though, so some care needs to be taken when documenting code...
Further more, doxygen incorrectly handles links to category members and doesn't detect
links to unknown classes. These are also properly detected and converted here.
This message is sent automatically from @c fixCleanObjectDocumentation() and should not
be sent otherwise. It is used to simplify otherwise large and difficult to manage parent
method.
@param objectName The name of the object that should be fixed.
@param objectData The data of the object that should be fixed.
@param objects The dictionary of all objects.
@exception NSException Thrown if fixing fails.
@see fixInheritanceForObject:objectData:objects:
@see fixLocationForObject:objectData:objects:
@see fixReferencesForObject:objectData:objects:
@see fixEmptyParaForObject:objectData:objects:
*/
- (void) fixParaLinksForObject:(NSString*) objectName
objectData:(NSMutableDictionary*) objectData
objects:(NSDictionary*) objects;
/** Fixes all empty paragraphs in the documentation for the given object.
Doxygen leaves some paragraphs with only spaces inside. We will delete all such "hanging"
paragraps to get nicer looking documentation. If the user prevented deletion through
@c --no-empty-para command line, this method will not do anything.
This message is sent automatically from @c fixCleanObjectDocumentation() and should not
be sent otherwise. It is used to simplify otherwise large and difficult to manage parent
method.
@param objectName The name of the object that should be fixed.
@param objectData The data of the object that should be fixed.
@param objects The dictionary of all objects.
@exception NSException Thrown if fixing fails.
@see fixInheritanceForObject:objectData:objects:
@see fixLocationForObject:objectData:objects:
@see fixReferencesForObject:objectData:objects:
@see fixParaLinksForObject:objectData:objects:
*/
- (void) fixEmptyParaForObject:(NSString*) objectName
objectData:(NSMutableDictionary*) objectData
objects:(NSDictionary*) objects;
//////////////////////////////////////////////////////////////////////////////////////////
/// @name Helper methods
//////////////////////////////////////////////////////////////////////////////////////////
/** Fetches the link data for the given object and member name.
@param objectName The name of the object.
@param memberName The name of the object's member.
@return Returns the @c NSDictionary from the database corresponding to the given object
member data. Returns @c nil if either object or member is not found.
@see objectLinkNameForObject:andMember:
@see memberLinkNameForObject:andMember:
*/
- (NSDictionary*) linkDataForObject:(NSString*) objectName
andMember:(NSString*) memberName;
/** Generates the link name for inter-object link.
@param objectName The name of the object.
@param memberName The name of the object's member.
@return Returns the given link name.
@see linkDataForObject:andMember:
@see memberLinkNameForObject:andMember:
*/
- (NSString*) objectLinkNameForObject:(NSString*) objectName
andMember:(NSString*) memberName;
/** Generates the link name for a member link.
@param objectName The name of the object.
@param memberName The name of the object's member.
@return Returns the given link name.
@see linkDataForObject:andMember:
@see objectLinkNameForObject:andMember:
*/
- (NSString*) memberLinkNameForObject:(NSString*) objectName
andMember:(NSString*) memberName;
/** Prepares the link to the given destination object.
The link is prepared for the given @c source object's reference to the given @c destination
object. If the two objects are found in the same subdirectory, the destination file name
is returned. Otherwise the relative link to the destination's file is returned. The
returned link already contains the required html extension.
@param source The object which is reffering to @c destination objecy.
@param destination The object to which the @c object is reffering.
@return Returns the required link, including relative path if necessary.
*/
- (NSString*) objectReferenceFromObject:(NSString*) source
toObject:(NSString*) destination;
/** Generates obsfucated string from the given one.
This is used internally while fixing broken links. The obsfucation is only temporary and
is removed before creating final text. It is not meant to hide contents from human eye
or web robots.
@param string The string to obsfucate.
@return Returns obsfucated string.
*/
- (NSString*) obsfucatedStringFromString:(NSString*) string;
//////////////////////////////////////////////////////////////////////////////////////////
/// @name Properties
//////////////////////////////////////////////////////////////////////////////////////////
/** Sets or returns the @c OutputInfoProvider conformer that provides information about
doxygen files.
This value is used to determine the path to the doxygen XML files. It is used to enumerate
the list of all objects and convert the doxygen XML to clean XML which is later as a
foundation for generating usable output by the rest of the output generators.
@warning Clients need to set this before starting output generation. If they fail to
provide a valid object, generation immediately fails with an exception.
*/
@property(retain) id<OutputInfoProvider> doxygenInfoProvider;
@end