rundoc 4.1.4 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +2 -1
- data/.standard.yml +1 -1
- data/CHANGELOG.md +7 -0
- data/README.md +36 -9
- data/lib/rundoc/cli.rb +4 -1
- data/lib/rundoc/code_command/background/log/clear.rb +12 -2
- data/lib/rundoc/code_command/background/log/read.rb +12 -2
- data/lib/rundoc/code_command/background/process_spawn.rb +3 -1
- data/lib/rundoc/code_command/background/start.rb +25 -6
- data/lib/rundoc/code_command/background/stdin_write.rb +21 -8
- data/lib/rundoc/code_command/background/stop.rb +12 -2
- data/lib/rundoc/code_command/background/wait.rb +15 -3
- data/lib/rundoc/code_command/background.rb +2 -0
- data/lib/rundoc/code_command/bash/cd.rb +7 -7
- data/lib/rundoc/code_command/bash.rb +43 -19
- data/lib/rundoc/code_command/comment.rb +33 -0
- data/lib/rundoc/code_command/deferred.rb +66 -0
- data/lib/rundoc/code_command/file_command/append.rb +29 -8
- data/lib/rundoc/code_command/file_command/remove.rb +27 -5
- data/lib/rundoc/code_command/no_such_command.rb +8 -3
- data/lib/rundoc/code_command/pipe.rb +36 -16
- data/lib/rundoc/code_command/pre/erb.rb +28 -18
- data/lib/rundoc/code_command/print/erb.rb +28 -4
- data/lib/rundoc/code_command/print/text.rb +27 -8
- data/lib/rundoc/code_command/raw.rb +17 -5
- data/lib/rundoc/code_command/rundoc/require.rb +25 -17
- data/lib/rundoc/code_command/rundoc_command.rb +21 -8
- data/lib/rundoc/code_command/website/driver.rb +2 -0
- data/lib/rundoc/code_command/website/navigate.rb +18 -12
- data/lib/rundoc/code_command/website/screenshot.rb +17 -11
- data/lib/rundoc/code_command/website/visit.rb +23 -12
- data/lib/rundoc/code_command/website.rb +2 -0
- data/lib/rundoc/code_command/write.rb +37 -9
- data/lib/rundoc/code_command.rb +5 -48
- data/lib/rundoc/context/after_build.rb +2 -0
- data/lib/rundoc/context/execution.rb +2 -0
- data/lib/rundoc/document.rb +6 -2
- data/lib/rundoc/fenced_code_block.rb +10 -7
- data/lib/rundoc/peg_parser.rb +17 -9
- data/lib/rundoc/version.rb +3 -1
- data/lib/rundoc.rb +52 -17
- data/rundoc.gemspec +2 -0
- data/test/rundoc/code_commands/append_file_test.rb +35 -10
- data/test/rundoc/code_commands/background_test.rb +24 -22
- data/test/rundoc/code_commands/bash_test.rb +10 -5
- data/test/rundoc/code_commands/comment_test.rb +116 -0
- data/test/rundoc/code_commands/pipe_test.rb +2 -2
- data/test/rundoc/code_commands/print_test.rb +13 -25
- data/test/rundoc/code_commands/remove_contents_test.rb +8 -3
- data/test/rundoc/code_section_test.rb +28 -21
- data/test/rundoc/peg_parser_test.rb +17 -1
- data/test/test_helper.rb +4 -2
- metadata +6 -6
- data/lib/rundoc/code_command/rundoc/depend_on.rb +0 -13
- data/test/fixtures/depend_on/dependency/rundoc.md +0 -5
- data/test/fixtures/depend_on/main/rundoc.md +0 -10
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
require "test_helper"
|
|
2
|
+
|
|
3
|
+
class CommentTest < Minitest::Test
|
|
4
|
+
def test_comment_runner_call_returns_empty_string
|
|
5
|
+
io = StringIO.new
|
|
6
|
+
runner = Rundoc::CodeCommand::CommentRunner.new(
|
|
7
|
+
render_command: false,
|
|
8
|
+
render_result: false,
|
|
9
|
+
io: io,
|
|
10
|
+
user_args: Rundoc::CodeCommand::CommentArgs.new("$ cat hello")
|
|
11
|
+
)
|
|
12
|
+
assert_equal "", runner.call
|
|
13
|
+
assert_equal "", runner.to_md
|
|
14
|
+
assert_equal "Skipping command (commented out): # $ cat hello\n", io.string
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def test_comment_with_contents
|
|
18
|
+
io = StringIO.new
|
|
19
|
+
runner = Rundoc::CodeCommand::CommentRunner.new(
|
|
20
|
+
render_command: false,
|
|
21
|
+
render_result: false,
|
|
22
|
+
io: io,
|
|
23
|
+
user_args: Rundoc::CodeCommand::CommentArgs.new("$ tail -n 2"),
|
|
24
|
+
contents: "foo\nbar\nbaz\n"
|
|
25
|
+
)
|
|
26
|
+
assert_equal "", runner.call
|
|
27
|
+
expected = <<~EOF
|
|
28
|
+
Skipping command (commented out): # $ tail -n 2
|
|
29
|
+
foo
|
|
30
|
+
bar
|
|
31
|
+
baz
|
|
32
|
+
EOF
|
|
33
|
+
assert_equal expected.strip, io.string.strip
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def test_comment_is_noop_in_document
|
|
37
|
+
contents = <<~EOF
|
|
38
|
+
before
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
:::>> # $ cat hello
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
after
|
|
45
|
+
EOF
|
|
46
|
+
|
|
47
|
+
Dir.mktmpdir do |dir|
|
|
48
|
+
Dir.chdir(dir) do
|
|
49
|
+
parsed = parse_contents(contents)
|
|
50
|
+
actual = strip_autogen_warning(parsed.to_md)
|
|
51
|
+
assert_equal "before\n\n\nafter\n", actual
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def test_smudged_comment
|
|
57
|
+
contents = <<~EOF
|
|
58
|
+
before
|
|
59
|
+
|
|
60
|
+
```
|
|
61
|
+
:::>> #$ cat hello
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
after
|
|
65
|
+
EOF
|
|
66
|
+
|
|
67
|
+
Dir.mktmpdir do |dir|
|
|
68
|
+
Dir.chdir(dir) do
|
|
69
|
+
parsed = parse_contents(contents)
|
|
70
|
+
actual = strip_autogen_warning(parsed.to_md)
|
|
71
|
+
assert_equal "before\n\n\nafter\n", actual
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def test_bare_comment_is_noop
|
|
77
|
+
contents = <<~EOF
|
|
78
|
+
before
|
|
79
|
+
|
|
80
|
+
```
|
|
81
|
+
:::>> #
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
after
|
|
85
|
+
EOF
|
|
86
|
+
|
|
87
|
+
Dir.mktmpdir do |dir|
|
|
88
|
+
Dir.chdir(dir) do
|
|
89
|
+
parsed = parse_contents(contents)
|
|
90
|
+
actual = strip_autogen_warning(parsed.to_md)
|
|
91
|
+
assert_equal "before\n\n\nafter\n", actual
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
def test_comment_does_not_affect_other_commands
|
|
97
|
+
contents = <<~EOF
|
|
98
|
+
before
|
|
99
|
+
|
|
100
|
+
```
|
|
101
|
+
:::>> # this is commented out
|
|
102
|
+
:::>> $ echo "hello"
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
after
|
|
106
|
+
EOF
|
|
107
|
+
|
|
108
|
+
Dir.mktmpdir do |dir|
|
|
109
|
+
Dir.chdir(dir) do
|
|
110
|
+
parsed = parse_contents(contents)
|
|
111
|
+
actual = strip_autogen_warning(parsed.to_md)
|
|
112
|
+
assert_equal "before\n\n```\n$ echo \"hello\"\nhello\n```\n\nafter\n", actual
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
end
|
|
@@ -5,7 +5,7 @@ class PipeTest < Minitest::Test
|
|
|
5
5
|
pipe_cmd = "tail -n 2"
|
|
6
6
|
cmd = "ls"
|
|
7
7
|
out = `#{cmd}`
|
|
8
|
-
pipe = Rundoc::CodeCommand::
|
|
8
|
+
pipe = Rundoc::CodeCommand::PipeRunner.new(render_command: false, render_result: false, io: StringIO.new, user_args: Rundoc::CodeCommand::PipeArgs.new(pipe_cmd))
|
|
9
9
|
actual = pipe.call(commands: [{command: cmd, output: out}])
|
|
10
10
|
|
|
11
11
|
expected = `#{cmd} | #{pipe_cmd}`
|
|
@@ -16,7 +16,7 @@ class PipeTest < Minitest::Test
|
|
|
16
16
|
pipe_cmd = "tail -n 2"
|
|
17
17
|
cmd = "ls"
|
|
18
18
|
out = `#{cmd}`
|
|
19
|
-
pipe = Rundoc::CodeCommand::
|
|
19
|
+
pipe = Rundoc::CodeCommand::PipeRunner.new(render_command: false, render_result: false, io: StringIO.new, user_args: Rundoc::CodeCommand::PipeArgs.new("$ #{pipe_cmd}"))
|
|
20
20
|
actual = pipe.call(commands: [{command: cmd, output: out}])
|
|
21
21
|
|
|
22
22
|
expected = `#{cmd} | #{pipe_cmd}`
|
|
@@ -6,9 +6,7 @@ class PrintTest < Minitest::Test
|
|
|
6
6
|
env[:before] = []
|
|
7
7
|
|
|
8
8
|
input = %($ rails new myapp # Not a command since it's missing the ":::>>")
|
|
9
|
-
cmd = Rundoc::CodeCommand::
|
|
10
|
-
cmd.render_command = false
|
|
11
|
-
cmd.render_result = true
|
|
9
|
+
cmd = Rundoc::CodeCommand::PrintTextRunner.new(user_args: Rundoc::CodeCommand::PrintTextArgs.new(input), io: StringIO.new, render_command: false, render_result: true)
|
|
12
10
|
|
|
13
11
|
assert_equal "", cmd.to_md(env)
|
|
14
12
|
assert_equal "", cmd.call
|
|
@@ -20,9 +18,7 @@ class PrintTest < Minitest::Test
|
|
|
20
18
|
env[:before] = []
|
|
21
19
|
|
|
22
20
|
input = %($ rails new myapp # Not a command since it's missing the ":::>>")
|
|
23
|
-
cmd = Rundoc::CodeCommand::
|
|
24
|
-
cmd.render_command = true
|
|
25
|
-
cmd.render_result = true
|
|
21
|
+
cmd = Rundoc::CodeCommand::PrintTextRunner.new(user_args: Rundoc::CodeCommand::PrintTextArgs.new(input), io: StringIO.new, render_command: true, render_result: true)
|
|
26
22
|
|
|
27
23
|
assert_equal "", cmd.to_md(env)
|
|
28
24
|
assert_equal input, cmd.call
|
|
@@ -35,9 +31,7 @@ class PrintTest < Minitest::Test
|
|
|
35
31
|
env[:before] = []
|
|
36
32
|
|
|
37
33
|
input = %($ rails new <%= 'myapp' %> # Not a command since it's missing the ":::>>")
|
|
38
|
-
cmd = Rundoc::CodeCommand::
|
|
39
|
-
cmd.render_command = false
|
|
40
|
-
cmd.render_result = true
|
|
34
|
+
cmd = Rundoc::CodeCommand::PrintERBRunner.new(user_args: Rundoc::CodeCommand::PrintERBArgs.new(input), io: StringIO.new, render_command: false, render_result: true)
|
|
41
35
|
|
|
42
36
|
assert_equal "", cmd.to_md(env)
|
|
43
37
|
assert_equal "", cmd.call
|
|
@@ -49,10 +43,7 @@ class PrintTest < Minitest::Test
|
|
|
49
43
|
env = {}
|
|
50
44
|
env[:before] = []
|
|
51
45
|
|
|
52
|
-
cmd = Rundoc::CodeCommand::
|
|
53
|
-
cmd.contents = %(<%= "foo" %>)
|
|
54
|
-
cmd.render_command = true
|
|
55
|
-
cmd.render_result = true
|
|
46
|
+
cmd = Rundoc::CodeCommand::PrintERBRunner.new(user_args: Rundoc::CodeCommand::PrintERBArgs.new, io: StringIO.new, render_command: true, render_result: true, contents: %(<%= "foo" %>))
|
|
56
47
|
|
|
57
48
|
assert_equal "", cmd.to_md(env)
|
|
58
49
|
assert_equal "foo", cmd.call
|
|
@@ -62,10 +53,13 @@ class PrintTest < Minitest::Test
|
|
|
62
53
|
def test_binding_is_preserved
|
|
63
54
|
env = {}
|
|
64
55
|
env[:before] = []
|
|
65
|
-
cmd = Rundoc::CodeCommand::
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
56
|
+
cmd = Rundoc::CodeCommand::PrintERBRunner.new(
|
|
57
|
+
user_args: Rundoc::CodeCommand::PrintERBArgs.new,
|
|
58
|
+
io: StringIO.new,
|
|
59
|
+
contents: %{<%= @foo = SecureRandom.hex(16) %>},
|
|
60
|
+
render_command: true,
|
|
61
|
+
render_result: true
|
|
62
|
+
)
|
|
69
63
|
|
|
70
64
|
assert_equal "", cmd.to_md(env)
|
|
71
65
|
assert_equal [], env[:before]
|
|
@@ -73,19 +67,13 @@ class PrintTest < Minitest::Test
|
|
|
73
67
|
|
|
74
68
|
assert !expected.empty?
|
|
75
69
|
|
|
76
|
-
cmd = Rundoc::CodeCommand::
|
|
77
|
-
cmd.contents = %(<%= @foo %>)
|
|
78
|
-
cmd.render_command = true
|
|
79
|
-
cmd.render_result = true
|
|
70
|
+
cmd = Rundoc::CodeCommand::PrintERBRunner.new(user_args: Rundoc::CodeCommand::PrintERBArgs.new, io: StringIO.new, render_command: true, render_result: true, contents: %(<%= @foo %>))
|
|
80
71
|
|
|
81
72
|
assert_equal "", cmd.to_md(env)
|
|
82
73
|
assert_equal expected, cmd.call
|
|
83
74
|
assert_equal [], env[:before]
|
|
84
75
|
|
|
85
|
-
cmd = Rundoc::CodeCommand::
|
|
86
|
-
cmd.contents = %(<%= @foo %>)
|
|
87
|
-
cmd.render_command = true
|
|
88
|
-
cmd.render_result = true
|
|
76
|
+
cmd = Rundoc::CodeCommand::PrintERBRunner.new(user_args: Rundoc::CodeCommand::PrintERBArgs.new(binding: "different"), io: StringIO.new, render_command: true, render_result: true, contents: %(<%= @foo %>))
|
|
89
77
|
|
|
90
78
|
assert_equal "", cmd.to_md(env)
|
|
91
79
|
assert_equal "", cmd.call
|
|
@@ -21,8 +21,13 @@ class RemoveContentsTest < Minitest::Test
|
|
|
21
21
|
|
|
22
22
|
assert_match(/sqlite3/, File.read(@file))
|
|
23
23
|
|
|
24
|
-
cc = Rundoc::CodeCommand::FileCommand::
|
|
25
|
-
|
|
24
|
+
cc = Rundoc::CodeCommand::FileCommand::RemoveRunner.new(
|
|
25
|
+
render_command: false,
|
|
26
|
+
render_result: false,
|
|
27
|
+
user_args: Rundoc::CodeCommand::FileCommand::RemoveArgs.new(@file),
|
|
28
|
+
contents: "gem 'sqlite3'",
|
|
29
|
+
io: StringIO.new
|
|
30
|
+
)
|
|
26
31
|
cc.call
|
|
27
32
|
|
|
28
33
|
refute_match(/sqlite3/, File.read(@file))
|
|
@@ -33,7 +38,7 @@ class RemoveContentsTest < Minitest::Test
|
|
|
33
38
|
env[:fence_start] = "```ruby"
|
|
34
39
|
cc.to_md(env)
|
|
35
40
|
|
|
36
|
-
assert_equal ["In file `foo.rb` remove:", Rundoc::CodeCommand::NEWLINE], env[:before]
|
|
41
|
+
assert_equal ["In file `foo.rb` remove:", Rundoc::CodeCommand::FileCommand::RemoveRunner::NEWLINE], env[:before]
|
|
37
42
|
end
|
|
38
43
|
end
|
|
39
44
|
end
|
|
@@ -19,7 +19,8 @@ class CodeSectionTest < Minitest::Test
|
|
|
19
19
|
fence: match[:fence],
|
|
20
20
|
lang: match[:lang],
|
|
21
21
|
code: match[:contents],
|
|
22
|
-
context: default_context
|
|
22
|
+
context: default_context,
|
|
23
|
+
io: StringIO.new
|
|
23
24
|
).render
|
|
24
25
|
assert_equal "", result
|
|
25
26
|
end
|
|
@@ -39,7 +40,8 @@ class CodeSectionTest < Minitest::Test
|
|
|
39
40
|
fence: match[:fence],
|
|
40
41
|
lang: match[:lang],
|
|
41
42
|
code: match[:contents],
|
|
42
|
-
context: default_context
|
|
43
|
+
context: default_context,
|
|
44
|
+
io: StringIO.new
|
|
43
45
|
).render
|
|
44
46
|
assert_equal contents, result.gsub(Rundoc::FencedCodeBlock::AUTOGEN_WARNING, "\n")
|
|
45
47
|
end
|
|
@@ -56,13 +58,14 @@ class CodeSectionTest < Minitest::Test
|
|
|
56
58
|
fence: match[:fence],
|
|
57
59
|
lang: match[:lang],
|
|
58
60
|
code: match[:contents],
|
|
59
|
-
context: default_context
|
|
61
|
+
context: default_context,
|
|
62
|
+
io: StringIO.new
|
|
60
63
|
)
|
|
61
64
|
code_section.render
|
|
62
65
|
|
|
63
66
|
code_command = code_section.executed_commands.first
|
|
64
|
-
assert_equal true, code_command.render_command
|
|
65
|
-
assert_equal false, code_command.render_result
|
|
67
|
+
assert_equal true, code_command.render_command?
|
|
68
|
+
assert_equal false, code_command.render_result?
|
|
66
69
|
|
|
67
70
|
contents = <<~RUBY
|
|
68
71
|
```
|
|
@@ -75,13 +78,14 @@ class CodeSectionTest < Minitest::Test
|
|
|
75
78
|
fence: match[:fence],
|
|
76
79
|
lang: match[:lang],
|
|
77
80
|
code: match[:contents],
|
|
78
|
-
context: default_context
|
|
81
|
+
context: default_context,
|
|
82
|
+
io: StringIO.new
|
|
79
83
|
)
|
|
80
84
|
code_section.render
|
|
81
85
|
|
|
82
86
|
code_command = code_section.executed_commands.first
|
|
83
|
-
assert_equal true, code_command.render_command
|
|
84
|
-
assert_equal false, code_command.render_result
|
|
87
|
+
assert_equal true, code_command.render_command?
|
|
88
|
+
assert_equal false, code_command.render_result?
|
|
85
89
|
end
|
|
86
90
|
|
|
87
91
|
def test_show_command_show_render
|
|
@@ -96,14 +100,14 @@ class CodeSectionTest < Minitest::Test
|
|
|
96
100
|
fence: match[:fence],
|
|
97
101
|
lang: match[:lang],
|
|
98
102
|
code: match[:contents],
|
|
99
|
-
context: default_context
|
|
103
|
+
context: default_context,
|
|
104
|
+
io: StringIO.new
|
|
100
105
|
)
|
|
101
106
|
code_section.render
|
|
102
107
|
|
|
103
|
-
puts code_section.executed_commands.inspect
|
|
104
108
|
code_command = code_section.executed_commands.first
|
|
105
|
-
assert_equal true, code_command.render_command
|
|
106
|
-
assert_equal true, code_command.render_result
|
|
109
|
+
assert_equal true, code_command.render_command?
|
|
110
|
+
assert_equal true, code_command.render_result?
|
|
107
111
|
end
|
|
108
112
|
|
|
109
113
|
def test_hide_command_hide_render
|
|
@@ -118,13 +122,14 @@ class CodeSectionTest < Minitest::Test
|
|
|
118
122
|
fence: match[:fence],
|
|
119
123
|
lang: match[:lang],
|
|
120
124
|
code: match[:contents],
|
|
121
|
-
context: default_context
|
|
125
|
+
context: default_context,
|
|
126
|
+
io: StringIO.new
|
|
122
127
|
)
|
|
123
128
|
code_section.render
|
|
124
129
|
|
|
125
130
|
code_command = code_section.executed_commands.first
|
|
126
|
-
assert_equal false, code_command.render_command
|
|
127
|
-
assert_equal false, code_command.render_result
|
|
131
|
+
assert_equal false, code_command.render_command?
|
|
132
|
+
assert_equal false, code_command.render_result?
|
|
128
133
|
|
|
129
134
|
contents = <<~RUBY
|
|
130
135
|
```
|
|
@@ -137,13 +142,14 @@ class CodeSectionTest < Minitest::Test
|
|
|
137
142
|
fence: match[:fence],
|
|
138
143
|
lang: match[:lang],
|
|
139
144
|
code: match[:contents],
|
|
140
|
-
context: default_context
|
|
145
|
+
context: default_context,
|
|
146
|
+
io: StringIO.new
|
|
141
147
|
)
|
|
142
148
|
code_section.render
|
|
143
149
|
|
|
144
150
|
code_command = code_section.executed_commands.first
|
|
145
|
-
assert_equal false, code_command.render_command
|
|
146
|
-
assert_equal false, code_command.render_result
|
|
151
|
+
assert_equal false, code_command.render_command?
|
|
152
|
+
assert_equal false, code_command.render_result?
|
|
147
153
|
end
|
|
148
154
|
|
|
149
155
|
def test_hide_command_show_render
|
|
@@ -158,12 +164,13 @@ class CodeSectionTest < Minitest::Test
|
|
|
158
164
|
fence: match[:fence],
|
|
159
165
|
lang: match[:lang],
|
|
160
166
|
code: match[:contents],
|
|
161
|
-
context: default_context
|
|
167
|
+
context: default_context,
|
|
168
|
+
io: StringIO.new
|
|
162
169
|
)
|
|
163
170
|
code_section.render
|
|
164
171
|
|
|
165
172
|
code_command = code_section.executed_commands.first
|
|
166
|
-
assert_equal false, code_command.render_command
|
|
167
|
-
assert_equal true, code_command.render_result
|
|
173
|
+
assert_equal false, code_command.render_command?
|
|
174
|
+
assert_equal true, code_command.render_result?
|
|
168
175
|
end
|
|
169
176
|
end
|
|
@@ -249,7 +249,8 @@ class PegParserTest < Minitest::Test
|
|
|
249
249
|
|
|
250
250
|
actual = @transformer.apply(tree)
|
|
251
251
|
assert_equal :rundoc, actual.keyword
|
|
252
|
-
|
|
252
|
+
assert_nil actual.original_args
|
|
253
|
+
assert_equal("email = ENV['HEROKU_EMAIL'] || `heroku auth:whoami`\n", actual.contents)
|
|
253
254
|
end
|
|
254
255
|
|
|
255
256
|
def test_rundoc_sub_commands_no_quotes
|
|
@@ -351,4 +352,19 @@ class PegParserTest < Minitest::Test
|
|
|
351
352
|
assert_equal :"background.start", actual.keyword
|
|
352
353
|
assert_equal ["rails server", {name: "server"}], actual.original_args
|
|
353
354
|
end
|
|
355
|
+
|
|
356
|
+
def test_no_args_preserves_newlines_in_stdin
|
|
357
|
+
input = <<~EOF.strip
|
|
358
|
+
:::>> rundoc
|
|
359
|
+
first = 1 # comment
|
|
360
|
+
second = 2
|
|
361
|
+
EOF
|
|
362
|
+
|
|
363
|
+
parser = Rundoc::PegParser.new.command_with_stdin
|
|
364
|
+
tree = parser.parse_with_debug(input)
|
|
365
|
+
|
|
366
|
+
actual = @transformer.apply(tree)
|
|
367
|
+
assert_equal :rundoc, actual.keyword
|
|
368
|
+
assert_equal "first = 1 # comment\nsecond = 2".strip, actual.contents.strip
|
|
369
|
+
end
|
|
354
370
|
end
|
data/test/test_helper.rb
CHANGED
|
@@ -33,7 +33,8 @@ class Minitest::Test
|
|
|
33
33
|
contents,
|
|
34
34
|
output_dir: nil,
|
|
35
35
|
source_path: nil,
|
|
36
|
-
screenshots_dirname: nil
|
|
36
|
+
screenshots_dirname: nil,
|
|
37
|
+
io: StringIO.new
|
|
37
38
|
)
|
|
38
39
|
context = default_context(
|
|
39
40
|
output_dir: output_dir,
|
|
@@ -42,7 +43,8 @@ class Minitest::Test
|
|
|
42
43
|
)
|
|
43
44
|
Rundoc::Document.new(
|
|
44
45
|
contents,
|
|
45
|
-
context: context
|
|
46
|
+
context: context,
|
|
47
|
+
io: io
|
|
46
48
|
)
|
|
47
49
|
end
|
|
48
50
|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rundoc
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 5.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Richard Schneeman
|
|
@@ -210,6 +210,8 @@ files:
|
|
|
210
210
|
- lib/rundoc/code_command/background/wait.rb
|
|
211
211
|
- lib/rundoc/code_command/bash.rb
|
|
212
212
|
- lib/rundoc/code_command/bash/cd.rb
|
|
213
|
+
- lib/rundoc/code_command/comment.rb
|
|
214
|
+
- lib/rundoc/code_command/deferred.rb
|
|
213
215
|
- lib/rundoc/code_command/file_command/append.rb
|
|
214
216
|
- lib/rundoc/code_command/file_command/remove.rb
|
|
215
217
|
- lib/rundoc/code_command/no_such_command.rb
|
|
@@ -218,7 +220,6 @@ files:
|
|
|
218
220
|
- lib/rundoc/code_command/print/erb.rb
|
|
219
221
|
- lib/rundoc/code_command/print/text.rb
|
|
220
222
|
- lib/rundoc/code_command/raw.rb
|
|
221
|
-
- lib/rundoc/code_command/rundoc/depend_on.rb
|
|
222
223
|
- lib/rundoc/code_command/rundoc/require.rb
|
|
223
224
|
- lib/rundoc/code_command/rundoc_command.rb
|
|
224
225
|
- lib/rundoc/code_command/website.rb
|
|
@@ -248,8 +249,6 @@ files:
|
|
|
248
249
|
- test/fixtures/cnb/shared/procfile.md
|
|
249
250
|
- test/fixtures/cnb/shared/use_the_image.md
|
|
250
251
|
- test/fixtures/cnb/shared/what_is_a_builder.md
|
|
251
|
-
- test/fixtures/depend_on/dependency/rundoc.md
|
|
252
|
-
- test/fixtures/depend_on/main/rundoc.md
|
|
253
252
|
- test/fixtures/java/rundoc.md
|
|
254
253
|
- test/fixtures/play/source.md
|
|
255
254
|
- test/fixtures/rails_4/rundoc.md
|
|
@@ -273,6 +272,7 @@ files:
|
|
|
273
272
|
- test/rundoc/code_commands/append_file_test.rb
|
|
274
273
|
- test/rundoc/code_commands/background_test.rb
|
|
275
274
|
- test/rundoc/code_commands/bash_test.rb
|
|
275
|
+
- test/rundoc/code_commands/comment_test.rb
|
|
276
276
|
- test/rundoc/code_commands/pipe_test.rb
|
|
277
277
|
- test/rundoc/code_commands/print_test.rb
|
|
278
278
|
- test/rundoc/code_commands/remove_contents_test.rb
|
|
@@ -294,14 +294,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
294
294
|
requirements:
|
|
295
295
|
- - ">="
|
|
296
296
|
- !ruby/object:Gem::Version
|
|
297
|
-
version: '
|
|
297
|
+
version: '3.2'
|
|
298
298
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
299
299
|
requirements:
|
|
300
300
|
- - ">="
|
|
301
301
|
- !ruby/object:Gem::Version
|
|
302
302
|
version: '0'
|
|
303
303
|
requirements: []
|
|
304
|
-
rubygems_version: 3.6.
|
|
304
|
+
rubygems_version: 3.6.9
|
|
305
305
|
specification_version: 4
|
|
306
306
|
summary: RunDOC generates runable code from docs
|
|
307
307
|
test_files: []
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
class ::Rundoc::CodeCommand
|
|
2
|
-
class RundocCommand
|
|
3
|
-
class DependOn < ::Rundoc::CodeCommand
|
|
4
|
-
# Pass in the relative path of another rundoc document in order to
|
|
5
|
-
# run all of it's commands (but not to )
|
|
6
|
-
def initialize(path)
|
|
7
|
-
raise "rundoc.depend_on has been removed, use `:::-- rundoc.require` instead"
|
|
8
|
-
end
|
|
9
|
-
end
|
|
10
|
-
end
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
Rundoc.register_code_command(:"rundoc.depend_on", ::Rundoc::CodeCommand::RundocCommand::DependOn)
|