From b862a8f716a8c1231be867112486edf52104479e Mon Sep 17 00:00:00 2001 From: Scott Bilas Date: Thu, 2 Nov 2023 17:13:24 +0100 Subject: [PATCH] Cover a new case that I care about that isn't implemented yet --- src/Core/DocoptUtility.cs | 4 ++++ src/Core/DocoptUtility.t.cs | 27 +++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/src/Core/DocoptUtility.cs b/src/Core/DocoptUtility.cs index cabef51..4a75cde 100644 --- a/src/Core/DocoptUtility.cs +++ b/src/Core/DocoptUtility.cs @@ -13,6 +13,10 @@ public class DocoptReflowOptions [PublicAPI] public static class DocoptUtility { + // TODO: nothing about this (once the "Usage" hack is removed) should be specific to docopt. + // can use blank lines to mean sections, detecting alignment, and - most importantly - the + // "end of last double space" rule to mean the indent point for wrapping. + public static string Reflow(string text, int wrapWidth) => Reflow(text, wrapWidth, new DocoptReflowOptions()); public static string Reflow(string text, int wrapWidth, DocoptReflowOptions options) diff --git a/src/Core/DocoptUtility.t.cs b/src/Core/DocoptUtility.t.cs index f4ce0d3..e7a65f2 100644 --- a/src/Core/DocoptUtility.t.cs +++ b/src/Core/DocoptUtility.t.cs @@ -255,4 +255,31 @@ public void Reflow_WithProgramUsage_DoesNotJoinLines() #endif } + + [Test, Category("TODO")] + public void Reflow_WithDoubleSpace_IndentsAtDoubleSpace() + { + Reflow( + "Options:\n"+ + " --thingy This is a really long line that should be wrapping at the double space\n"+ + " * first: This one should not wrap at '* ' but instead at 'This'\n"+ + " * second: This one should also wrap at the 'This' and not before that\n", + 50).ShouldBe( + // WHAT WE WANT + // "Options:\n"+ + // " --thingy This is a really long line that should\n"+ + // " be wrapping at the double space\n"+ + // " * first: This one should not wrap at '* '\n"+ + // " but instead at 'This'\n"+ + // " * second: This one should also wrap at the\n"+ + // " 'This' and not before that"); + // WHAT WE ACTUALLY GET + "Options:\n"+ + " --thingy This is a really long line that should\n"+ + " be wrapping at the double space\n"+ + " * first: This one should not wrap at '* '\n"+ + " but instead at 'This'\n"+ + " * second: This one should also wrap at the\n"+ + " 'This' and not before that"); + } }