@@ -43,8 +43,8 @@ to be applied and wait for the results!!
43
43
44
44
> ** Warning:** At the moment, this library is under heavy development, so it is recommended to always install
45
45
> the latest version.
46
- >
47
- > You can install _ gpt4docstrings_ via [ pip] from [ PyPI] :
46
+
47
+ You can install _ gpt4docstrings_ via [ pip] from [ PyPI] :
48
48
49
49
``` console
50
50
$ pip install -U gpt4docstrings
@@ -185,96 +185,180 @@ gpt4docstrings example/example.py -v 1 -st numpy
185
185
186
186
After it finishes documenting, we should see a new patch file on our directory called ` gpt4docstring_docstring_generator_patch.diff ` .
187
187
188
- ``` patch
189
- --- a//Users/moteroperdido/Desktop/projects/gpt4docstrings/example/example.py
190
- +++ b//Users/moteroperdido/Desktop/projects/gpt4docstrings/example/example.py
191
- @@ -2,17 +2,78 @@
192
-
193
-
194
- async def async_example():
195
- + """
196
- + An asynchronous example function.
197
- +
198
- + This function demonstrates the use of the `async` keyword and `asyncio.sleep()` to create an asynchronous delay.
199
- +
200
- + Returns
201
- + -------
202
- + None
203
- + This function does not return any value.
204
- +
205
- + Raises
206
- + ------
207
- + None
208
- + This function does not raise any exceptions.
209
- + """
210
- await asyncio.sleep(2)
211
-
212
-
213
- class MyClass:
214
-
215
- + """
216
- + A class representing MyClass.
217
- +
218
- + Parameters
219
- + ----------
220
- + value : any
221
- + The initial value for MyClass.
222
- +
223
- + Methods
224
- + -------
225
- + nested_method()
226
- + A static method that demonstrates nested functions.
227
- + """
228
- def __init__(self, value):
229
- + """
230
- + Initialize a new instance of the class.
231
- +
232
- + Parameters
233
- + ----------
234
- + value : any
235
- + The value to assign to the instance variable.
236
- +
237
- + Returns
238
- + -------
239
- + None
240
- + """
241
- self.value = value
242
-
243
- @staticmethod
244
- def nested_method():
245
- + """
246
- + Perform a nested method execution.
247
- +
248
- + This method has an inner function that is called within the outer method.
249
- +
250
- + Parameters
251
- + ----------
252
- + None
253
- +
254
- + Returns
255
- + -------
256
- + None
257
- + """
258
- def inner_function():
259
- + """
260
- + This function is an inner function with no parameters or return values.
261
- +
262
- + Raises
263
- + ------
264
- + None
265
- + This function does not raise any exceptions.
266
- + """
267
- print("Nested method inner function")
268
- print("Nested method start")
269
- inner_function()
270
- ```
271
-
272
188
To apply the patch, simply run:
273
189
274
190
``` bash
275
191
patch -p1 < gpt4docstring_docstring_generator_patch.diff
276
192
```
277
193
194
+ The result should be similar to the following (` gpt-3.5-turbo ` temperature
195
+ is set to 1, so you should expect different results every time you run the command)
196
+
197
+ ``` python
198
+ import asyncio
199
+
200
+
201
+ async def async_example ():
202
+ """
203
+ An asynchronous example function.
204
+
205
+ This function asynchronously sleeps for 2 seconds.
206
+
207
+ Returns
208
+ -------
209
+ None
210
+ This function does not return any value.
211
+ """
212
+ await asyncio.sleep(2 )
213
+
214
+
215
+ class MyClass :
216
+ """
217
+ A class representing MyClass.
218
+
219
+ Parameters
220
+ ----------
221
+ value : any
222
+ The initial value for MyClass.
223
+
224
+ Methods
225
+ -------
226
+ nested_method : static method
227
+ A nested static method within MyClass.
228
+ """
229
+ def __init__ (self , value ):
230
+ """
231
+ Initialize a new instance of the class.
232
+
233
+ Parameters
234
+ ----------
235
+ value : any
236
+ The initial value for the instance.
237
+
238
+ Returns
239
+ -------
240
+ None
241
+
242
+ Raises
243
+ ------
244
+ None
245
+ """
246
+ self .value = value
247
+
248
+ @ staticmethod
249
+ def nested_method ():
250
+ """
251
+ This static method demonstrates a nested method.
252
+
253
+ Raises
254
+ ------
255
+ None
256
+
257
+ Returns
258
+ -------
259
+ None
260
+ """
261
+ def inner_function ():
262
+ """
263
+ Inner function.
264
+
265
+ This function performs a nested method inner function.
266
+
267
+ Parameters
268
+ ----------
269
+ None
270
+
271
+ Returns
272
+ -------
273
+ None
274
+ """
275
+ print (" Nested method inner function" )
276
+
277
+ print (" Nested method start" )
278
+ inner_function()
279
+ print (" Nested method completed" )
280
+ ```
281
+
282
+ Suppose now that we want to modify the docstring type. For example,
283
+ suppose we want to use ` epytext ` style. That's very easy with
284
+ ` gpt4docstrings ` , we just need to run the same command changing the docstring style.
285
+
286
+ > Be aware that, by default, ` gpt4docstrings ` will allways generate
287
+ > docstrings for undocumented functions / classes and also translate the existing
288
+ > ones to follow the provided style. If you just want to generate docstrings (no translation),
289
+ > simply set the ` -t ` flag to ` False ` .
290
+
291
+ ``` bash
292
+ gpt4docstrings example/example.py -st epytext
293
+ ```
294
+
295
+ If we apply the patch, we'll get the previous code with the
296
+ docstrings translated:
297
+
298
+ ``` python
299
+ import asyncio
300
+
301
+
302
+ async def async_example ():
303
+ """
304
+ An asynchronous example function.
305
+
306
+ This function asynchronously sleeps for 2 seconds.
307
+
308
+ @rtype: None
309
+ @return: This function does not return any value.
310
+ """
311
+ await asyncio.sleep(2 )
312
+
313
+
314
+ class MyClass :
315
+ """
316
+ A class representing MyClass.
317
+
318
+ @type value: any
319
+ @ivar value: The initial value for MyClass.
320
+
321
+ @type nested_method: static method
322
+ @ivar nested_method: A nested static method within MyClass.
323
+ """
324
+ def __init__ (self , value ):
325
+ """
326
+ Initialize a new instance of the class.
327
+
328
+ @param value: The initial value for the instance.
329
+ @type value: any
330
+
331
+ @return: None
332
+
333
+ @raise None
334
+ """
335
+ self .value = value
336
+
337
+ @ staticmethod
338
+ def nested_method ():
339
+ """
340
+ This static method demonstrates a nested method.
341
+
342
+ @rtype: None
343
+ @return: None
344
+
345
+ @raise: None
346
+ """
347
+ def inner_function ():
348
+ """
349
+ Inner function.
350
+
351
+ This function performs a nested method inner function.
352
+
353
+ @rtype: None
354
+ """
355
+ print (" Nested method inner function" )
356
+
357
+ print (" Nested method start" )
358
+ inner_function()
359
+ print (" Nested method completed" )
360
+ ```
361
+
278
362
## Contributing
279
363
280
364
Contributions are very welcome.
0 commit comments