Branch: refs/heads/master
Revision: 47ffaa9
Author: ben-albrecht
Log Message:
Merge pull request #15664 from ben-albrecht/string.dedent
Add string.dedent()
This PR adds the string.dedent()
and bytes.dedent()
methods to the standard library. This feature allows one to write indented multi-line strings without the strings being indented in stdout, for example:
var helpMsg= """
Usage: chpl [flags] [source files]
Module Processing Options:
--[no-]count-tokens [Don't] count tokens in main modules
--main-module <module> Specify entry point module
-M, --module-dir <directory> Add directory to module search path
--[no-]print-code-size [Don't] print code size of main modules
--print-module-files Print module file locations
--[no-]print-search-dirs [Don't] print module search path
""".dedent();
writeln(helpMsg);
Would print:
Usage: chpl [flags] [source files]
Module Processing Options:
--[no-]count-tokens [Don't] count tokens in main modules
--main-module <module> Specify entry point module
-M, --module-dir <directory> Add directory to module search path
--[no-]print-code-size [Don't] print code size of main modules
--print-module-files Print module file locations
--[no-]print-search-dirs [Don't] print module search path
This feature is marked a unstable in the documentation and when compiling with --warn-unstable
since it is still up for discussion whether it will stay in the built-in String module or migrate to a StringUtils module if that were to be introduced in the future.
[Reviewed by @e-kayrakli]
Modified Files:
A test/types/string/methods/testDedent.chpl
A test/types/string/methods/testDedent.good
M modules/internal/Bytes.chpl
M modules/internal/BytesStringCommon.chpl
M modules/internal/String.chpl
Compare: https://github.com/chapel-lang/chapel/compare/06b1cf6e3751...47ffaa99500c