rundoc 4.1.3 → 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.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +2 -1
  3. data/.standard.yml +1 -1
  4. data/CHANGELOG.md +12 -0
  5. data/README.md +36 -9
  6. data/lib/rundoc/cli.rb +6 -3
  7. data/lib/rundoc/code_command/background/log/clear.rb +12 -2
  8. data/lib/rundoc/code_command/background/log/read.rb +12 -2
  9. data/lib/rundoc/code_command/background/process_spawn.rb +9 -5
  10. data/lib/rundoc/code_command/background/start.rb +25 -6
  11. data/lib/rundoc/code_command/background/stdin_write.rb +21 -8
  12. data/lib/rundoc/code_command/background/stop.rb +12 -2
  13. data/lib/rundoc/code_command/background/wait.rb +15 -3
  14. data/lib/rundoc/code_command/background.rb +2 -0
  15. data/lib/rundoc/code_command/bash/cd.rb +7 -7
  16. data/lib/rundoc/code_command/bash.rb +43 -19
  17. data/lib/rundoc/code_command/comment.rb +33 -0
  18. data/lib/rundoc/code_command/deferred.rb +66 -0
  19. data/lib/rundoc/code_command/file_command/append.rb +29 -8
  20. data/lib/rundoc/code_command/file_command/remove.rb +27 -5
  21. data/lib/rundoc/code_command/no_such_command.rb +8 -3
  22. data/lib/rundoc/code_command/pipe.rb +36 -16
  23. data/lib/rundoc/code_command/pre/erb.rb +28 -18
  24. data/lib/rundoc/code_command/print/erb.rb +28 -4
  25. data/lib/rundoc/code_command/print/text.rb +27 -8
  26. data/lib/rundoc/code_command/raw.rb +17 -5
  27. data/lib/rundoc/code_command/rundoc/require.rb +25 -17
  28. data/lib/rundoc/code_command/rundoc_command.rb +21 -8
  29. data/lib/rundoc/code_command/website/driver.rb +25 -7
  30. data/lib/rundoc/code_command/website/navigate.rb +18 -12
  31. data/lib/rundoc/code_command/website/screenshot.rb +17 -11
  32. data/lib/rundoc/code_command/website/visit.rb +26 -14
  33. data/lib/rundoc/code_command/website.rb +2 -0
  34. data/lib/rundoc/code_command/write.rb +37 -9
  35. data/lib/rundoc/code_command.rb +5 -48
  36. data/lib/rundoc/context/after_build.rb +2 -0
  37. data/lib/rundoc/context/execution.rb +2 -0
  38. data/lib/rundoc/document.rb +6 -2
  39. data/lib/rundoc/fenced_code_block.rb +10 -7
  40. data/lib/rundoc/peg_parser.rb +17 -9
  41. data/lib/rundoc/version.rb +3 -1
  42. data/lib/rundoc.rb +52 -17
  43. data/rundoc.gemspec +2 -0
  44. data/test/integration/background_stdin_test.rb +65 -15
  45. data/test/integration/website_test.rb +19 -0
  46. data/test/rundoc/code_commands/append_file_test.rb +35 -10
  47. data/test/rundoc/code_commands/background_test.rb +26 -22
  48. data/test/rundoc/code_commands/bash_test.rb +10 -5
  49. data/test/rundoc/code_commands/comment_test.rb +116 -0
  50. data/test/rundoc/code_commands/pipe_test.rb +2 -2
  51. data/test/rundoc/code_commands/print_test.rb +13 -25
  52. data/test/rundoc/code_commands/remove_contents_test.rb +8 -3
  53. data/test/rundoc/code_section_test.rb +28 -21
  54. data/test/rundoc/peg_parser_test.rb +17 -1
  55. data/test/test_helper.rb +32 -2
  56. metadata +7 -10
  57. data/lib/rundoc/code_command/rundoc/depend_on.rb +0 -13
  58. data/test/fixtures/depend_on/dependency/rundoc.md +0 -5
  59. data/test/fixtures/depend_on/main/rundoc.md +0 -10
data/test/test_helper.rb CHANGED
@@ -9,6 +9,8 @@ require "rundoc"
9
9
  require "minitest/autorun"
10
10
  require "mocha/minitest"
11
11
  require "tmpdir"
12
+ require "socket"
13
+ require "timeout"
12
14
 
13
15
  class Minitest::Test
14
16
  SUCCESS_DIRNAME = Rundoc::CLI::DEFAULTS::ON_SUCCESS_DIR
@@ -31,7 +33,8 @@ class Minitest::Test
31
33
  contents,
32
34
  output_dir: nil,
33
35
  source_path: nil,
34
- screenshots_dirname: nil
36
+ screenshots_dirname: nil,
37
+ io: StringIO.new
35
38
  )
36
39
  context = default_context(
37
40
  output_dir: output_dir,
@@ -40,7 +43,8 @@ class Minitest::Test
40
43
  )
41
44
  Rundoc::Document.new(
42
45
  contents,
43
- context: context
46
+ context: context,
47
+ io: io
44
48
  )
45
49
  end
46
50
 
@@ -81,4 +85,30 @@ class Minitest::Test
81
85
 
82
86
  attr_reader :value
83
87
  end
88
+
89
+ # Yields port, exits unexpectedly
90
+ def tcp_unexpected_exit(timeout: 30)
91
+ Timeout.timeout(timeout) do
92
+ threads = []
93
+ server = TCPServer.new("127.0.0.1", 0)
94
+ port = server.addr[1]
95
+ threads << Thread.new do
96
+ # Accept one connection, then raise an error to simulate unexpected close
97
+ server.accept
98
+ raise "Unexpected server error!"
99
+ rescue
100
+ # Simulate crash, but let ensure run
101
+ end.tap { |t| t.abort_on_exception = false }
102
+
103
+ threads << Thread.new do
104
+ yield port
105
+ end
106
+
107
+ while threads.all?(&:alive?)
108
+ sleep 0.1
109
+ end
110
+ ensure
111
+ server.close if server && !server.closed?
112
+ end
113
+ end
84
114
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rundoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.3
4
+ version: 5.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Schneeman
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-12-16 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: thor
@@ -211,6 +210,8 @@ files:
211
210
  - lib/rundoc/code_command/background/wait.rb
212
211
  - lib/rundoc/code_command/bash.rb
213
212
  - lib/rundoc/code_command/bash/cd.rb
213
+ - lib/rundoc/code_command/comment.rb
214
+ - lib/rundoc/code_command/deferred.rb
214
215
  - lib/rundoc/code_command/file_command/append.rb
215
216
  - lib/rundoc/code_command/file_command/remove.rb
216
217
  - lib/rundoc/code_command/no_such_command.rb
@@ -219,7 +220,6 @@ files:
219
220
  - lib/rundoc/code_command/print/erb.rb
220
221
  - lib/rundoc/code_command/print/text.rb
221
222
  - lib/rundoc/code_command/raw.rb
222
- - lib/rundoc/code_command/rundoc/depend_on.rb
223
223
  - lib/rundoc/code_command/rundoc/require.rb
224
224
  - lib/rundoc/code_command/rundoc_command.rb
225
225
  - lib/rundoc/code_command/website.rb
@@ -249,8 +249,6 @@ files:
249
249
  - test/fixtures/cnb/shared/procfile.md
250
250
  - test/fixtures/cnb/shared/use_the_image.md
251
251
  - test/fixtures/cnb/shared/what_is_a_builder.md
252
- - test/fixtures/depend_on/dependency/rundoc.md
253
- - test/fixtures/depend_on/main/rundoc.md
254
252
  - test/fixtures/java/rundoc.md
255
253
  - test/fixtures/play/source.md
256
254
  - test/fixtures/rails_4/rundoc.md
@@ -274,6 +272,7 @@ files:
274
272
  - test/rundoc/code_commands/append_file_test.rb
275
273
  - test/rundoc/code_commands/background_test.rb
276
274
  - test/rundoc/code_commands/bash_test.rb
275
+ - test/rundoc/code_commands/comment_test.rb
277
276
  - test/rundoc/code_commands/pipe_test.rb
278
277
  - test/rundoc/code_commands/print_test.rb
279
278
  - test/rundoc/code_commands/remove_contents_test.rb
@@ -288,7 +287,6 @@ homepage: https://github.com/schneems/rundoc
288
287
  licenses:
289
288
  - MIT
290
289
  metadata: {}
291
- post_install_message:
292
290
  rdoc_options: []
293
291
  require_paths:
294
292
  - lib
@@ -296,15 +294,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
296
294
  requirements:
297
295
  - - ">="
298
296
  - !ruby/object:Gem::Version
299
- version: '0'
297
+ version: '3.2'
300
298
  required_rubygems_version: !ruby/object:Gem::Requirement
301
299
  requirements:
302
300
  - - ">="
303
301
  - !ruby/object:Gem::Version
304
302
  version: '0'
305
303
  requirements: []
306
- rubygems_version: 3.5.23
307
- signing_key:
304
+ rubygems_version: 3.6.9
308
305
  specification_version: 4
309
306
  summary: RunDOC generates runable code from docs
310
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)
@@ -1,5 +0,0 @@
1
- ```
2
- :::>> $ mkdir foo
3
- :::>> $ cd foo
4
- :::>> $ echo "hello" >> hello.txt
5
- ```
@@ -1,10 +0,0 @@
1
- # Hello
2
-
3
- ```
4
- :::-- rundoc.depend_on "../dependency/rundoc.md"
5
- ```
6
-
7
- ```
8
- :::>> $ ruby -e "raise 'nope' unless File.read('hello.txt').chomp == 'hello'"
9
- ```
10
-