Skip to content

Commit 876bb06

Browse files
authored
Merge pull request SCons#4583 from mwichmann/doc/consistent-signatures
Doc: use consistent repeated-args syntax
2 parents c7a3c96 + b44c536 commit 876bb06

File tree

5 files changed

+63
-42
lines changed

5 files changed

+63
-42
lines changed

CHANGES.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER
3838
- Switch SCons build to use setuptools' supported version fetcher from
3939
the old homegrown one.
4040
- Improve wording of manpage "Functions and Environment Methods" section.
41+
Make doc function signature style more consistent - tweaks to AddOption,
42+
DefaultEnvironment and Tool,.
4143

4244

4345
RELEASE 4.8.0 - Sun, 07 Jul 2024 17:22:20 -0700

RELEASE.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ DOCUMENTATION
6363
-------------
6464

6565
- Improve wording of manpage "Functions and Environment Methods" section.
66+
- Make doc function signature style more consistent - tweaks to AddOption,
67+
DefaultEnvironment and Tool,.
68+
6669

6770
DEVELOPMENT
6871
-----------

SCons/Defaults.xml

Lines changed: 41 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -729,43 +729,53 @@ searching the repositories.
729729

730730
<scons_function name="DefaultEnvironment">
731731
<arguments signature="global">
732-
([**kwargs])
732+
([key=value, ...])
733733
</arguments>
734734
<summary>
735735
<para>
736736
Instantiates and returns the global &consenv; object.
737-
This environment is used internally by SCons
738-
when it executes many of the global functions listed in this section
739-
(that is, those not called as methods of a specific &consenv;).
740-
The &defenv; is a singleton:
741-
the keyword arguments are used only on the first call;
742-
on subsequent calls the already-constructed object is returned
737+
The <firstterm>&DefEnv;</firstterm> is used internally by &SCons;
738+
when executing a global function
739+
or the global form of a Builder method
740+
that requires access to a &consenv;.
741+
</para>
742+
743+
<para>
744+
On the first call,
745+
arguments are interpreted as for the &f-link-Environment; function.
746+
The &DefEnv; is a singleton;
747+
subsequent calls to &f-DefaultEnvironment; return
748+
the already-constructed object,
743749
and any keyword arguments are silently ignored.
744-
The &defenv; can still be modified after instantiation
745-
in the same way as any other &consenv;.
746-
The &defenv; is independent:
747-
modifying it has no effect on any other &consenv;
748-
constructed by an &f-link-Environment; or &f-link-Clone; call.
749-
</para>
750-
751-
<para>
752-
It is not mandatory to call &f-DefaultEnvironment;:
753-
the &defenv; is instantiated automatically when the
754-
build phase begins if this function has not been called;
755-
however calling it explicitly gives the opportunity to
756-
affect and examine the contents of the &defenv;.
757-
Instantiation happens even if no build instructions
758-
appar to use it, as there are internal uses.
759-
If there are no uses in the project &SConscript; files,
760-
a small performance gain may be seen by calling
761-
&f-DefaultEnvironment; with an empty tools list,
762-
thus avoiding that part of the initialization cost.
763-
This is mainly of interest in testing when &scons; is
764-
launched repeatedly in a short time period:
765750
</para>
766-
<example_commands>
767-
DefaultEnvironment(tools=[])
768-
</example_commands>
751+
752+
<para>
753+
The &DefEnv; can be modified after instantiation,
754+
similar to other &consenvs;,
755+
although some &consenv; methods may be unavailable.
756+
Modifying the &DefEnv; has no effect on any other &consenv;,
757+
either existing or newly constructed.
758+
</para>
759+
760+
<para>
761+
It is not necessary to explicitly call &f-DefaultEnvironment;.
762+
&SCons; instantiates the &defenv; automatically when the
763+
build phase begins, if has not already been done.
764+
However, calling it explicitly provides the opportunity to
765+
affect and examine its contents.
766+
Instantiation occurs even if nothing in the build system
767+
appars to use it, due to internal uses.
768+
</para>
769+
770+
<para>
771+
If the project &SConscript; files do not use global functions or Builders,
772+
a small performance gain may be achieved by calling
773+
&f-DefaultEnvironment; with an empty tools list
774+
(<userinput>DefaultEnvironment(tools=[])</userinput>).
775+
This avoids the tool initialization cost for the &DefEnv;,
776+
which is mainly of interest in the test suite
777+
where &scons; is launched repeatedly in a short time period.
778+
</para>
769779
</summary>
770780
</scons_function>
771781

SCons/Environment.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3489,7 +3489,7 @@ source_nodes = env.subst('$EXPAND_TO_NODELIST', conv=lambda x: x)
34893489

34903490
<scons_function name="Tool">
34913491
<arguments>
3492-
(name, [toolpath, **kwargs])
3492+
(name, [toolpath, key=value, ...])
34933493
</arguments>
34943494
<summary>
34953495

SCons/Script/Main.xml

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,25 @@ This file is processed by the bin/SConsDoc.py module.
2727

2828
<scons_function name="AddOption">
2929
<arguments signature="global">
30-
(arguments)
30+
(opt_str, ..., attr=value, ...)
3131
</arguments>
3232
<summary>
3333
<para>
3434
Adds a local (project-specific) command-line option.
35-
<parameter>arguments</parameter>
36-
are the same as those supported by the <function>add_option</function>
37-
method in the standard Python library module <systemitem>optparse</systemitem>,
38-
with a few additional capabilities noted below.
39-
See the documentation for
40-
<systemitem>optparse</systemitem>
35+
One or more <parameter>opt_str</parameter> values are
36+
the strings representing how the option can be called,
37+
while the keyword arguments define attributes of the option.
38+
For the most part these are the same as for the
39+
<function>OptionParser.add_option</function>
40+
method in the standard Python library module
41+
<systemitem>optparse</systemitem>,
42+
but with a few additional capabilities noted below.
43+
See the
44+
<ulink url="https://docs.python.org/3/library/optparse.html">
45+
optparse documentation</ulink>
4146
for a thorough discussion of its option-processing capabities.
47+
All options added through &f-AddOption; are placed
48+
in a special "Local Options" option group.
4249
</para>
4350

4451
<para>
@@ -49,10 +56,9 @@ method, &f-AddOption;
4956
allows setting the
5057
<parameter>nargs</parameter>
5158
keyword value to
52-
a string consisting of a question mark
53-
(<literal>'?'</literal>)
59+
a string <literal>'?'</literal> (question mark)
5460
to indicate that the option argument for
55-
that option string is optional.
61+
that option string may be omitted.
5662
If the option string is present on the
5763
command line but has no matching option
5864
argument, the value of the

0 commit comments

Comments
 (0)