open_gemdocs 0.1.0 → 0.2.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
- checksums.yaml.gz.sig +0 -0
- data/README.md +36 -5
- data/checksums/open_gemdocs-0.2.0.gem.sha512 +1 -0
- data/exe/open-gem-docs +29 -2
- data/lib/open_gemdocs/version.rb +1 -1
- data/lib/open_gemdocs/yard.rb +45 -0
- data/lib/open_gemdocs.rb +1 -0
- data.tar.gz.sig +0 -0
- metadata +3 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 163ed0b411faca022538670ef2cf3d1eb32bdd14ab18da40ec40ebd0cacf614d
|
4
|
+
data.tar.gz: 49da57a40d0e42119d72b22307c4ab65e8220a8dbaff4fdf40ede8614b176381
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 808f9bdd8aedd3c9207be40d17c1e8c8b8d51e96beda2337f57eb57b3d12eeae505bfd46b60cbee3ca87406dcd511e77f36ca352bbd22a47a68935888b815fed
|
7
|
+
data.tar.gz: 727d07b3051bdf906d8e5f272ee5f3d3005f5069e0313c141e0298ac17960cb191ad258868df2819e84e11f611fef598dba8d5763e14c1b30305d161b6ec52b1
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/README.md
CHANGED
@@ -1,6 +1,13 @@
|
|
1
1
|
# OpenGemdocs
|
2
2
|
|
3
|
-
This is a simple command line tool that helps open gem documentation
|
3
|
+
This is a simple command line tool that helps open gem documentation. There are two documentation sources you can use.
|
4
|
+
|
5
|
+
1. local gems served with the yarn gem
|
6
|
+
2. [https://gemdocs.org](https://gemdocs.org) - a good ruby gem documentation host
|
7
|
+
|
8
|
+
* If ran from a directory with a Gemfile.lock, it will open the documentation for the version of the gem you are using unles you specify `--latest` or `--version` options
|
9
|
+
* Defaults to open the latest version of the documentation
|
10
|
+
* Can specify a version of the docs to view
|
4
11
|
|
5
12
|
## Installation
|
6
13
|
|
@@ -20,15 +27,39 @@ gem install open_gemdocs
|
|
20
27
|
|
21
28
|
Currently, this only works on Macs because of the `open` command. It opens the documentation for a gem in your default web browser.
|
22
29
|
|
23
|
-
|
30
|
+
To see the available options.
|
31
|
+
```bash
|
32
|
+
open-gem-docs --help
|
33
|
+
```
|
24
34
|
|
35
|
+
### Example usage
|
36
|
+
If you are in a directory with a Gemfile.lock, it will open the documentation for the version of the gem you are using unless you specify `--latest` or `--version` options.
|
37
|
+
|
38
|
+
If you are not in a directory with a Gemfile.lock, it will open the latest version of the documentation.
|
25
39
|
```bash
|
26
|
-
|
40
|
+
open-gem-docs rspec
|
27
41
|
```
|
42
|
+
(Assuming you are in a directory with a Gemfile.lock, it will open the rspec docs for the version you are using.)
|
28
43
|
|
29
|
-
|
44
|
+
Open a specific version (regardless of what is in your Gemfile.lock)
|
45
|
+
```bash
|
46
|
+
open-gem-docs -v 3.12.0 rspec
|
47
|
+
```
|
30
48
|
|
31
|
-
|
49
|
+
Open the latest version of the documentation
|
50
|
+
```bash
|
51
|
+
open-gem-docs --latest rspec
|
52
|
+
```
|
53
|
+
|
54
|
+
To use a local documentation server. Run the following command from a directory where Gemfile.lock exists. This will serves the documentation for your currently installed gems.
|
55
|
+
```bash
|
56
|
+
open-gem-docs --local
|
57
|
+
```
|
58
|
+
|
59
|
+
You can also jump directly to a local doc gem page:
|
60
|
+
```bash
|
61
|
+
open-gem-docs --local rspec
|
62
|
+
```
|
32
63
|
|
33
64
|
## Development
|
34
65
|
|
@@ -0,0 +1 @@
|
|
1
|
+
d38b05b2644370819c8ace560260816630b1c77dba752edeab3f4a8fc7d32dcf914582ff054a48ff61d6f904a513f46279273eaf3e686611df51724dc94ad1ed
|
data/exe/open-gem-docs
CHANGED
@@ -12,11 +12,14 @@ options = {}
|
|
12
12
|
OptionParser.new do |opts|
|
13
13
|
opts.banner = 'Usage: open-gem-docs [options] <gem_name>'
|
14
14
|
|
15
|
+
opts.on('--local', 'Use local documentation') do
|
16
|
+
options[:local] = true
|
17
|
+
end
|
15
18
|
opts.on('-v', '--version VERSION', 'Specify the version') do |version|
|
16
19
|
options[:version] = version
|
17
20
|
end
|
18
21
|
|
19
|
-
opts.on('
|
22
|
+
opts.on('--latest', 'Use the latest version') do
|
20
23
|
options[:latest] = true
|
21
24
|
end
|
22
25
|
|
@@ -24,10 +27,34 @@ OptionParser.new do |opts|
|
|
24
27
|
puts opts
|
25
28
|
exit
|
26
29
|
end
|
30
|
+
|
31
|
+
opts.on('-s', '--stop', 'stops the yarn server') do
|
32
|
+
OpenGemdocs::Yard.stop_server
|
33
|
+
exit
|
34
|
+
end
|
27
35
|
end.parse!
|
28
36
|
|
29
37
|
begin
|
30
|
-
|
38
|
+
if options[:local]
|
39
|
+
unless OpenGemdocs::Yard.yard_installed?
|
40
|
+
puts 'To use the local documentation, you need to install Yard.'
|
41
|
+
puts 'Please install yard with `gem install yard`.'
|
42
|
+
puts 'Would you like to install it now? (y/n)'
|
43
|
+
case gets.chomp.downcase
|
44
|
+
when 'y'
|
45
|
+
system('gem install yard')
|
46
|
+
puts 'Yard installed successfully.'
|
47
|
+
puts 'Now you can use the local documentation with `open-gem-docs --local <gem_name>`'
|
48
|
+
else
|
49
|
+
puts 'Yard is required to use the local documentation.'
|
50
|
+
puts 'Please install it and try again.'
|
51
|
+
end
|
52
|
+
exit 0
|
53
|
+
end
|
54
|
+
OpenGemdocs::Yard.browse_gem(ARGV[0])
|
55
|
+
else
|
56
|
+
OpenGemdocs::Browser.new(gem_name: ARGV[0], version: options[:version], use_latest: options[:latest]).open_browser
|
57
|
+
end
|
31
58
|
rescue OpenGemdocs::Error, ArgumentError => e
|
32
59
|
puts e.message
|
33
60
|
exit 1
|
data/lib/open_gemdocs/version.rb
CHANGED
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module OpenGemdocs
|
4
|
+
module Yard
|
5
|
+
extend self
|
6
|
+
SERVER_COMMAND = 'yard server --gems --daemon ./'
|
7
|
+
|
8
|
+
def browse_gem(gem_name)
|
9
|
+
if server_running?
|
10
|
+
puts "Yard server is already running. Opening browser..."
|
11
|
+
system("open http://localhost:8808/docs/#{gem_name}")
|
12
|
+
else
|
13
|
+
puts "Starting Yard server in the background..."
|
14
|
+
start_yard_server
|
15
|
+
sleep 2 # Give the server some time to start
|
16
|
+
system("open http://localhost:8808/docs/#{gem_name}")
|
17
|
+
end
|
18
|
+
puts " When you're done, remember to stop the server with `open-gem-docs --stop`"
|
19
|
+
end
|
20
|
+
|
21
|
+
def yard_installed?
|
22
|
+
`gem list yard -i`.strip == 'true'
|
23
|
+
end
|
24
|
+
|
25
|
+
def start_yard_server = `#{SERVER_COMMAND}`
|
26
|
+
|
27
|
+
def server_running? = find_yard_pids.any?
|
28
|
+
|
29
|
+
def find_yard_pids
|
30
|
+
# Find pids bound to port 8808
|
31
|
+
`lsof -i TCP:8808 | grep -E "^ruby.*:8808"`.strip.split("\n").map { |line| line.split(/\s+/)[1] }
|
32
|
+
end
|
33
|
+
|
34
|
+
def stop_server
|
35
|
+
yard_pids = find_yard_pids
|
36
|
+
if yard_pids.any?
|
37
|
+
puts "Stopping Yard server processes: #{yard_pids.join(', ')}"
|
38
|
+
`kill #{yard_pids.join(' ')}`
|
39
|
+
puts "Yard server processes stopped."
|
40
|
+
else
|
41
|
+
puts "No Yard server processes found to stop"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
data/lib/open_gemdocs.rb
CHANGED
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: open_gemdocs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean McCleary
|
@@ -52,10 +52,12 @@ files:
|
|
52
52
|
- Rakefile
|
53
53
|
- certs/mrinterweb.pem
|
54
54
|
- checksums/open_gemdocs-0.1.0.gem.sha512
|
55
|
+
- checksums/open_gemdocs-0.2.0.gem.sha512
|
55
56
|
- exe/open-gem-docs
|
56
57
|
- lib/open_gemdocs.rb
|
57
58
|
- lib/open_gemdocs/browser.rb
|
58
59
|
- lib/open_gemdocs/version.rb
|
60
|
+
- lib/open_gemdocs/yard.rb
|
59
61
|
- sig/open_gemdocs.rbs
|
60
62
|
homepage: https://github.com/mrinterweb/open_gemdocs
|
61
63
|
licenses:
|
metadata.gz.sig
CHANGED
Binary file
|