guard-yard 1.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.
data/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2011 Panayiotis Thomakos
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
data/README.markdown ADDED
@@ -0,0 +1,48 @@
1
+ # Guard::Yard
2
+
3
+ Guard::Yard allows you to automatically run and update your local YARD Documentation Server. It aims to centralize your file monitoring to guard instead of using the `yard server --reload` command which can be unreliable and provides little control over the generated documentation. Guard::Yard monitors files and updates only the documentation than changes, as opposed to generating the entire documentation suite. That means that changes to your documentation are available sooner!
4
+
5
+ ## Install
6
+
7
+ Ensure you have [Guard](https://github.com/guard/guard) installed before you continue.
8
+
9
+ Add guard-yard to your Gemfile (inside development group):
10
+
11
+ gem 'guard-yard'
12
+
13
+ Install or update your bundle:
14
+
15
+ bundle install
16
+
17
+ Add the default guard-yard definition to your Guardfile:
18
+
19
+ guard init yard
20
+
21
+ ## Guardfile
22
+
23
+ Please read the [Guardfile DSL documentation](https://github.com/guard/guard#readme) for additional information.
24
+
25
+ Guard::Yard automatically detects changes in your app, lib and ext directories, but you can have it monitor additional files using the Guardfile DSL.
26
+
27
+ Guard::Yard also provides some basic options for doc generation and running the YARD server.
28
+
29
+ guard 'yard', :port => '8808' do
30
+ ...
31
+ end
32
+
33
+ Available options:
34
+
35
+ :port => '8808' # Port on which the server shoud run.
36
+
37
+ ## Clean-Slate Documentation
38
+
39
+ To generate or re-create documentation from a clean-slate, run the following command:
40
+
41
+ rm -rf .yardoc && yard doc
42
+
43
+ When booting guard, Guard::Yard will do this for you automatically if no .yardoc directory is present. Once guard is running you can execute this command by using the `Ctrl-\` key combination as well.
44
+
45
+
46
+ ## Troubleshooting
47
+
48
+ If you are running into issues, try re-creating your documentation using `rm -rf .yardoc && yard doc`. Once this operation is complete, restart guard. If you are still having problems, open a new issue in the GitHub issue tracker for this project.
data/lib/guard/yard.rb ADDED
@@ -0,0 +1,71 @@
1
+ require 'guard'
2
+ require 'guard/guard'
3
+ require 'yard'
4
+
5
+ module Guard
6
+ class Yard < Guard
7
+ autoload :Server, 'guard/yard/server'
8
+ attr_accessor :server
9
+
10
+ def initialize(watchers=[], options={})
11
+ super
12
+ @server = Server.new(options[:port])
13
+ end
14
+
15
+ def start
16
+ UI.info "[Guard::Yard] Starting YARD Documentation Server."
17
+ boot
18
+ end
19
+
20
+ def stop
21
+ server.kill
22
+ end
23
+
24
+ def reload
25
+ UI.info "[Guard::Yard] Reloading YARD Documentation Server."
26
+ boot
27
+ end
28
+
29
+ def run_all
30
+ UI.info "[Guard::Yard] Generating all documentation."
31
+ system('rm -rf .yardoc && yard doc')
32
+ UI.info "[Guard::Yard] Documentation has been generated."
33
+ true
34
+ end
35
+
36
+ def run_on_change(paths)
37
+ UI.info "[Guard::Yard] Detected changes in #{paths.join(',')}."
38
+ paths.each{ |path| document([path]) }
39
+ UI.info "[Guard::Yard] Updated documentation for #{paths.join(',')}."
40
+ end
41
+
42
+ private
43
+
44
+ def check
45
+ return true if File.exists?('.yardoc')
46
+ UI.info "[Guard::Yard] Documentation missing."
47
+ run_all and true
48
+ end
49
+
50
+ def boot
51
+ check and server.kill and server.spawn and server.verify
52
+ end
53
+
54
+ def document files
55
+ ::YARD::Registry.load!
56
+ ::YARD::Registry.load(files, true)
57
+ ::YARD::Registry.load_all
58
+ options = ::YARD::CLI::Yardoc.new.options
59
+ objects = ::YARD::Registry.all(:root, :module, :class).reject do |object|
60
+ (!options[:serializer] || options[:serializer].exists?(object)) \
61
+ && !object.files.any?{|f,line| files.include?(f)}
62
+ end
63
+ ::YARD::Templates::Engine.generate(objects, options)
64
+ save_registry
65
+ end
66
+
67
+ def save_registry
68
+ ::YARD::Registry.save(true)
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,49 @@
1
+ require 'socket'
2
+
3
+ module Guard
4
+ class Yard
5
+ class Server
6
+ attr_accessor :pid, :port
7
+
8
+ def initialize(port)
9
+ @port = port || '8808'
10
+ end
11
+
12
+ def spawn
13
+ self.pid = fork
14
+ raise 'Fork failed' if pid == -1
15
+
16
+ unless pid
17
+ Signal.trap('QUIT', 'IGNORE')
18
+ Signal.trap('INT', 'IGNORE')
19
+ Signal.trap('TSTP', 'IGNORE')
20
+
21
+ exec("yard server -p #{port}")
22
+ end
23
+ pid
24
+ end
25
+
26
+ def kill
27
+ Process.kill('KILL', pid) unless pid.nil?
28
+ true
29
+ end
30
+
31
+ def verify
32
+ 5.times do
33
+ sleep 1
34
+ begin
35
+ TCPSocket.new('localhost', port.to_i).close
36
+ rescue Errno::ECONNREFUSED
37
+ next
38
+ end
39
+ UI.info "[Guard::Yard] Server successfully started."
40
+ return true
41
+ end
42
+ UI.error "[Guard::Yard] Error starting documentation server."
43
+ Notifier.notify "[Guard::Yard] Server NOT started.",
44
+ :title => 'yard', :image => failed
45
+ false
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,5 @@
1
+ guard 'yard' do
2
+ watch(%r{app/.+\.rb})
3
+ watch(%r{lib/.+\.rb})
4
+ watch($r{ext/.+\.c})
5
+ end
@@ -0,0 +1,5 @@
1
+ module Guard
2
+ module Yard
3
+ VERSION = "1.0.0"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,75 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: guard-yard
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Pan Thomakos
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-06-21 00:00:00.000000000 -07:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: guard
17
+ requirement: &2152555340 !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
22
+ version: 0.2.2
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: *2152555340
26
+ - !ruby/object:Gem::Dependency
27
+ name: yard
28
+ requirement: &2152517400 !ruby/object:Gem::Requirement
29
+ none: false
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: 0.7.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: *2152517400
37
+ description: Guard::Yard automatically monitors Yard Documentation.
38
+ email:
39
+ - pan.thomakos@gmail.com
40
+ executables: []
41
+ extensions: []
42
+ extra_rdoc_files: []
43
+ files:
44
+ - lib/guard/yard/server.rb
45
+ - lib/guard/yard/templates/Guardfile
46
+ - lib/guard/yard/version.rb
47
+ - lib/guard/yard.rb
48
+ - LICENSE
49
+ - README.markdown
50
+ has_rdoc: true
51
+ homepage: ''
52
+ licenses: []
53
+ post_install_message:
54
+ rdoc_options: []
55
+ require_paths:
56
+ - lib
57
+ required_ruby_version: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ! '>='
61
+ - !ruby/object:Gem::Version
62
+ version: 1.9.2
63
+ required_rubygems_version: !ruby/object:Gem::Requirement
64
+ none: false
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ requirements: []
70
+ rubyforge_project: guard-yard
71
+ rubygems_version: 1.6.2
72
+ signing_key:
73
+ specification_version: 3
74
+ summary: Guard gem for YARD
75
+ test_files: []