lix/doc/manual
eldritch horrors 512c1f05c3 Unify and refactor value printing
Previously, there were two mostly-identical value printers -- one in
`libexpr/eval.cc` (which didn't force values) and one in
`libcmd/repl.cc` (which did force values and also printed ANSI color
codes).

This PR unifies both of these printers into `print.cc` and provides a
`PrintOptions` struct for controlling the output, which allows for
toggling whether values are forced, whether repeated values are tracked,
and whether ANSI color codes are displayed.

Additionally, `PrintOptions` allows tuning the maximum number of
attributes, list items, and bytes in a string that will be displayed;
this makes it ideal for contexts where printing too much output (e.g.
all of Nixpkgs) is distracting. (As requested by @roberth in
https://github.com/NixOS/nix/pull/9554#issuecomment-1845095735)

Please read the tests for example output.

Future work:
- It would be nice to provide this function as a builtin, perhaps
  `builtins.toStringDebug` -- a printing function that never fails would
  be useful when debugging Nix code.
- It would be nice to support customizing `PrintOptions` members on the
  command line, e.g. `--option to-string-max-attrs 1000`.

(cherry picked from commit 0fa08b4516, )

===

Restore ambiguous value printer for `nix-instantiate`

The Nix team has requested that this output format remain unchanged.
I've added a warning to the man page explaining that `nix-instantiate
--eval` output will not parse correctly in many situations.

(cherry picked from commit df84dd4d8d)

Change-Id: I7cca6b4b53cd0642f2d49af657d5676a8554c9f8
2024-03-09 03:50:06 +01:00
..
rl-next Add release notes 2024-03-07 12:29:57 -08:00
src Unify and refactor value printing 2024-03-09 03:50:06 +01:00
theme doc/manual: don't need to copy highlight.js manually 2021-08-04 19:47:05 -07:00
anchors.jq doc: Port anchors preprocessor to jq script 2022-05-26 18:17:21 +02:00
book.toml manual: Check links 2023-01-10 22:30:41 +01:00
custom.css disallow selecting shell prompt in code samples 2022-12-05 11:01:46 +01:00
generate-builtin-constants.nix revert anchor prefix for builtin constants 2023-07-20 10:27:38 +02:00
generate-builtins.nix Automatically document builtin constants 2023-06-27 09:37:54 -04:00
generate-manpage.nix Merge pull request #8931 from fricklerhandwerk/nix3-config-options 2024-03-04 04:35:54 +01:00
generate-xp-features-shortlist.nix Single page for experimental feature descriptions 2023-04-09 11:01:23 -04:00
generate-xp-features.nix Single page for experimental feature descriptions 2023-04-09 11:01:23 -04:00
local.mk Merge pull request #5145 from fedepell/local_doc_build_5140 2024-03-05 23:01:05 +01:00
quote-literals.xsl Generate release notes again 2014-03-12 14:24:29 +01:00
redirects.js fix an old lost direct (#9717) 2024-01-08 20:57:39 +01:00
utils.nix backport fix for the --help output 2023-11-10 19:22:42 +01:00