Skip to content

Commit

Permalink
Tweak Clean and NoClean manpage entries [skip appveyor]
Browse files Browse the repository at this point in the history
Motivated by an issue that pointed out the argument names differ between
doc and implementation, adjusted the wording a bit.  Clean() used to
suggest you could use a whole bunch of args in one call ("Multiple files
or directories should be specified either as separate arguments to the
Clean method, or as a list") but as it's written to take exactly two
positionial arguments that wasn't correct - only the list approach
works.

Fixes #4638

Signed-off-by: Mats Wichmann <[email protected]>
  • Loading branch information
mwichmann committed Nov 17, 2024
1 parent 9f387ef commit b8b2ede
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 128 deletions.
1 change: 1 addition & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER
always returns a dict. The default remains to return different
types depending on whether zero, one, or multiple construction
variable names are given.
- Update Clean and NoClean documentation.


RELEASE 4.8.1 - Tue, 03 Sep 2024 17:22:20 -0700
Expand Down
1 change: 1 addition & 0 deletions RELEASE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ DOCUMENTATION

- Many grammatical and spelling fixes in the documentation.

- Update Clean and NoClean documentation.

DEVELOPMENT
-----------
Expand Down
14 changes: 12 additions & 2 deletions SCons/Environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -2248,6 +2248,16 @@ def CacheDir(self, path, custom_class=None) -> None:
self.get_CacheDir()

def Clean(self, targets, files) -> None:
"""Mark additional files for cleaning.
*files* will be removed if any of *targets* are selected
for cleaning - that is, the combination of target selection
and -c clean mode.
Args:
targets (files or nodes): targets to associate *files* with.
files (files or nodes): items to remove if *targets* are selected.
"""
global CleanTargets
tlist = self.arg2nodes(targets, self.fs.Entry)
flist = self.arg2nodes(files, self.fs.Entry)
Expand Down Expand Up @@ -2334,8 +2344,8 @@ def PyPackageDir(self, modulename):
return result
return self.fs.PyPackageDir(s)

def NoClean(self, *targets):
"""Tag target(s) so that it will not be cleaned by -c."""
def NoClean(self, *targets) -> list:
"""Tag *targets* to not be removed in clean mode."""
tlist = []
for t in targets:
tlist.extend(self.arg2nodes(t, self.fs.Entry))
Expand Down
100 changes: 38 additions & 62 deletions SCons/Environment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1010,45 +1010,34 @@ to arrange for cache pruning, expiry, access control, etc. if needed.

<scons_function name="Clean">
<arguments>
(targets, files_or_dirs)
(targets, files)
</arguments>
<summary>
<para>
This specifies a list of files or directories which should be removed
whenever the targets are specified with the
<option>-c</option>
command line option.
The specified targets may be a list
or an individual target.
Multiple calls to
&f-Clean;
are legal,
and create new targets or add files and directories to the
clean list for the specified targets.
</para>

<para>
Multiple files or directories should be specified
either as separate arguments to the
&f-Clean;
method, or as a list.
&f-Clean;
will also accept the return value of the &consenv;
Builder methods.
Examples:
Set additional <parameter>files</parameter>
for removal when any of
<parameter>targets</parameter> are selected
for cleaning
(<link linkend="opt-clean"><option>-c</option></link>
command line option).
<parameter>targets</parameter> and
<parameter>files</parameter>
can each be a single filename or node,
or a list of filenames or nodes.
These can refer to files or directories.
Calling this method repeatedly
has an additive effect.
</para>

<para>
The related
&f-link-NoClean;
function overrides calling
&f-Clean;
for the same target,
and any targets passed to both functions will
<emphasis>not</emphasis>
be removed by the
<option>-c</option>
option.
method has higher priority:
any target specified to
&f-NoClean;
will not be cleaned even if also given as
a <parameter>files</parameter>
parameter to &f-Clean;.
</para>

<para>
Expand All @@ -1062,9 +1051,12 @@ Clean(['foo', 'bar'], 'something_else_to_clean')
</example_commands>

<para>
&SCons; does not directly track directories as targets -
they are created if needed and not normally removed
in clean mode.
In this example,
installing the project creates a subdirectory for the documentation.
This statement causes the subdirectory to be removed
The &f-Clean; call ensures that the subdirectory is removed
if the project is uninstalled.
</para>
<example_commands>
Expand Down Expand Up @@ -2525,35 +2517,21 @@ NoCache(env.Program('hello', 'hello.c'))

<scons_function name="NoClean">
<arguments>
(target, ...)
(targets, ...)
</arguments>
<summary>
<para>
Specifies a list of files or directories which should
<emphasis>not</emphasis>
be removed whenever the targets (or their dependencies)
are specified with the
<option>-c</option>
command line option.
The specified targets may be a list
or an individual target.
Multiple calls to
&f-NoClean;
are legal,
and prevent each specified target
from being removed by calls to the
<option>-c</option>
option.
</para>

<para>
Multiple files or directories should be specified
either as separate arguments to the
&f-NoClean;
method, or as a list.
&f-NoClean;
will also accept the return value of any of the &consenv;
Builder methods.
Specifies files or directories which should not
be removed whenever a specified
<parameter>target</parameter> (or its dependencies)
is selected and clean mode is active
(<link linkend="opt-clean"><option>-c</option></link>
command line option).
<parameter>targets</parameter>
may be one or more file or directory names
or nodes,
and/or lists of names or nodes.
&f-NoClean; can be called multiple times.
</para>

<para>
Expand All @@ -2562,11 +2540,9 @@ Calling
for a target overrides calling
&f-link-Clean;
for the same target,
and any targets passed to both functions will
so any targets passed to both functions will
<emphasis>not</emphasis>
be removed by the
<option>-c</option>
option.
be removed in clean mode.
</para>

<para>
Expand Down
104 changes: 40 additions & 64 deletions doc/generated/functions.gen
Original file line number Diff line number Diff line change
Expand Up @@ -927,44 +927,33 @@ to arrange for cache pruning, expiry, access control, etc. if needed.
</listitem>
</varlistentry>
<varlistentry id="f-Clean">
<term><function>Clean</function>(<parameter>targets, files_or_dirs</parameter>)</term>
<term><replaceable>env</replaceable>.<methodname>Clean</methodname>(<parameter>targets, files_or_dirs</parameter>)</term>
<term><function>Clean</function>(<parameter>targets, files</parameter>)</term>
<term><replaceable>env</replaceable>.<methodname>Clean</methodname>(<parameter>targets, files</parameter>)</term>
<listitem><para>
This specifies a list of files or directories which should be removed
whenever the targets are specified with the
<option>-c</option>
command line option.
The specified targets may be a list
or an individual target.
Multiple calls to
&f-Clean;
are legal,
and create new targets or add files and directories to the
clean list for the specified targets.
</para>

<para>
Multiple files or directories should be specified
either as separate arguments to the
&f-Clean;
method, or as a list.
&f-Clean;
will also accept the return value of the &consenv;
Builder methods.
Examples:
Set additional <parameter>files</parameter>
for removal when any of
<parameter>targets</parameter> are selected
for cleaning
(<link linkend="opt-clean"><option>-c</option></link>
command line option).
<parameter>targets</parameter> and
<parameter>files</parameter>
can each be a single filename or node,
or a list of filenames or nodes.
These can refer to files or directories.
Calling this method repeatedly
has an additive effect.
</para>

<para>
The related
&f-link-NoClean;
function overrides calling
&f-Clean;
for the same target,
and any targets passed to both functions will
<emphasis>not</emphasis>
be removed by the
<option>-c</option>
option.
method has higher priority:
any target specified to
&f-NoClean;
will not be cleaned even if also given as
a <parameter>files</parameter>
parameter to &f-Clean;.
</para>

<para>
Expand All @@ -978,9 +967,12 @@ Clean(['foo', 'bar'], 'something_else_to_clean')
</example_commands>

<para>
&SCons; does not directly track directories as targets -
they are created if needed and not normally removed
in clean mode.
In this example,
installing the project creates a subdirectory for the documentation.
This statement causes the subdirectory to be removed
The &f-Clean; call ensures that the subdirectory is removed
if the project is uninstalled.
</para>
<example_commands>
Expand Down Expand Up @@ -3056,34 +3048,20 @@ NoCache(env.Program('hello', 'hello.c'))
</listitem>
</varlistentry>
<varlistentry id="f-NoClean">
<term><function>NoClean</function>(<parameter>target, ...</parameter>)</term>
<term><replaceable>env</replaceable>.<methodname>NoClean</methodname>(<parameter>target, ...</parameter>)</term>
<term><function>NoClean</function>(<parameter>targets, ...</parameter>)</term>
<term><replaceable>env</replaceable>.<methodname>NoClean</methodname>(<parameter>targets, ...</parameter>)</term>
<listitem><para>
Specifies a list of files or directories which should
<emphasis>not</emphasis>
be removed whenever the targets (or their dependencies)
are specified with the
<option>-c</option>
command line option.
The specified targets may be a list
or an individual target.
Multiple calls to
&f-NoClean;
are legal,
and prevent each specified target
from being removed by calls to the
<option>-c</option>
option.
</para>

<para>
Multiple files or directories should be specified
either as separate arguments to the
&f-NoClean;
method, or as a list.
&f-NoClean;
will also accept the return value of any of the &consenv;
Builder methods.
Specifies files or directories which should not
be removed whenever a specified
<parameter>target</parameter> (or its dependencies)
is selected and clean mode is active
(<link linkend="opt-clean"><option>-c</option></link>
command line option).
<parameter>targets</parameter>
may be one or more file or directory names
or nodes,
and/or lists of names or nodes.
&f-NoClean; can be called multiple times.
</para>

<para>
Expand All @@ -3092,11 +3070,9 @@ Calling
for a target overrides calling
&f-link-Clean;
for the same target,
and any targets passed to both functions will
so any targets passed to both functions will
<emphasis>not</emphasis>
be removed by the
<option>-c</option>
option.
be removed in clean mode.
</para>

<para>
Expand Down

0 comments on commit b8b2ede

Please sign in to comment.