guard-boondoc 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 9808173acf5b72841dd3acdf32958970df6d11ae1b4c70d23b61d16cb36bfa04
4
+ data.tar.gz: fc81a22ac53395bf2dab91f67e91c06ca1daf72ddc578f74c3c1c8ff0a63250b
5
+ SHA512:
6
+ metadata.gz: e8c9dd7d3f8f1e5030d7f25cb1c4b7ed9f75bcbc861cef88f1f6f4d8ade66a72beeb4eda215fc5c783dce59c3b1d130052e23afc97e71f4077e22bd3d9eb3102
7
+ data.tar.gz: 0b2053246dc6a0318c243fcea83aa3944c62dfd4c16403fb8532991b7b25f927155ad9fd5276ee12a41f35d3e3ca434d00410d2fa2db6043b11002e3782f9e91
data/CHANGELOG.md ADDED
@@ -0,0 +1,8 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2026-10-26
4
+
5
+ ### ✨ Features
6
+ - **`guard :boondoc` plugin:** regenerates your Boondoc markdown docs whenever the watched files change.
7
+ - **`status_file` option:** records the outcome of each run.
8
+ - **Guardfile `watch` lines:** these override the files Boondoc would otherwise watch. Changes to the output directory never trigger a regeneration.
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2026 Joe Sharp
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,67 @@
1
+ # guard-boondoc
2
+
3
+ A [Guard](https://github.com/guard/guard) plugin that regenerates your [Boondoc](https://github.com/joe-sharp/boondoc)
4
+ docs when a file Boondoc reads changes.
5
+
6
+ ## Setup
7
+
8
+ ```ruby
9
+ # Gemfile
10
+ group :development do
11
+ gem 'guard-boondoc'
12
+ end
13
+ ```
14
+
15
+ ```sh
16
+ bundle exec guard init boondoc # adds `guard :boondoc` to your Guardfile
17
+ bundle exec guard
18
+ ```
19
+
20
+ ## What it does
21
+
22
+ The docs are generated when Guard starts, and again whenever one of these changes, is added, or is removed:
23
+
24
+ - the Ruby files in `sources`
25
+ - the README and the `files` you stitch in
26
+ - the files matching `assets`
27
+ - `.boondoc.yml` and `.yardopts`
28
+
29
+ What to build comes from Boondoc's own configuration, not from Guardfile options. The plugin reads `.boondoc.yml` and `.yardopts` on every run, so editing them takes effect
30
+ without restarting Guard, and changes inside the output directory never trigger a run.
31
+
32
+ If Boondoc fails, for example in `strict` mode with warnings, the error is shown and Guard marks the task as
33
+ failed. The next change to a file Boondoc reads tries again.
34
+
35
+ ## Overriding what is watched
36
+
37
+ If you need to regenerate for files Boondoc doesn't read, or want full control, add your own `watch` lines:
38
+
39
+ ```ruby
40
+ guard :boondoc do
41
+ watch(%r{^templates/})
42
+ watch('.boondoc.yml')
43
+ end
44
+ ```
45
+
46
+ Any `watch` turns off the detection described above, so your patterns alone decide when the docs are regenerated.
47
+ Changes inside the output directory still never trigger a run, so a broad pattern such as `/\.md$/` is safe.
48
+
49
+ ## Recording the outcome
50
+
51
+ To let another tool, such as a status line, see how the last run went, give the plugin a `status_file`:
52
+
53
+ ```ruby
54
+ guard :boondoc, status_file: 'tmp/docs_status.txt'
55
+ ```
56
+
57
+ After each run the file holds `ok`, or `error` followed by Boondoc's message. Its directory is created if needed.
58
+
59
+ ## Development
60
+
61
+ ```sh
62
+ bundle exec rake # specs and RuboCop
63
+ ```
64
+
65
+ ## License
66
+
67
+ MIT, see [LICENSE.txt](LICENSE.txt).
@@ -0,0 +1 @@
1
+ guard :boondoc
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Guard
4
+ module BoondocVersion
5
+ VERSION = '0.1.0'
6
+ end
7
+ end
@@ -0,0 +1,128 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'fileutils'
4
+ require 'guard/compat/plugin'
5
+ require 'boondoc'
6
+ require_relative 'boondoc/version'
7
+
8
+ module Guard
9
+ # Regenerates boondoc documentation when a file boondoc reads changes.
10
+ #
11
+ # What to watch and where the docs go come from `.boondoc.yml` and
12
+ # `.yardopts`, which are read again on every run. The only option is
13
+ # `status_file`, a path the outcome of each run is written to: `ok`, or
14
+ # `error` followed by boondoc's message.
15
+ #
16
+ # @example Guardfile
17
+ # guard :boondoc
18
+ #
19
+ # @example Guardfile, recording each run's outcome
20
+ # guard :boondoc, status_file: 'tmp/docs_status.txt'
21
+ #
22
+ # @example Guardfile, overriding what is watched
23
+ # guard :boondoc do
24
+ # watch(%r{^templates/})
25
+ # end
26
+ class Boondoc < Plugin
27
+ # Files whose change can alter how every other file is read.
28
+ CONFIG_FILES = [::Boondoc::Config::FILE, '.yardopts'].freeze
29
+ GLOB_FLAGS = File::FNM_PATHNAME | File::FNM_EXTGLOB
30
+
31
+ # Watches every file, then narrows to the ones boondoc reads when they change,
32
+ # since those are only known from the configuration. Watchers given in the
33
+ # Guardfile replace that, and then decide on their own when to regenerate.
34
+ def initialize(options = {})
35
+ super
36
+ @custom_watchers = !watchers.empty?
37
+ self.watchers = [Guard::Watcher.new(/./)] unless @custom_watchers
38
+ end
39
+
40
+ # @return [void]
41
+ def start
42
+ generate
43
+ end
44
+
45
+ # @return [void]
46
+ def reload
47
+ generate
48
+ end
49
+
50
+ # @return [void]
51
+ def run_all
52
+ generate
53
+ end
54
+
55
+ # @param paths [Array<String>] files that changed, relative to the project
56
+ # @return [void]
57
+ def run_on_modifications(paths)
58
+ paths = outside_output(paths)
59
+ return if paths.empty?
60
+
61
+ generate if @custom_watchers || relevant?(paths)
62
+ end
63
+ alias run_on_additions run_on_modifications
64
+ alias run_on_removals run_on_modifications
65
+
66
+ private
67
+
68
+ def generate
69
+ config = ::Boondoc::Config.load
70
+ ::Boondoc::Generator.new(config).run
71
+ remember(config)
72
+ record('ok')
73
+ Compat::UI.info('boondoc: docs regenerated')
74
+ rescue ::Boondoc::Error => e
75
+ record("error #{e.message}")
76
+ Compat::UI.error("boondoc: #{e.message}")
77
+ throw :task_has_failed
78
+ end
79
+
80
+ def record(status)
81
+ path = options[:status_file] or return
82
+
83
+ FileUtils.mkdir_p(File.dirname(path))
84
+ File.write(path, "#{status}\n")
85
+ end
86
+
87
+ def remember(config)
88
+ @inputs = inputs(config)
89
+ end
90
+
91
+ def inputs(config)
92
+ [config.source_files, config.extra_files, config.readme_file].flatten.compact
93
+ end
94
+
95
+ # A file is relevant if boondoc read it last run or would read it now, which
96
+ # covers files added or removed since. Everything is relevant until a run has
97
+ # succeeded, and when the configuration cannot be read.
98
+ def relevant?(paths)
99
+ return true unless @inputs
100
+
101
+ config = ::Boondoc::Config.load
102
+ known = @inputs | inputs(config)
103
+ paths.any? { |path| CONFIG_FILES.include?(path) || known.include?(path) || asset?(config, path) }
104
+ rescue ::Boondoc::Error
105
+ true
106
+ end
107
+
108
+ def asset?(config, path)
109
+ return false if in_output?(config, path)
110
+
111
+ Array(config.assets).any? { |pattern| File.fnmatch?(pattern, path, GLOB_FLAGS) }
112
+ end
113
+
114
+ # Boondoc's own output must never trigger a run, whatever the watchers match.
115
+ # When the configuration cannot be read, nothing is known to be output.
116
+ def outside_output(paths)
117
+ config = ::Boondoc::Config.load
118
+ paths.reject { |path| in_output?(config, path) }
119
+ rescue ::Boondoc::Error
120
+ paths
121
+ end
122
+
123
+ def in_output?(config, path)
124
+ output = config.output_dir.delete_prefix(File.join(config.root, ''))
125
+ path == output || path.start_with?(File.join(output, ''))
126
+ end
127
+ end
128
+ end
metadata ADDED
@@ -0,0 +1,94 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: guard-boondoc
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Joe Sharp
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: boondoc
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: '0'
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
25
+ version: '0'
26
+ - !ruby/object:Gem::Dependency
27
+ name: guard
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - "~>"
31
+ - !ruby/object:Gem::Version
32
+ version: '2.20'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '2.20'
40
+ - !ruby/object:Gem::Dependency
41
+ name: guard-compat
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '1.2'
47
+ type: :runtime
48
+ prerelease: false
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '1.2'
54
+ description: guard-boondoc watches the files boondoc reads, as set in .boondoc.yml
55
+ and .yardopts, and regenerates your markdown documentation when one of them changes.
56
+ email:
57
+ - joesharp13@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - CHANGELOG.md
63
+ - LICENSE.txt
64
+ - README.md
65
+ - lib/guard/boondoc.rb
66
+ - lib/guard/boondoc/templates/Guardfile
67
+ - lib/guard/boondoc/version.rb
68
+ homepage: https://github.com/joe-sharp/guard-boondoc
69
+ licenses:
70
+ - MIT
71
+ metadata:
72
+ homepage_uri: https://github.com/joe-sharp/guard-boondoc
73
+ source_code_uri: https://github.com/joe-sharp/guard-boondoc/tree/v0.1.0
74
+ bug_tracker_uri: https://github.com/joe-sharp/guard-boondoc/issues
75
+ changelog_uri: https://github.com/joe-sharp/guard-boondoc/blob/main/CHANGELOG.md
76
+ rubygems_mfa_required: 'true'
77
+ rdoc_options: []
78
+ require_paths:
79
+ - lib
80
+ required_ruby_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: 3.3.0
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ requirements: []
91
+ rubygems_version: 4.0.20
92
+ specification_version: 4
93
+ summary: Guard plugin that regenerates your boondoc docs when their sources change
94
+ test_files: []