@@ -224,45 +224,55 @@ def __doc__(self):
224
224
opts_list = opts_list )
225
225
226
226
_get_option_tmpl = """
227
- get_option(pat) - Retrieves the value of the specified option
227
+ get_option(pat)
228
+
229
+ Retrieves the value of the specified option.
228
230
229
231
Available options:
232
+
230
233
{opts_list}
231
234
232
235
Parameters
233
236
----------
234
- pat - str/regexp which should match a single option.
235
-
236
- Note: partial matches are supported for convenience, but unless you use the
237
- full option name (e.g. x.y.z.option_name), your code may break in future
238
- versions if new options with similar names are introduced.
237
+ pat : str
238
+ Regexp which should match a single option.
239
+ Note: partial matches are supported for convenience, but unless you use the
240
+ full option name (e.g. x.y.z.option_name), your code may break in future
241
+ versions if new options with similar names are introduced.
239
242
240
243
Returns
241
244
-------
242
- result - the value of the option
245
+ result : the value of the option
243
246
244
247
Raises
245
248
------
246
- OptionError if no such option exists
249
+ OptionError : if no such option exists
250
+
251
+ Notes
252
+ -----
253
+ The available options with its descriptions:
247
254
248
255
{opts_desc}
249
256
"""
250
257
251
258
_set_option_tmpl = """
252
- set_option(pat,value) - Sets the value of the specified option
259
+ set_option(pat, value)
260
+
261
+ Sets the value of the specified option.
253
262
254
263
Available options:
264
+
255
265
{opts_list}
256
266
257
267
Parameters
258
268
----------
259
- pat - str/regexp which should match a single option.
260
-
261
- Note: partial matches are supported for convenience, but unless you use the
262
- full option name (e.g. x.y.z.option_name), your code may break in future
263
- versions if new options with similar names are introduced.
264
-
265
- value - new value of option.
269
+ pat : str
270
+ Regexp which should match a single option.
271
+ Note: partial matches are supported for convenience, but unless you use the
272
+ full option name (e.g. x.y.z.option_name), your code may break in future
273
+ versions if new options with similar names are introduced.
274
+ value :
275
+ new value of option.
266
276
267
277
Returns
268
278
-------
@@ -272,55 +282,72 @@ def __doc__(self):
272
282
------
273
283
OptionError if no such option exists
274
284
285
+ Notes
286
+ -----
287
+ The available options with its descriptions:
288
+
275
289
{opts_desc}
276
290
"""
277
291
278
292
_describe_option_tmpl = """
279
- describe_option(pat,_print_desc=False) Prints the description
280
- for one or more registered options.
293
+ describe_option(pat, _print_desc=False)
294
+
295
+ Prints the description for one or more registered options.
281
296
282
297
Call with not arguments to get a listing for all registered options.
283
298
284
299
Available options:
300
+
285
301
{opts_list}
286
302
287
303
Parameters
288
304
----------
289
- pat - str, a regexp pattern. All matching keys will have their
290
- description displayed.
291
-
292
- _print_desc - if True (default) the description(s) will be printed
293
- to stdout otherwise , the description(s) will be returned
294
- as a unicode string (for testing).
305
+ pat : str
306
+ Regexp pattern. All matching keys will have their description displayed.
307
+ _print_desc : bool, default True
308
+ If True (default) the description(s) will be printed to stdout.
309
+ Otherwise , the description(s) will be returned as a unicode string
310
+ (for testing).
295
311
296
312
Returns
297
313
-------
298
314
None by default, the description(s) as a unicode string if _print_desc
299
315
is False
300
316
317
+ Notes
318
+ -----
319
+ The available options with its descriptions:
320
+
301
321
{opts_desc}
302
322
"""
303
323
304
324
_reset_option_tmpl = """
305
- reset_option(pat) - Reset one or more options to their default value.
325
+ reset_option(pat)
326
+
327
+ Reset one or more options to their default value.
306
328
307
329
Pass "all" as argument to reset all options.
308
330
309
331
Available options:
332
+
310
333
{opts_list}
311
334
312
335
Parameters
313
336
----------
314
- pat - str/regex if specified only options matching `prefix`* will be reset
315
-
316
- Note: partial matches are supported for convenience, but unless you use the
317
- full option name (e.g. x.y.z.option_name), your code may break in future
318
- versions if new options with similar names are introduced.
337
+ pat : str/regex
338
+ If specified only options matching `prefix*` will be reset.
339
+ Note: partial matches are supported for convenience, but unless you
340
+ use the full option name (e.g. x.y.z.option_name), your code may break
341
+ in future versions if new options with similar names are introduced.
319
342
320
343
Returns
321
344
-------
322
345
None
323
346
347
+ Notes
348
+ -----
349
+ The available options with its descriptions:
350
+
324
351
{opts_desc}
325
352
"""
326
353
@@ -337,6 +364,18 @@ def __doc__(self):
337
364
338
365
339
366
class option_context (object ):
367
+ """
368
+ Context manager to temporarily set options in the `with` statement context.
369
+
370
+ You need to invoke as ``option_context(pat, val, [(pat, val), ...])``.
371
+
372
+ Examples
373
+ --------
374
+
375
+ >>> with option_context('display.max_rows', 10, 'display.max_columns', 5):
376
+ ...
377
+
378
+ """
340
379
341
380
def __init__ (self , * args ):
342
381
if not (len (args ) % 2 == 0 and len (args ) >= 2 ):
@@ -589,13 +628,13 @@ def _build_option_description(k):
589
628
o = _get_registered_option (k )
590
629
d = _get_deprecated_option (k )
591
630
592
- s = u ('%s: ' ) % k
631
+ s = u ('%s : ' ) % k
593
632
if o :
594
633
s += u ('[default: %s] [currently: %s]' ) % (o .defval ,
595
634
_get_option (k , True ))
596
635
597
636
if o .doc :
598
- s += '\n ' + ' \n ' .join (o .doc .strip ().split ('\n ' ))
637
+ s += '\n ' .join (o .doc .strip ().split ('\n ' ))
599
638
else :
600
639
s += 'No description available.\n '
601
640
@@ -604,7 +643,7 @@ def _build_option_description(k):
604
643
s += (u (', use `%s` instead.' ) % d .rkey if d .rkey else '' )
605
644
s += u (')\n ' )
606
645
607
- s += '\n '
646
+ s += '\n \n '
608
647
return s
609
648
610
649
@@ -615,9 +654,9 @@ def pp_options_list(keys, width=80, _print=False):
615
654
from itertools import groupby
616
655
617
656
def pp (name , ks ):
618
- pfx = (name + '.[' if name else '' )
657
+ pfx = ('- ' + name + '.[' if name else '' )
619
658
ls = wrap (', ' .join (ks ), width , initial_indent = pfx ,
620
- subsequent_indent = ' ' * len ( pfx ) , break_long_words = False )
659
+ subsequent_indent = ' ' , break_long_words = False )
621
660
if ls and ls [- 1 ] and name :
622
661
ls [- 1 ] = ls [- 1 ] + ']'
623
662
return ls
0 commit comments