From cedc1e4799909952a701efabed40a0f0e6107852 Mon Sep 17 00:00:00 2001 From: Matt Sturgeon Date: Tue, 28 May 2024 22:16:32 +0100 Subject: [PATCH] lib/options: use code-block for multiline defaults Detect whether a plugin default is multiline using `hasInfix "\n"`. Also remove `multiline=false` from the `toPretty` call. --- lib/options.nix | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/options.nix b/lib/options.nix index 34b6d155..6f2c09d6 100644 --- a/lib/options.nix +++ b/lib/options.nix @@ -64,12 +64,13 @@ rec { # Assume a string default is already formatted as intended, # historically strings were the only type accepted here. # TODO consider deprecating this behavior so we can properly quote strings - if isString defaultValue then - defaultValue - else - generators.toPretty { multiline = false; } defaultValue; + if isString defaultValue then defaultValue else generators.toPretty { } defaultValue; in - "Plugin default: `${default}`"; + "Plugin default:" + + ( + # Detect whether `default` is multiline or inline: + if hasInfix "\n" default then "\n\n```nix\n${default}\n```" else " `${default}`" + ); mkDesc = default: desc: