@@ -4716,22 +4716,26 @@ call the &Variables; factory function:</para>
4716
4716
<varlistentry id =" v-Variables" >
4717
4717
<term ><function >Variables</function >([<parameter >files, [args]]</parameter >)</term >
4718
4718
<listitem >
4719
- <para >If <parameter >files</parameter > is a file or list of files ,
4719
+ <para >If <parameter >files</parameter > is a filename or list of filenames ,
4720
4720
they are considered to be &Python; scripts which will
4721
- be executed when the
4721
+ be executed to set variables when the
4722
4722
<link linkend =' v-Update' ><function >Update</function ></link >
4723
4723
method is called -
4724
4724
this allows the use of &Python; syntax in the assignments.
4725
+ A file can be the result of an earlier call to the
4726
+ <link linkend =' v-Save' >&Save; </link > method.
4725
4727
If <parameter >files</parameter > is not specified,
4726
4728
or the
4727
4729
<parameter >files</parameter >
4728
4730
argument is
4729
4731
<constant >None</constant >,
4730
- then no files will be read
4731
- (supplying <constant >None</constant > is required
4732
+ then no files will be read.
4733
+ Supplying <constant >None</constant > is required
4732
4734
if there are no files but you want to specify
4733
4735
<parameter >args</parameter > as a positional argument;
4734
- this can be omitted if using the keyword argument style).
4736
+ this can be omitted if using the keyword argument style.
4737
+ If any of <parameter >files</parameter > is missing,
4738
+ it is silently skipped.
4735
4739
</para >
4736
4740
4737
4741
<para >
@@ -4751,10 +4755,11 @@ will be added to those obtained from
4751
4755
<parameter >files</parameter >, if any.
4752
4756
Keys from <parameter >args</parameter >
4753
4757
take precendence over same-named keys from <parameter >files</parameter >.
4754
- The most common usage is to pass the
4755
- &ARGUMENTS; dictionary that holds variables
4756
- specified on the command line,
4757
- allowing you to indicate that if a setting appears
4758
+ If omittted, the default is the
4759
+ <link linkend =" v-ARGUMENTS" >&ARGUMENTS; </link >
4760
+ dictionary that holds build variables
4761
+ specified on the command line.
4762
+ Using &ARGUMENTS; allows you to indicate that if a setting appears
4758
4763
on both the command line and in the file(s),
4759
4764
the command line setting is preferred.
4760
4765
However, any dictionary can be passed.
@@ -4827,20 +4832,25 @@ not to any stored-values files.
4827
4832
<para >Add a customizable &consvar; to the &Variables; object.
4828
4833
<parameter >key</parameter >
4829
4834
is either the name of the variable,
4830
- or a tuple (or list) , in which case
4831
- the first item in the tuple is taken as the variable name,
4835
+ or a sequence of strings , in which case
4836
+ the first item in the sequence is taken as the variable name,
4832
4837
and any remaining values are considered aliases for the variable.
4838
+ <parameter >key</parameter > is mandatory,
4839
+ there is no default.
4833
4840
<parameter >help</parameter >
4834
4841
is the help text for the variable
4835
- (default empty string).
4842
+ (defaults to an empty string).
4836
4843
<parameter >default</parameter >
4837
4844
is the default value of the variable
4838
- (default <constant >None</constant >).
4845
+ (defaults to <constant >None</constant >).
4839
4846
</para >
4840
4847
4841
4848
<para >
4842
4849
If the optional <parameter >validator</parameter > argument is supplied,
4843
- it is a callback function to validate the value of the variable.
4850
+ it is a callback function to validate the value of the variable
4851
+ when the variables are processed
4852
+ (that is, when the <link linkend =' v-Update' >&Update; </link >
4853
+ method runs).
4844
4854
A validator function must accept three arguments:
4845
4855
<parameter >key</parameter >,
4846
4856
<parameter >value</parameter >
@@ -4853,23 +4863,34 @@ No return value is expected from the validator.
4853
4863
<para >
4854
4864
If the optional <parameter >converter</parameter > argument is supplied,
4855
4865
it is a callback function to convert the value into
4856
- one suitable for adding to the environment,
4857
- and should accept either a value
4858
- or a value and &consenv; as parameters.
4866
+ one suitable for adding to the &consenv; .
4867
+ A converter function must accept the
4868
+ <parameter >value</parameter > argument,
4869
+ and may declare <parameter >env</parameter >
4870
+ as a second argument if it needs access to the
4871
+ &consenv; while validating - the function will be called appropriately.
4859
4872
The converter is called before the validator;
4860
4873
it must return a value, which is then passed to the
4861
- <parameter >validator</parameter > (if any)
4862
- and finally added to the &consenv; -
4863
- it is recommended to avoid performing validation
4864
- checks in the converter.
4874
+ <parameter >validator</parameter > (if any) for checking.
4875
+ In general, the converter should not fail,
4876
+ leaving validation checks to the validator,
4877
+ although if an operation is impossible to complete
4878
+ or there is no separate validator
4879
+ it can raise a <exceptionname >ValueError</exceptionname >.
4865
4880
</para >
4866
4881
4867
4882
<para >
4868
4883
As a special case, if <parameter >key</parameter >
4869
- is a tuple (or list) and is the <emphasis >only</emphasis >
4870
- argument, the tuple is unpacked into the five parameters
4871
- listed above left to right, with any missing members filled with
4872
- the respective default values. This form allows &Add;
4884
+ is a sequence and is the <emphasis >only</emphasis >
4885
+ argument to &Add; , it is unpacked into the five parameters
4886
+ <parameter >key</parameter >,
4887
+ <parameter >help</parameter >,
4888
+ <parameter >default</parameter >,
4889
+ <parameter >validator</parameter > and
4890
+ <parameter >converter</parameter >,
4891
+ with any missing members from the right filled in with
4892
+ the respective default values.
4893
+ This form allows it
4873
4894
to consume a tuple emitted by the convenience functions
4874
4895
<link linkend =' v-BoolVariable' >&BoolVariable; </link >,
4875
4896
<link linkend =' v-EnumVariable' >&EnumVariable; </link >,
@@ -4902,15 +4923,12 @@ to a &Variables; object in one call;
4902
4923
equivalent to calling
4903
4924
<link linkend =' v-Add' ><function >Add</function ></link >
4904
4925
multiple times.
4905
- The <parameter >args</parameter >
4906
- are tuples (or lists)
4907
- that contain the arguments
4908
- for an individual call to the &Add; method.
4909
- Since tuples are not &Python; mappings,
4910
- the arguments cannot use the keyword form,
4911
- but rather are positional arguments as documented for &Add; :
4912
- a required name, the other four optional,
4913
- but must be in the specified order if used.
4926
+ Each <parameter >args</parameter > member
4927
+ must be a tuple that contains the arguments
4928
+ for an individual call to the &Add; method
4929
+ using the "special case" form;
4930
+ the other calling styles (individual positional
4931
+ arguments and/or keyword arguments) are not supported.
4914
4932
</para >
4915
4933
4916
4934
<programlisting language =" python" >
@@ -4927,19 +4945,26 @@ opt.AddVariables(
4927
4945
<varlistentry id =" v-Update" >
4928
4946
<term ><replaceable >vars</replaceable >.<function >Update</function >(<parameter >env, [args]</parameter >)</term >
4929
4947
<listitem >
4930
- <para >Process the arguments given as
4931
- <parameter >files</parameter > and/or
4932
- <parameter >args</parameter >
4933
- when the &Variables; object was created,
4948
+ <para >Process the input sources recorded
4949
+ when the &Variables; object was initialized
4934
4950
and update
4935
4951
<parameter >env</parameter >
4936
4952
with the customized &consvars; .
4937
- Any specified variables that are not
4953
+ The names of any variables in the input sources that are not
4938
4954
configured in the &Variables; object
4939
- will be saved and may be retrieved using the
4955
+ are recorded and may be retrieved using the
4940
4956
<link linkend =' v-UnknownVariables' >&UnknownVariables; </link >
4941
4957
method.</para >
4942
4958
4959
+ <para >
4960
+ If the optional
4961
+ <parameter >args</parameter >
4962
+ argument is provided, it is a dictionary of variables
4963
+ to use in place of the one saved when
4964
+ <link linkend =' v-Variables' >&Variables; </link >
4965
+ was called.
4966
+ </para >
4967
+
4943
4968
<para >Normally, &Update; is not called directly,
4944
4969
but rather invoked indirectly by passing the &Variables; object to
4945
4970
the &f-link-Environment; function:</para >
@@ -5177,9 +5202,9 @@ Any value that is not in
5177
5202
will raise an error.
5178
5203
More than one value may be specified,
5179
5204
separated by commas.
5180
- The default may be a string of
5181
- comma-separated default values ,
5182
- or a list of the default values.
5205
+ < parameter > default</ parameter > may be specified
5206
+ either as a string of comma-separated value ,
5207
+ or as a list of values.
5183
5208
The optional
5184
5209
<parameter >map</parameter >
5185
5210
argument is a dictionary
0 commit comments