Skip to content

Commit 94e6e3b

Browse files
committed
Update documentation format, fix #6.
1 parent bdc3dde commit 94e6e3b

File tree

5 files changed

+52
-45
lines changed

5 files changed

+52
-45
lines changed

STNetTaskQueue/STHTTPNetTask.h

+15-15
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
FOUNDATION_EXPORT NSString *const STHTTPNetTaskServerError;
1313
FOUNDATION_EXPORT NSString *const STHTTPNetTaskResponseParsedError;
1414

15-
// Error "userInfo" key
15+
// Error "userInfo" keys
1616
FOUNDATION_EXPORT NSString *const STHTTPNetTaskErrorStatusCodeUserInfoKey;
1717
FOUNDATION_EXPORT NSString *const STHTTPNetTaskErrorResponseDataUserInfoKey;
1818

@@ -39,12 +39,12 @@ typedef NS_ENUM(NSUInteger, STHTTPNetTaskResponseType) {
3939
STHTTPNetTaskResponseRawData
4040
};
4141

42-
/*
42+
/**
4343
If a class conforms to this protocol, it means the instance of this class will be converted to a dictionary and passed as parameter in a HTTP request.
4444
*/
4545
@protocol STHTTPNetTaskRequestObject <NSObject>
4646

47-
/*
47+
/**
4848
Properties which should be ignored when packing parameters for reqeust.
4949
5050
@return NSArray An array of strings representing the name of properties to be ignored.
@@ -53,7 +53,7 @@ typedef NS_ENUM(NSUInteger, STHTTPNetTaskResponseType) {
5353

5454
@optional
5555

56-
/*
56+
/**
5757
Separator string which should be used when packing parameters.
5858
E.g. property schoolName will be converted to school_name.
5959
Default: @"_"
@@ -64,76 +64,76 @@ typedef NS_ENUM(NSUInteger, STHTTPNetTaskResponseType) {
6464

6565
@end
6666

67-
/*
67+
/**
6868
Net task which is designed for HTTP protocol.
6969
*/
7070
@interface STHTTPNetTask : STNetTask<STHTTPNetTaskRequestObject>
7171

72-
/*
72+
/**
7373
HTTP method which should be used for the HTTP net task.
7474
7575
@return STHTTPNetTaskMethod
7676
*/
7777
- (STHTTPNetTaskMethod)method;
7878

79-
/*
79+
/**
8080
Request parameters format. E.g JSON, key-value string(form param).
8181
8282
@return STHTTPNetTaskRequestType
8383
*/
8484
- (STHTTPNetTaskRequestType)requestType;
8585

86-
/*
86+
/**
8787
Response data format. E.g JSON, String, Raw data.
8888
8989
@return STHTTPNetTaskResponseType
9090
*/
9191
- (STHTTPNetTaskResponseType)responseType;
9292

93-
/*
93+
/**
9494
Custom headers which will be added into HTTP request headers.
9595
9696
@return NSDictionary<NSString, NSString> Custom headers, e.g. @{ @"User-Agent": @"STNetTaskQueue Client" }
9797
*/
9898
- (NSDictionary *)headers;
9999

100-
/*
100+
/**
101101
Additional parameters which will be added as HTTP request parameters.
102102
103103
@return NSDictionary<NSString, id>
104104
*/
105105
- (NSDictionary *)parameters;
106106

107-
/*
107+
/**
108108
NSDatas which will be added into multi-part form data body,
109109
requestType should be STHTTPNetTaskRequestFormData if you are going to return datas.
110110
111111
@return NSDictionary<NSString, NSData>
112112
*/
113113
- (NSDictionary *)datas;
114114

115-
/*
115+
/**
116116
This method will be called if the response object is a dictionary.
117117
118118
@param dictionary NSDictionary
119119
*/
120120
- (void)didResponseDictionary:(NSDictionary *)dictionary;
121121

122-
/*
122+
/**
123123
This method will be called if the response object is an array.
124124
125125
@param array NSArray
126126
*/
127127
- (void)didResponseArray:(NSArray *)array;
128128

129-
/*
129+
/**
130130
This method will be called if the response obejct is a string.
131131
132132
@param string NSString
133133
*/
134134
- (void)didResponseString:(NSString *)string;
135135

136-
/*
136+
/**
137137
This method will be called if the response object is NSData
138138
139139
@param data NSData

STNetTaskQueue/STHTTPNetTaskQueueHandler.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@
1010

1111
@interface STHTTPNetTaskQueueHandler : NSObject<STNetTaskQueueHandler>
1212

13-
/*
13+
/**
1414
Init the handler with base URL, a base URL will be used for constructing the whole url for HTTP net tasks.
1515
E.g HTTP net task returns uri "user/profile", handled by handler with baseURL "http://example.com", the whole url will be http://example.com/user/profile".
1616
1717
@param baseURL NSURL
1818
*/
1919
- (instancetype)initWithBaseURL:(NSURL *)baseURL;
2020

21-
/*
21+
/**
2222
Init the handler with baseURL and NSURLSessionConfiguration.
2323
2424
@param baseURL NSURL

STNetTaskQueue/STNetTask.h

+20-14
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ FOUNDATION_EXPORT NSString *const STNetTaskUnknownError;
3030

3131
@protocol STNetTaskDelegate <NSObject>
3232

33-
/*
33+
/**
3434
This delegate method will be called when the net task is finished(no matter it's successful or failed).
3535
If the net task is failed, task.error will be non-nil.
3636
@@ -50,63 +50,69 @@ typedef void (^STNetTaskSubscriptionBlock)();
5050

5151
@interface STNetTask : NSObject
5252

53-
/* Error object which contains error message when net task is failed. */
53+
/**
54+
Error object which contains error message when net task is failed.
55+
*/
5456
@property (atomic, strong) NSError *error;
5557

56-
/*
58+
/**
5759
Indicates if the net task is waiting for executing or executing.
5860
This value will be set to "YES" immediately after the net task is added to net task queue.
5961
*/
6062
@property (atomic, assign, readonly) BOOL pending;
6163

62-
/*
64+
/**
6365
Indicates if the net task is cancelled.
6466
This value would be "NO" by default after net task is created, even the net task is not added to queue.
6567
*/
6668
@property (atomic, assign, readonly) BOOL cancelled;
6769

68-
/* Indicates if the net task is finished(no matter it's successful or failed). */
70+
/**
71+
Indicates if the net task is finished(no matter it's successful or failed).
72+
*/
6973
@property (atomic, assign, readonly) BOOL finished;
7074

71-
/* The current retry time @see maxRetryCount */
75+
/**
76+
The current retry time @see maxRetryCount
77+
*/
7278
@property (atomic, assign, readonly) NSUInteger retryCount;
7379

74-
/*
80+
/**
7581
A unique string represents the net task.
7682
7783
@return NSString The uri string.
7884
*/
7985
- (NSString *)uri;
8086

81-
/*
87+
/**
8288
A callback method which is called when the net task is finished successfully.
8389
Note: this method will be called in thread of STNetTaskQueue.
8490
8591
@param response id The response object.
8692
*/
8793
- (void)didResponse:(id)response;
8894

89-
/*
95+
/**
9096
A callback method which is called when the net task is failed.
9197
Note: this method will be called in thread of STNetTaskQueue.
9298
*/
9399
- (void)didFail;
94100

95-
/*
101+
/**
96102
A callback method which is called when the net task is retried.
97103
Note: this method will be called in thread of STNetTaskQueue.
98104
*/
99105
- (void)didRetry;
100106

101-
/*
107+
/**
102108
Indicates how many times the net task should be retried after failed.
103109
Default 0.
104110
105111
@return NSUInteger
106112
*/
107113
- (NSUInteger)maxRetryCount;
108114

109-
/*
115+
/**
110116
If you are going to retry the net task only when specific error is returned, return NO in this method.
111117
Default YES.
112118
@@ -115,14 +121,14 @@ typedef void (^STNetTaskSubscriptionBlock)();
115121
*/
116122
- (BOOL)shouldRetryForError:(NSError *)error;
117123

118-
/*
124+
/**
119125
Indicates how many seconds should be delayed before retrying the net task.
120126
121127
@return NSTimeInterval
122128
*/
123129
- (NSTimeInterval)retryInterval;
124130

125-
/*
131+
/**
126132
Subscribe state of net task by using block
127133
128134
@param state STNetTaskState state of net task

STNetTaskQueue/STNetTaskQueue.h

+15-13
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ FOUNDATION_EXPORT const unsigned char STNetTaskQueueVersionString[];
1919

2020
@protocol STNetTaskQueueHandler <NSObject>
2121

22-
/*
22+
/**
2323
STNetTaskQueue will call this method when a net task is added to queue and become ready to be excecuted.
2424
2525
@param netTaskQueue STNetTaskQueue The net task queue which is holding the net task.
2626
@param task STNetTask The net task which is ready to be executed.
2727
*/
2828
- (void)netTaskQueue:(STNetTaskQueue *)netTaskQueue handleTask:(STNetTask *)task;
2929

30-
/*
30+
/**
3131
STNetTaskQueue will call this method when a net task is cancelled and removed from net task queue.
3232
Giving a chance to the handler to do a clean up for the cancelled net task.
3333
@@ -36,7 +36,7 @@ FOUNDATION_EXPORT const unsigned char STNetTaskQueueVersionString[];
3636
*/
3737
- (void)netTaskQueue:(STNetTaskQueue *)netTaskQueue didCancelTask:(STNetTask *)task;
3838

39-
/*
39+
/**
4040
STNetTaskQueue will call this method when the net task queue is deallocated.
4141
4242
@param netTaskQueue STNetTaskQueue The net task queue which is deallocated.
@@ -47,21 +47,23 @@ FOUNDATION_EXPORT const unsigned char STNetTaskQueueVersionString[];
4747

4848
@interface STNetTaskQueue : NSObject
4949

50-
/* The STNetTaskQueueHandler which is used for handling the net tasks in queue. */
50+
/**
51+
The STNetTaskQueueHandler which is used for handling the net tasks in queue.
52+
*/
5153
@property (nonatomic, strong) id<STNetTaskQueueHandler> handler;
5254

53-
/*
55+
/**
5456
Count of Max concurrent task in a queue.
5557
If the number of unfinished tasks in queue hits the max count, upcoming task will be processed till one of the unfinished task is done.
5658
*/
5759
@property (nonatomic, assign) NSUInteger maxConcurrentTasksCount;
5860

59-
/*
61+
/**
6062
A shared STNetTaskQueue instance.
6163
*/
6264
+ (instancetype)sharedQueue;
6365

64-
/*
66+
/**
6567
Add a net task into the net task queue.
6668
The net task may not be executed immediately depends on the "maxConcurrentTasksCount",
6769
but the net task will be marked as "pending" anyway.
@@ -70,15 +72,15 @@ FOUNDATION_EXPORT const unsigned char STNetTaskQueueVersionString[];
7072
*/
7173
- (void)addTask:(STNetTask *)task;
7274

73-
/*
75+
/**
7476
Cancel and remove the net task from queue.
7577
If the net task is executing, it will be cancelled and remove from the queue without calling the "netTaskDidEnd" delegate method.
7678
7779
@param task STNetTask The net task to be cancelled and removed from the queue.
7880
*/
7981
- (void)cancelTask:(STNetTask *)task;
8082

81-
/*
83+
/**
8284
This method should be called when the "handler" finish handling the net task successfully.
8385
After "handler" called this method, the net task will be marked as "finished", set "pending" as "NO", and removed from the queue.
8486
@@ -87,7 +89,7 @@ FOUNDATION_EXPORT const unsigned char STNetTaskQueueVersionString[];
8789
*/
8890
- (void)task:(STNetTask *)task didResponse:(id)response;
8991

90-
/*
92+
/**
9193
This method should be caled when the "handler" finish handling the net task with error.
9294
After "hadnler" called this method, the net task will be marked as "finished", set "pending" as "NO", and removed from the queue.
9395
@@ -96,7 +98,7 @@ FOUNDATION_EXPORT const unsigned char STNetTaskQueueVersionString[];
9698
*/
9799
- (void)task:(STNetTask *)task didFailWithError:(NSError *)error;
98100

99-
/*
101+
/**
100102
Add a net task delegate to "STNetTaskQueue" with uri of the net task,
101103
it's a weak reference and duplicated delegate with same uri will be ignored.
102104
@@ -105,7 +107,7 @@ FOUNDATION_EXPORT const unsigned char STNetTaskQueueVersionString[];
105107
*/
106108
- (void)addTaskDelegate:(id<STNetTaskDelegate>)delegate uri:(NSString *)uri;
107109

108-
/*
110+
/**
109111
Add a net task delegate to "STNetTaskQueue" with class of net task,
110112
it's a weak reference and duplicated delegate with same class will be ignored.
111113
@@ -114,7 +116,7 @@ FOUNDATION_EXPORT const unsigned char STNetTaskQueueVersionString[];
114116
*/
115117
- (void)addTaskDelegate:(id<STNetTaskDelegate>)delegate class:(Class)clazz;
116118

117-
/*
119+
/**
118120
Most of the times you don't need to remove net task delegate explicitly,
119121
because "STNetTaskQueue" holds weak reference of each delegate.
120122

STNetTaskQueueTest/STNetTaskQueueTest/STNetTaskQueueTestHTTP.m

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
//
77
//
88

9-
#import <UIKit/UIKit.h>
109
#import <XCTest/XCTest.h>
1110
#import <STNetTaskQueue/STNetTaskQueue.h>
1211
#import "STTestRetryNetTask.h"

0 commit comments

Comments
 (0)