1// Copyright (c) 2014-2019 TSUYUSATO Kitsune
2// This software is released under the MIT License.
3// http://opensource.org/licenses/mit-license.php
4
5package heredoc_test
6
7import (
8	"fmt"
9)
10
11import "github.com/MakeNowJust/heredoc"
12
13func ExampleDoc_lipsum() {
14	fmt.Print(heredoc.Doc(`
15		Lorem ipsum dolor sit amet, consectetur adipisicing elit,
16		sed do eiusmod tempor incididunt ut labore et dolore magna
17		aliqua. Ut enim ad minim veniam, ...
18	`))
19	// Output:
20	// Lorem ipsum dolor sit amet, consectetur adipisicing elit,
21	// sed do eiusmod tempor incididunt ut labore et dolore magna
22	// aliqua. Ut enim ad minim veniam, ...
23	//
24}
25
26func ExampleDoc_spec() {
27	// Single line string is no change.
28	fmt.Println(heredoc.Doc(`It is single line.`))
29	// If first line is empty, heredoc.Doc removes first line.
30	fmt.Println(heredoc.Doc(`
31		It is first line.
32		It is second line.`))
33	// If last line is empty and more little length than indents,
34	// heredoc.Doc removes last line's content.
35	fmt.Println(heredoc.Doc(`
36		Next is last line.
37	`))
38	fmt.Println("Previous is last line.")
39	// Output:
40	// It is single line.
41	// It is first line.
42	// It is second line.
43	// Next is last line.
44	//
45	// Previous is last line.
46}
47
48func ExampleDocf() {
49	libName := "github.com/MakeNowJust/heredoc"
50	author := "TSUYUSATO Kitsune (@MakeNowJust)"
51	fmt.Printf(heredoc.Docf(`
52		Library Name  : %s
53		Author        : %s
54		Repository URL: http://%s.git
55	`, libName, author, libName))
56	// Output:
57	// Library Name  : github.com/MakeNowJust/heredoc
58	// Author        : TSUYUSATO Kitsune (@MakeNowJust)
59	// Repository URL: http://github.com/MakeNowJust/heredoc.git
60}
61