@@ -68,7 +68,7 @@ def diskcheck_convert(value):
6868
6969
7070class SConsValues (optparse .Values ):
71- """Holder class for uniform access to SCons options .
71+ """SCons parsed argument names and values .
7272
7373 A SCons option value can originate three different ways:
7474
@@ -235,8 +235,8 @@ def set_option(self, name: str, value) -> None:
235235class SConsOption (optparse .Option ):
236236 """SCons added option.
237237
238- Changes :attr:`CHECK_METHODS` and :attr:`CONST_ACTIONS` settings from
239- :class:`optparse.Option` base class to tune for our usage.
238+ Changes :attr:`CHECK_METHODS` and :attr:`CONST_ACTIONS` settings
239+ to tune for our usage.
240240
241241 New function :meth:`_check_nargs_optional` implements the ``nargs=?``
242242 syntax from :mod:`argparse`, and is added to the ``CHECK_METHODS`` list.
@@ -247,12 +247,13 @@ class SConsOption(optparse.Option):
247247 set in the option. A parameter to mark the option settable was added
248248 in 4.8.0, but was not initially made part of the option object itself.
249249 """
250+
250251 # can uncomment to have a place to trap SConsOption creation for debugging:
251252 # def __init__(self, *args, **kwargs):
252253 # super().__init__(*args, **kwargs)
253254
254255 def convert_value (self , opt : str , value ):
255- """SCons override: recognize nargs="?". """
256+ """SCons override: recognize `` nargs='?'` """
256257 if value is not None :
257258 if self .nargs in (1 , '?' ):
258259 return self .check_value (opt , value )
@@ -289,7 +290,7 @@ def _check_nargs_optional(self) -> None:
289290
290291
291292class SConsOptionGroup (optparse .OptionGroup ):
292- """A subclass for SCons-specific option groups.
293+ """SCons option groups.
293294
294295 The only difference between this and the base class is that we print
295296 the group's help text flush left, underneath their own title but
@@ -311,7 +312,7 @@ def format_help(self, formatter) -> str:
311312
312313
313314class SConsBadOptionError (optparse .BadOptionError ):
314- """Raised if an invalid option value is encountered on the command line .
315+ """SCons handler for bad options .
315316
316317 Attributes:
317318 opt_str: The unrecognized command-line option.
@@ -328,6 +329,8 @@ def __str__(self) -> str:
328329
329330
330331class SConsOptionParser (optparse .OptionParser ):
332+ """SCons option parser."""
333+
331334 preserve_unknown_options = False
332335 raise_exception_on_error = False
333336
@@ -343,13 +346,11 @@ def error(self, msg: str) -> None:
343346 def _process_long_opt (self , rargs , values ) -> None :
344347 """SCons-specific processing of long options.
345348
346- This is copied directly from the normal Optparse
347- :meth:`~optparse.OptionParser._process_long_opt` method, except
348- that, if configured to do so, we catch the exception thrown
349- when an unknown option is encountered and just stick it back
350- on the "leftover" arguments for later (re-)processing. This is
351- because we may see the option definition later, while processing
352- SConscript files.
349+ Vendors :meth:`~optparse.OptionParser._process_long_opt`.
350+ If configured to do so, catch the unknown option exception and stick
351+ the option back on the "leftover" arguments for later (re-)processing.
352+ This is because we may see the option definition later in the form
353+ of a :meth:`~SCons.Script.Main.AddOption` while reading SConscript files.
353354 """
354355 arg = rargs .pop (0 )
355356
@@ -420,13 +421,11 @@ def _process_long_opt(self, rargs, values) -> None:
420421 def _process_short_opts (self , rargs , values ) -> None :
421422 """SCons-specific processing of short options.
422423
423- This is copied directly from the normal Optparse
424- :meth:`~optparse.OptionParser._process_short_opts` method, except
425- that, if configured to do so, we catch the exception thrown
426- when an unknown option is encountered and just stick it back
427- on the "leftover" arguments for later (re-)processing. This is
428- because we may see the option definition later, while processing
429- SConscript files.
424+ Vendors :meth:`~optparse.OptionParser._process_short_opts`.
425+ If configured to do so, catch the unknown option exception and stick
426+ the option back on the "leftover" arguments for later (re-)processing.
427+ This is because we may see the option definition later in the form
428+ of a :meth:`~SCons.Script.Main.AddOption` while reading SConscript files.
430429 """
431430 arg = rargs .pop (0 )
432431 stop = False
@@ -549,7 +548,7 @@ def add_local_option(self, *args, **kw) -> SConsOption:
549548 by default "local" (project-added) options are not eligible for
550549 :func:`~SCons.Script.Main.SetOption` calls.
551550
552- .. versionchanged:: NEXT_VERSION
551+ .. versionchanged:: 4.9.0
553552 If the option's *settable* attribute is true, it is added to
554553 the :attr:`SConsValues.settable` list. *settable* handling was
555554 added in 4.8.0, but was not made an option attribute at the time.
@@ -617,6 +616,12 @@ def print_local_option_help(self, file=None):
617616
618617
619618class SConsIndentedHelpFormatter (optparse .IndentedHelpFormatter ):
619+ """SCons help formatting.
620+
621+ This is the SCons-specific :meth:`~optparse.HelpFormatter` subclass,
622+ implemented by extending :meth:`optparse.IndentedHelpFormatter`.
623+ """
624+
620625 def format_usage (self , usage ) -> str :
621626 """Format the usage message for SCons."""
622627 return "usage: %s\n " % usage
@@ -625,7 +630,7 @@ def format_heading(self, heading):
625630 """Translate heading to "SCons Options"
626631
627632 Heading of "Options" changed to "SCons Options."
628- Unfortunately, we have to do this here, because those titles
633+ Unfortunately, we have to intercept it here, because those titles
629634 are hard-coded in the optparse calls.
630635 """
631636 if heading == 'Options' :
@@ -635,8 +640,8 @@ def format_heading(self, heading):
635640 def format_option (self , option ):
636641 """SCons-specific option formatter.
637642
638- A copy of the :meth:`optparse.IndentedHelpFormatter .format_option`
639- method. Overridden so we can modify text wrapping to our liking:
643+ Vendors :meth:`optparse.HelpFormatter .format_option`, overridden
644+ to modify text wrapping to our liking:
640645
641646 * add our own regular expression that doesn't break on hyphens
642647 (so things like ``--no-print-directory`` don't get broken).
@@ -663,8 +668,9 @@ def format_option(self, option):
663668 read data from FILENAME
664669
665670 Help strings are wrapped for terminal width and do not preserve
666- any hand-made formatting that may have been used in the ``AddOption``
667- call, so don't attempt prettying up a list of choices (for example).
671+ any hand-made formatting that may have been used in the
672+ :meth:`~SCons.Script.Main.AddOption` call, so don't attempt
673+ prettying up a list of choices (for example).
668674 """
669675 result = []
670676 opts = self .option_strings [option ]
0 commit comments