forked from tomaz/appledoc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMarkdownOutputGenerator.h
319 lines (256 loc) · 12.5 KB
/
MarkdownOutputGenerator.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
//
// MarkdownOutputGenerator.h
// appledoc
//
// Created by Tomaz Kragelj on 28.5.09.
// Copyright (C) 2009, Tomaz Kragelj. All rights reserved.
//
#import "XMLBasedOutputGenerator.h"
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
/** Defines a concrete @c XMLBasedOutputGenerator that generates Markdown output.
Basically this produces text files which are fairly readable for humans and can be
converted to simple HTML as a bonus (although @c XHTMLOutputGenerator is probably a
better HTML output generator solution if HTML is the desired output). See
http://daringfireball.net/projects/markdown for details on Markdown syntax.
*/
@interface MarkdownOutputGenerator : XMLBasedOutputGenerator
{
NSMutableDictionary* linkReferences;
NSString* descriptionBlockPrefix;
NSString* descriptionBlockSuffix;
NSString* descriptionBlockLinePrefix;
BOOL descriptionBlockPrefixFirstLine;
BOOL descriptionDelimitSingleParameters;
BOOL descriptionDelimitLastParameter;
BOOL descriptionMarkEmphasis;
int descriptionBlockLineCount;
}
//////////////////////////////////////////////////////////////////////////////////////////
/// @name Object member helpers
//////////////////////////////////////////////////////////////////////////////////////////
/** Appends the given member title.
@param data The data to append to.
@param item The member item to get information from.
@exception NSException Thrown if appending fails.
*/
- (void) appendObjectMemberTitleToData:(NSMutableData*) data
fromItem:(id) item;
/** Appends the given member overview description.
@param data The data to append to.
@param item The member item to get information from.
@exception NSException Thrown if appending fails.
*/
- (void) appendObjectMemberOverviewToData:(NSMutableData*) data
fromItem:(id) item;
/** Appends the given member prototype description.
@param data The data to append to.
@param item The member item to get information from.
@exception NSException Thrown if appending fails.
*/
- (void) appendObjectMemberPrototypeToData:(NSMutableData*) data
fromItem:(id) item;
/** Appends the given member section type description.
The type should be one of the following:
- @c kTKObjectMemberSectionParameters: The array of all parameters will be returned.
- @c kTKObjectMemberSectionExceptions: The array of all exceptions will be returned.
@param data The data to append to.
@param item The member item to get information from.
@param type The member section type.
@param title The desired section title.
@exception NSException Thrown if appending fails.
*/
- (void) appendObjectMemberSectionToData:(NSMutableData*) data
fromItem:(id) item
type:(int) type
title:(NSString*) title;
/** Appends the given member return description.
@param data The data to append to.
@param item The member item to get information from.
@exception NSException Thrown if appending fails.
*/
- (void) appendObjectMemberReturnToData:(NSMutableData*) data
fromItem:(id) item;
/** Appends the given member discussion description.
@param data The data to append to.
@param item The member item to get information from.
@exception NSException Thrown if appending fails.
*/
- (void) appendObjectMemberDiscussionToData:(NSMutableData*) data
fromItem:(id) item;
/** Appends the given member warning description.
@param data The data to append to.
@param item The member item to get information from.
@exception NSException Thrown if appending fails.
*/
- (void) appendObjectMemberWarningToData:(NSMutableData*) data
fromItem:(id) item;
/** Appends the given member bug description.
@param data The data to append to.
@param item The member item to get information from.
@exception NSException Thrown if appending fails.
*/
- (void) appendObjectMemberBugToData:(NSMutableData*) data
fromItem:(id) item;
/** Appends the given member see also section description.
@param data The data to append to.
@param item The member item to get information from.
@exception NSException Thrown if appending fails.
*/
- (void) appendObjectMemberSeeAlsoToData:(NSMutableData*) data
fromItem:(id) item;
/** Appends the given member declaration file description.
@param data The data to append to.
@param item The member item to get information from.
@exception NSException Thrown if appending fails.
*/
- (void) appendObjectMemberFileToData:(NSMutableData*) data
fromItem:(id) item;
//////////////////////////////////////////////////////////////////////////////////////////
/// @name Description helpers
//////////////////////////////////////////////////////////////////////////////////////////
/** Appends the brief description to the given data.
First the brief description is retreived from the given node, then the data from the
retreived nodes is converted to a proper Markdown format and is then appended to the end
of the given data.
Note that the generated output is affected by object's description variables and flags.
@c resetDescriptionVarsToDefaults() can be used to reset these to defaults. See
See @c resetDescriptionVarsToDefaults for the list of the variables and their meanings.
@param data The data to append to.
@param item The description item which brief subcsection to append.
@exception NSException Thrown if appending fails.
@see appendDetailedDescriptionToData:fromItem:
@see appendDescriptionToData:fromDescriptionItems:
@see resetDescriptionVarsToDefaults
*/
- (void) appendBriefDescriptionToData:(NSMutableData*) data
fromItem:(id) item;
/** Appends the detailed description to the given data.
First the detailed description is retreived from the given node, then the data from the
retreived nodes is converted to a proper Markdown format and is then appended to the end
of the given data.
Note that the generated output is affected by object's description variables and flags.
@c resetDescriptionVarsToDefaults() can be used to reset these to defaults. See
See @c resetDescriptionVarsToDefaults for the list of the variables and their meanings.
@param data The data to append to.
@param item The description item which detailed subcsection to append.
@exception NSException Thrown if appending fails.
@see appendBriefDescriptionToData:fromItem:
@see appendDescriptionToData:fromDescriptionItems:
@see resetDescriptionVarsToDefaults
*/
- (void) appendDetailedDescriptionToData:(NSMutableData*) data
fromItem:(id) item;
/** Converts the description data from the given paragraph to proper Markdown format and
appends it to the given data.
Note that the generated output is affected by object's description variables and flags.
@c resetDescriptionVarsToDefaults() can be used to reset these to defaults. See
See @c resetDescriptionVarsToDefaults for the list of the variables and their meanings.
@param data The data to append to.
@param items The array of description items which data to convert. If @c nil nothing happens.
@exception NSException Thrown if convertion fails.
@see appendBriefDescriptionToData:fromItem:
@see appendDetailedDescriptionToData:fromItem:
@see appendParagraphToData:fromString:
@see resetDescriptionVarsToDefaults
*/
- (void) appendDescriptionToData:(NSMutableData*) data
fromDescriptionItems:(NSArray*) items;
/** Appends the given string containing a paragraph text to the given data.
This method cleans the output and takes care of formatting the text to fit to the desired
line width. It is sent automatically from @c appendDescriptionToData:fromDescriptionItems:()
and is not meant to be used otherwise.
Note that this only appends the given paragraph text, it doesn't delimit the paragraph
with an empty line and doesn't end the paragraph with a new line either.
@param data The data to append to.
@param string The paragraph text.
@param prefix The prefix to append before each line.
@param wrap If @c YES, paragraph text should be wrapped according to wrapping options,
otherwise not.
@exception NSException Thrown if appending fails.
@see appendDescriptionToData:fromDescriptionItems:
*/
- (void) appendParagraphToData:(NSMutableData*) data
fromString:(NSString*) string
linePrefix:(NSString*) prefix
wrap:(BOOL) wrap;
/** Resets all description variables to default values.
The description variables and their default values are:
- @c descriptionDelimitSingleParameters: A boolean value indicating whether single
parameters should be delimited by a new line or not. If @c YES, all parameters are
delimited, if @c NO, parameters are delimited by a new line only if two or more are
detected. Defaults to @c YES.
- @c descriptionDelimitLastParameter: A boolean value indicating whether last parameter
should be delimited by a new line or not. Note that if this is set to @c NO, the
@c descriptionDelimitSingleParameters has no effect. Defaults to @c YES.
- @c descriptionMarkEmphasis: A boolean value indicating whether strong and emphasis
markers should be used or not. Defaults to @c YES.
@see appendBriefDescriptionToData:fromItem:
@see appendDetailedDescriptionToData:fromItem:
@see appendDescriptionToData:fromDescriptionItems:
*/
- (void) resetDescriptionVarsToDefaults;
//////////////////////////////////////////////////////////////////////////////////////////
/// @name Helper methods
//////////////////////////////////////////////////////////////////////////////////////////
/** Appends the header of the given level for the given string.
Depending of the settings, this creates properly formatted header for the given string.
Afterwards it automatically adds one empty line.
@param data The data to append to.
@param string The header string.
@param level The header level. Should be between @c 1 and @c 10.
@exception NSException Thrown if the given level is not within expected range or appending fails.
*/
- (void) appendHeaderToData:(NSMutableData*) data
forString:(NSString*) string
level:(int) level;
/** Appends the underline data for the given string.
This is mostly used for generating underlines for the titles. Note that nothing will be
output if the given @c string or @c underline are @c nil or empty strings.
@param data The data to append to.
@param string The string which should be underlines.
@param underline The underline string. Should only contain 1 char!
@exception NSException Thrown if appending fails.
*/
- (void) appendUnderlineToData:(NSMutableData*) data
forString:(NSString*) string
underline:(NSString*) underline;
/** Appends link to the given data.
Depending on the style this either appends the link ID and the reference to the footnote
or the actual link. If @c nil is passed for the reference, the method appends only the
given description. However @c description may not be @c nil in such case.
@param data The data to append to.
@param reference The link reference. May be @c nil to only use the description.
@param description The link description. May be @c nil to use the reference.
@exception NSException Thrown if the @c reference and the @c description are @c nil or
appending fails.
*/
- (void) appendLinkToData:(NSMutableData*) data
fromReference:(NSString*) reference
andDescription:(NSString*) description;
/** Appends all link footnotes to the given data.
This message should be sent after handling the file is complete and all references
are in the temporary array. This method will output the actual links as footnote
markdown style if necessary. If footnote links are disabled or there is no reference
for the current object, nothing happens.
@param data The data to append to.
@exception NSException Thrown if appending fails.
*/
- (void) appendLinkFootnotesToData:(NSMutableData*) data;
/** Formats a link from the given data.
Depending on the style this either formats the link as the reference to the footnote or
the actual link. If @c nil is passed for the reference, the method appends only the
given description. However @c description may not be @c nil in such case.
Note that if the given reference points to the object's member, the link is not generated.
Instead only the member name is emmited.
Note that in case footnote style is used, the receiver's footnote index is automatically
incremented if necessary.
@param reference The link reference. May be @c nil to only use the description.
@param description The link description. May be @c nil to use the reference.
@return Returns the formatted link.
@exception NSException Thrown if the @c reference and the @c description are @c nil or
appending fails.
*/
- (NSString*) formatLinkFromReference:(NSString*) reference
andDescription:(NSString*) description;
@end