work
authorBen Pfaff <blp@cs.stanford.edu>
Sun, 18 Aug 2024 23:53:05 +0000 (16:53 -0700)
committerBen Pfaff <blp@cs.stanford.edu>
Sun, 18 Aug 2024 23:53:05 +0000 (16:53 -0700)
rust/src/output/pivot/mod.rs

index 9336cc0bd47d4c04bdf5b201759e710fdfd7a13d..fde78fbd81977eccfd37bbc214d3567ffe0a3472 100644 (file)
@@ -460,13 +460,52 @@ pub struct Footnote {
     show: bool,
 }
 
+/// The content of a single pivot table cell.
+///
+/// A [Value] is also a pivot table's title, caption, footnote marker and
+/// contents, and so on.
+///
+/// A given [Value] is one of:
+///
+/// 1. A number resulting from a calculation.
+///
+///    A number has an associated display format (usually [F] or [Pct]).  This
+///    format can be set directly, but that is not usually the easiest way.
+///    Instead, it is usually true that all of the values in a single category
+///    should have the same format (e.g. all "Significance" values might use
+///    format `F40.3`), so PSPP makes it easy to set the default format for a
+///    category while creating the category.  See pivot_dimension_create() for
+///    more details.
+///
+///    [F]: crate::format::Format::F
+///    [Pct]: crate::format::Format::Pct
+///
+/// 2. A numeric or string value obtained from data (PIVOT_VALUE_NUMERIC or
+///    PIVOT_VALUE_STRING).  If such a value corresponds to a variable, then the
+///    variable's name can be attached to the pivot_value.  If the value has a
+///    value label, then that can also be attached.  When a label is present,
+///    the user can control whether to show the value or the label or both.
+///
+/// 3. A variable name (PIVOT_VALUE_VARIABLE).  The variable label, if any, can
+///    be attached too, and again the user can control whether to show the value
+///    or the label or both.
+///
+/// 4. A text string (PIVOT_VALUE_TEXT).  The value stores the string in English
+///    and translated into the output language (localized).  Use
+///    pivot_value_new_text() or pivot_value_new_text_format() for those cases.
+///    In some cases, only an English or a localized version is available for
+///    one reason or another, although this is regrettable; in those cases, use
+///    pivot_value_new_user_text() or pivot_value_new_user_text_nocopy().
+///
+/// 5. A template. PSPP doesn't create these itself yet, but it can read and
+///    interpret those created by SPSS.
 pub struct Value {
     styling: Option<Box<ValueStyle>>,
     inner: ValueInner,
 }
 
 pub enum ValueInner {
-    Numeric {
+    Number {
         show: ValueShow,
         format: Spec,
         honor_small: bool,
@@ -506,5 +545,5 @@ pub struct ValueStyle {
     font_style: FontStyle,
     cell_style: CellStyle,
     subscripts: Vec<String>,
-    footnote_indexes: Vec<usize>
+    footnote_indexes: Vec<usize>,
 }