Skip to content

Commit

Permalink
Cover a new case that I care about that isn't implemented yet
Browse files Browse the repository at this point in the history
  • Loading branch information
scottbilas committed Nov 2, 2023
1 parent 1164264 commit b862a8f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Core/DocoptUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
27 changes: 27 additions & 0 deletions src/Core/DocoptUtility.t.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}

0 comments on commit b862a8f

Please sign in to comment.