Skip to content

Commit c7a3c96

Browse files
authored
Merge pull request SCons#4579 from mwichmann/doc/env-methods
Wordsmithing on manpage env Methods section
2 parents 7313377 + a4dc81d commit c7a3c96

File tree

3 files changed

+84
-76
lines changed

3 files changed

+84
-76
lines changed

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER
3737
real reason it shouldn't keep working - add to `__all__`.
3838
- Switch SCons build to use setuptools' supported version fetcher from
3939
the old homegrown one.
40+
- Improve wording of manpage "Functions and Environment Methods" section.
4041

4142

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

RELEASE.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,7 @@ PACKAGING
6262
DOCUMENTATION
6363
-------------
6464

65-
- List any significant changes to the documentation (not individual
66-
typo fixes, even if they're mentioned in src/CHANGES.txt to give
67-
the contributor credit)
65+
- Improve wording of manpage "Functions and Environment Methods" section.
6866

6967
DEVELOPMENT
7068
-----------

doc/man/scons.xml

Lines changed: 82 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -2519,7 +2519,7 @@ that can be used in &SConscript; files. Quick links:
25192519
<member><link linkend='construction_environments'>Construction Environments</link></member>
25202520
<member><link linkend='tools'>Tools</link></member>
25212521
<member><link linkend='builder_methods'>Builder Methods</link></member>
2522-
<member><link linkend='methods_and_functions_to_do_things'>Methods and Functions to do Things</link></member>
2522+
<member><link linkend='env_methods'>Functions and Environment Methods</link></member>
25232523
<member><link linkend='sconscript_variables'>SConscript Variables</link></member>
25242524
<member><link linkend='construction_variables'>Construction Variables</link></member>
25252525
<member><link linkend='configure_contexts'>Configure Contexts</link></member>
@@ -3384,89 +3384,98 @@ object.</para>
33843384

33853385
</refsect2>
33863386

3387-
<refsect2 id='methods_and_functions_to_do_things'>
3388-
<title>Methods and Functions To Do Things</title>
3387+
<refsect2 id='env_methods'>
3388+
<title>&SCons; Functions and Environment Methods</title>
33893389

3390-
<para>In addition to Builder methods,
3391-
&scons;
3392-
provides a number of other &consenv; methods
3393-
and global functions to
3394-
manipulate the build configuration.
3395-
Usually, a &consenv; method
3396-
and global function with the same name both exist
3397-
for convenience.
3398-
In the following list, the global function
3399-
is documented in this style:</para>
3390+
<para>
3391+
&SCons; provides a variety of &consenv; methods
3392+
and global functions to manipulate the build configuration.
3393+
Often, a &consenv; method and a global function with
3394+
the same name exist for convenience.
3395+
In this section, both forms are shown if the function can be called
3396+
in either way.
3397+
The documentation style for these is as follows:
3398+
</para>
34003399

34013400
<programlisting language="python">
3402-
<function>Function</function>(<parameter>arguments, [optional arguments]</parameter>)
3401+
<function>Function</function>(<parameter>arguments, [optional arguments, ...]</parameter>) # Global function
3402+
<replaceable>env</replaceable>.<methodname>Function</methodname>(<parameter>arguments, [optional arguments, ...]</parameter>) # Environment method
34033403
</programlisting>
34043404

3405-
<para>and the &consenv; method looks like:</para>
3406-
3407-
<programlisting language="python">
3408-
<replaceable>env</replaceable>.<methodname>Function</methodname>(<parameter>arguments, [optional arguments]</parameter>)
3409-
</programlisting>
3405+
<para>
3406+
In these function signatures,
3407+
arguments in brackets (<literal>[]</literal>) are optional,
3408+
and ellipses (<literal>...</literal>) indicate possible repetition.
3409+
Positional vs. keyword arguments are usually detailed
3410+
in the following text, not in the signature itself.
3411+
The &Python; positional-only (<literal>/</literal>)
3412+
and keyword-only (<literal>*</literal>) markers are not used.
3413+
</para>
34103414

3411-
<para>If the function can be called both ways,
3412-
then both forms are listed.</para>
3415+
<para>
3416+
When the &Python; <literal>keyword=value</literal> style is shown,
3417+
it can have two meanings.
3418+
If the keyword argument is known to the function,
3419+
the value is the default for that argument if it is omitted.
3420+
If the keyword is unknown to the function,
3421+
some methods treat it as a &consvar; assignment;
3422+
otherwise an exception is raised for an unknown argument.
3423+
</para>
34133424

3414-
<para>The global function and same-named
3415-
&consenv; method
3416-
provide almost identical functionality, with a couple of exceptions.
3417-
First, many of the &consenv; methods affect only that
3418-
&consenv;, while the global function has a
3419-
global effect (or, alternatively, takes an additional
3420-
positional argument to specify the affected &consenv;).
3421-
Second, where appropriate,
3422-
calling the functionality through a &consenv; will
3423-
substitute &consvars; into
3424-
any supplied string arguments, while the global function,
3425-
unless it takes a &consenv; parameter,
3426-
does not have the context of a &consenv; to pick variables from,
3427-
and thus cannot perform substitutions.
3428-
For example:</para>
3425+
<para>
3426+
A global function and a same-named &consenv; method
3427+
have the same base functionality,
3428+
with two key differences:
3429+
</para>
34293430

3430-
<programlisting language="python">
3431-
Default('$FOO')
3431+
<orderedlist>
3432+
<listitem>
3433+
<para>
3434+
&Consenv; methods that change the environment
3435+
act on the environment instance from which they are called,
3436+
while the corresponding global function acts on
3437+
a special “hidden” &consenv; called the Default Environment.
3438+
In some cases, the global function may take
3439+
an initial argument giving the object to operate on.
3440+
</para>
3441+
</listitem>
3442+
<listitem>
3443+
<para>
3444+
String-valued arguments
3445+
(including strings in list-valued arguments)
3446+
are subject to construction variable expansion
3447+
by the environment method form;
3448+
variable expansion is not immediately performed in the global function.
3449+
For example, <userinput>Default('$MYTARGET')</userinput>
3450+
adds <computeroutput>'$MYTARGET'</computeroutput> to the
3451+
list of default targets,
3452+
while if the value in <parameter>env</parameter> of
3453+
<literal>MYTARGET</literal> is <literal>'mine'</literal>,
3454+
<userinput>env.Default('$MYTARGET'</userinput> adds
3455+
<computeroutput>'mine'</computeroutput>
3456+
to the default targets.
3457+
For more details on &consvar; expansion, see the
3458+
<link linkend="construction_variables">&Consvars;</link> section.
3459+
</para>
3460+
</listitem>
3461+
</orderedlist>
34323462

3433-
env = Environment(FOO='foo')
3434-
env.Default('$FOO')
3435-
</programlisting>
3436-
3437-
<para>In the above example,
3438-
the call to the global &f-Default;
3439-
function will add a target named
3440-
<emphasis role="bold">$FOO</emphasis>
3441-
to the list of default targets,
3442-
while the call to the
3443-
&f-env-Default; &consenv; method
3444-
will expand the value
3445-
and add a target named
3446-
<emphasis role="bold">foo</emphasis>
3447-
to the list of default targets.
3448-
For more on &consvar; expansion,
3449-
see the
3450-
<link linkend="construction_variables">&Consvars;</link>
3451-
section below.
3452-
</para>
3453-
3454-
<para>
3455-
Global functions are automatically in scope inside
3456-
&SConscript; files.
3457-
If you have custom &Python; code that you import into an &SConscript; file,
3458-
such code will need to bring them into their own scope.
3459-
You can do that by adding the following import
3460-
to the &Python; module:</para>
3463+
<para>
3464+
Global functions are automatically in scope inside &SConscript; files.
3465+
If your project adds &Python; modules that you include
3466+
via the &Python; <literal>import</literal> statement
3467+
from an &SConscript; file,
3468+
such code will need to add the functions
3469+
to that module’s global scope explicitly.
3470+
You can do that by adding the following import to the &Python; module:
3471+
<userinput>from SCons.Script import *</userinput>.
3472+
</para>
34613473

3462-
<programlisting language="python">
3463-
from SCons.Script import *
3464-
</programlisting>
3474+
<para>
3475+
&SCons; provides the following &consenv; methods and global functions.
3476+
The list can be augmented on a project basis using &f-link-AddMethod;
3477+
</para>
34653478

3466-
<para>&Consenv; methods
3467-
and global functions provided by
3468-
&scons;
3469-
include:</para>
34703479

34713480
<!-- '\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -->
34723481
<!-- '\" BEGIN GENERATED FUNCTION DESCRIPTIONS -->

0 commit comments

Comments
 (0)