Skip to content

Commit 5cb6060

Browse files
authored
Merge pull request #4797 from mwichmann/doc/sphinx-ignore-all
Improve coverage of API doc build
2 parents c6bc7dc + 2f3c3cb commit 5cb6060

File tree

6 files changed

+73
-29
lines changed

6 files changed

+73
-29
lines changed

CHANGES.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER
3232
- Handle the default (unset) ProgressObject differently for the sole
3333
purpose of avoiding Sphinx 9.0+ blowing up on it (it's been giving
3434
a warning for years, but now it's a fatal error).
35+
- Improve covarage of API doc build by ignoring any setting of
36+
__all__ in a package and not showing inherited members from optparse.
3537

3638

3739
RELEASE 4.10.1 - Sun, 16 Nov 2025 10:51:57 -0700

RELEASE.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ DOCUMENTATION
6767
a warning for years, but now it's a fatal error). Affects only the
6868
API doc build.
6969

70+
- Improve covarage of API doc build by ignoring any setting of
71+
__all__ in a package and not showing inherited members from optparse.
72+
73+
7074

7175
DEVELOPMENT
7276
-----------

SCons/Script/SConsOptions.py

Lines changed: 32 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def diskcheck_convert(value):
6868

6969

7070
class 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:
235235
class 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

291292
class 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

313314
class 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

330331
class 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

619618
class 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]

SCons/Variables/__init__.py

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,12 @@
2121
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
2222
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2323

24-
"""Adds user-friendly customizable variables to an SCons build."""
24+
"""
25+
Adds user-friendly customizable variables to an SCons build.
26+
27+
"Build Variables" represent a way to supply values for SCons
28+
construction variables from the command-line, or from saved settings files.
29+
"""
2530

2631
from __future__ import annotations
2732

@@ -56,8 +61,27 @@
5661

5762
@dataclass(order=True)
5863
class Variable:
59-
"""A Build Variable."""
60-
__slots__ = ('key', 'aliases', 'help', 'default', 'validator', 'converter', 'do_subst')
64+
"""A Build Variable.
65+
66+
Attributes:
67+
key: the name of the variable
68+
aliases: other names recognized for the variable
69+
help:– help text
70+
default: optional default value
71+
validator: optional validator function
72+
converter: optional converter function
73+
do_subst: substitute before calling converter/valiator (default True)
74+
"""
75+
76+
__slots__ = (
77+
'key',
78+
'aliases',
79+
'help',
80+
'default',
81+
'validator',
82+
'converter',
83+
'do_subst',
84+
)
6185
key: str
6286
aliases: list[str]
6387
help: str

doc/sphinx/SCons.Script.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ SCons.Script.SConsOptions module
3333
--------------------------------
3434

3535
.. automodule:: SCons.Script.SConsOptions
36+
:no-inherited-members:
3637
:members:
3738
:undoc-members:
3839
:show-inheritance:

doc/sphinx/SCons.Variables.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Module contents
55
---------------
66

77
.. automodule:: SCons.Variables
8+
:ignore-module-all:
89
:members:
910
:undoc-members:
1011
:show-inheritance:
@@ -17,6 +18,7 @@ SCons.Variables.BoolVariable module
1718
-----------------------------------
1819

1920
.. automodule:: SCons.Variables.BoolVariable
21+
:ignore-module-all:
2022
:members:
2123
:undoc-members:
2224
:show-inheritance:
@@ -25,6 +27,7 @@ SCons.Variables.EnumVariable module
2527
-----------------------------------
2628

2729
.. automodule:: SCons.Variables.EnumVariable
30+
:ignore-module-all:
2831
:members:
2932
:undoc-members:
3033
:show-inheritance:
@@ -33,6 +36,8 @@ SCons.Variables.ListVariable module
3336
-----------------------------------
3437

3538
.. automodule:: SCons.Variables.ListVariable
39+
:ignore-module-all:
40+
:no-inherited-members:
3641
:members:
3742
:undoc-members:
3843
:show-inheritance:
@@ -41,6 +46,7 @@ SCons.Variables.PackageVariable module
4146
--------------------------------------
4247

4348
.. automodule:: SCons.Variables.PackageVariable
49+
:ignore-module-all:
4450
:members:
4551
:undoc-members:
4652
:show-inheritance:
@@ -49,6 +55,7 @@ SCons.Variables.PathVariable module
4955
-----------------------------------
5056

5157
.. automodule:: SCons.Variables.PathVariable
58+
:ignore-module-all:
5259
:members:
5360
:undoc-members:
5461
:show-inheritance:

0 commit comments

Comments
 (0)