Skip to content

Commit 62e5d52

Browse files
authored
Merge pull request #1 from invenia/cv/first-revision
Implementation of MultilineStrings package
2 parents e98cbfe + 9a15a9d commit 62e5d52

File tree

10 files changed

+467
-27
lines changed

10 files changed

+467
-27
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
Pkg.develop(PackageSpec(path=pwd()))
2929
Pkg.instantiate()
3030
using Documenter: doctest
31-
using BlockScalars
32-
doctest(BlockScalars)
31+
using MultilineStrings
32+
doctest(MultilineStrings)
3333
include("docs/make.jl")'
3434
after_success: skip

Project.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name = "BlockScalars"
1+
name = "MultilineStrings"
22
uuid = "1e8d2bf6-9821-4900-9a2f-4d87552df2bd"
33
authors = ["Invenia Technical Computing Corporation"]
44
version = "0.1.0"
@@ -8,6 +8,7 @@ julia = "1"
88

99
[extras]
1010
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
11+
YAML = "ddb6d928-2868-570f-bddf-ab3f9cf99eb6"
1112

1213
[targets]
13-
test = ["Test"]
14+
test = ["Test", "YAML"]

README.md

Lines changed: 53 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,56 @@
1-
# BlockScalars
1+
# MultilineStrings
22

3-
[![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://invenia.github.io/BlockScalars.jl/stable)
4-
[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://invenia.github.io/BlockScalars.jl/dev)
5-
[![Build Status](https://travis-ci.com/invenia/BlockScalars.jl.svg?branch=master)](https://travis-ci.com/invenia/BlockScalars.jl)
3+
[![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://invenia.github.io/MultilineStrings.jl/stable)
4+
[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://invenia.github.io/MultilineStrings.jl/dev)
5+
[![Build Status](https://travis-ci.com/invenia/MultilineStrings.jl.svg?branch=master)](https://travis-ci.com/invenia/MultilineStrings.jl)
66
[![Code Style: Blue](https://img.shields.io/badge/code%20style-blue-4495d1.svg)](https://github.com/invenia/BlueStyle)
77
[![ColPrac: Contributor's Guide on Collaborative Practices for Community Packages](https://img.shields.io/badge/ColPrac-Contributor's%20Guide-blueviolet)](https://github.com/SciML/ColPrac)
8+
9+
Tooling for manipulating multiline strings.
10+
11+
## Features
12+
13+
The package features a multiline string literal (`@m_str`), inspired from [YAML's block scalars](https://yaml-multiline.info/), which provide options for manipulating multiline string literals via a style and chomp indicator:
14+
15+
- Style indicator:
16+
- `f` replace newlines with spaces (folded)
17+
- `l` keep newlines (literal)
18+
- Chomp indicator:
19+
- `s` no newlines at the end (strip)
20+
- `c` single newline at the end (clip)
21+
- `k` keep all newlines from the end (keep)
22+
23+
The indicators are provided after the ending quote of the string (e.g. `m"hello\nworld!"fc`).
24+
If no indicators are provided the default behaviour is folded/strip.
25+
26+
## Example
27+
28+
When writing a long string literal you may want to break the string up over multiple lines in the code, to make it easier to read, but have the string be printed as a single line.
29+
Specifically, when writing an long error message you may want to break up the string over multiple lines:
30+
31+
```julia
32+
"An unexpected error has occurred which really shouldn't have happened but somehow did. Please check that the inputs to this function doesn't contain magic that may interfere with with the non-magical computation occurring on this device."
33+
```
34+
35+
Alternatively written over multiple lines:
36+
37+
```julia
38+
"An unexpected error has occurred which really shouldn't " *
39+
"have happened but somehow did. Please check that the inputs " *
40+
"to this function doesn't contain magic that may interfere with " *
41+
"with the non-magical computation occurring on this device."
42+
```
43+
44+
Writing strings this way can be cumbersome as you need to remember to add spaces between each line.
45+
The MultilineStrings package provides an alternative way of writing this using the multiline string macro:
46+
47+
```julia
48+
m"""
49+
An unexpected error has occurred which really shouldn't
50+
have happened but somehow did. Please check that the inputs
51+
to this function doesn't contain magic that may interfere with
52+
with the non-magical computation occurring on this device.
53+
"""
54+
```
55+
56+
Take note that a Julia [triple-quoted string literal](https://docs.julialang.org/en/v1/manual/strings/#Triple-Quoted-String-Literals) will leave most newlines in place.

docs/Manifest.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[[Base64]]
44
uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
55

6-
[[BlockScalars]]
6+
[[MultilineStrings]]
77
path = ".."
88
uuid = "1e8d2bf6-9821-4900-9a2f-4d87552df2bd"
99
version = "0.1.0"

docs/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[deps]
2-
BlockScalars = "1e8d2bf6-9821-4900-9a2f-4d87552df2bd"
2+
MultilineStrings = "1e8d2bf6-9821-4900-9a2f-4d87552df2bd"
33
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"

docs/make.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
using BlockScalars
1+
using MultilineStrings
22
using Documenter
33

44
makedocs(;
5-
modules=[BlockScalars],
5+
modules=[MultilineStrings],
66
authors="Invenia Technical Computing Corporation",
7-
repo="https://github.com/invenia/BlockScalars.jl/blob/{commit}{path}#L{line}",
8-
sitename="BlockScalars.jl",
7+
repo="https://github.com/invenia/MultilineStrings.jl/blob/{commit}{path}#L{line}",
8+
sitename="MultilineStrings.jl",
99
format=Documenter.HTML(;
1010
prettyurls=get(ENV, "CI", "false") == "true",
11-
canonical="https://invenia.github.io/BlockScalars.jl",
11+
canonical="https://invenia.github.io/MultilineStrings.jl",
1212
assets=String[],
1313
),
1414
pages=[
@@ -19,5 +19,5 @@ makedocs(;
1919
)
2020

2121
deploydocs(;
22-
repo="github.com/invenia/BlockScalars.jl",
22+
repo="github.com/invenia/MultilineStrings.jl",
2323
)

docs/src/index.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
```@meta
2-
CurrentModule = BlockScalars
2+
CurrentModule = MultilineStrings
33
```
44

5-
# BlockScalars
5+
# MultilineStrings
66

77
```@index
88
```
99

1010
```@autodocs
11-
Modules = [BlockScalars]
11+
Modules = [MultilineStrings]
1212
```

src/BlockScalars.jl

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)