motion-docs 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b46bb74fc9981344cf8dc7b9c6e15284f5b61125
4
+ data.tar.gz: 843a9ac3b1c059ff9111c750e341adb069d31bf4
5
+ SHA512:
6
+ metadata.gz: 07dd18c96977c365d00727bda49e5cb2d1942f63a2f0e7f1f1d84d3038ff2eead97683eb3b98be1bd8fe892e360a51c7aa1069ab3ef20f3c5fe7a232a1f64e82
7
+ data.tar.gz: 0fc804ab1ad878c0ded3951a85d75f4ca9209a587adba7f51643235711ace75aa157366d025cae6565548ef0b8935e53208611b730795e0f25a994923cd24908
@@ -0,0 +1,93 @@
1
+ # MotionDocs
2
+
3
+ Provides class and method documentation right in your RubyMotion REPL.
4
+
5
+ ## Installation
6
+
7
+ MotionDocs will only activate if running in simulator.
8
+
9
+ ```ruby
10
+ gem 'motion-docs'
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ Within your RubyMotion REPL, type in `docs` and a string representing what you'd like
16
+ to look up in the documentation.
17
+
18
+ ```sh-session
19
+ (main)> docs "UINavigationController"
20
+ ```
21
+
22
+ You'll get something like this:
23
+
24
+ ![UINavigationController documentation](http://clrsight.co/jh/2015-02-19-o8uh6.png?+)
25
+
26
+ To look up a method, just use the familiar notation for class and instance methods:
27
+
28
+ ```sh-session
29
+ (main)> docs "UIColor.blueColor"
30
+ ...
31
+ (main)> docs "UIColor#colorWithAlphaComponent:"
32
+ ...
33
+ ```
34
+
35
+ As an alternative, you can use `.docs` on a string:
36
+
37
+ ```sh-session
38
+ (main)> "UIColor.redColor".docs
39
+ ...
40
+ ```
41
+
42
+ Or, for classes, even just on the class itself:
43
+
44
+ ```sh-session
45
+ (main)> UIColor.docs
46
+ ...
47
+ ```
48
+
49
+ If you give it a class or instance method name, it'll give you documentation for that.
50
+
51
+ ```sh-session
52
+ (main)> UIView.docs("#frame")
53
+ ...
54
+ (main)> NSObject.docs(".alloc")
55
+ ...
56
+ ```
57
+
58
+ ## Support
59
+
60
+ File an issue here at Github. Better yet, submit a pull request with a fix. :-)
61
+ But an issue is just fine as well.
62
+
63
+ ## Author
64
+
65
+ [Jamon Holmgren](https://twitter.com/jamonholmgren)
66
+
67
+ ## License
68
+
69
+ Copyright (c) 2015 Jamon Holmgren
70
+
71
+ MIT License
72
+
73
+ Permission is hereby granted, free of charge, to any person obtaining
74
+ a copy of this software and associated documentation files (the
75
+ "Software"), to deal in the Software without restriction, including
76
+ without limitation the rights to use, copy, modify, merge, publish,
77
+ distribute, sublicense, and/or sell copies of the Software, and to
78
+ permit persons to whom the Software is furnished to do so, subject to
79
+ the following conditions:
80
+
81
+ The above copyright notice and this permission notice shall be
82
+ included in all copies or substantial portions of the Software.
83
+
84
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
85
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
86
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
87
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
88
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
89
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
90
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
91
+
92
+
93
+
@@ -0,0 +1,12 @@
1
+ # encoding: utf-8
2
+
3
+ unless defined?(Motion::Project::Config)
4
+ raise "This file must be required within a RubyMotion project Rakefile."
5
+ end
6
+
7
+ lib_dir_path = File.dirname(File.expand_path(__FILE__))
8
+ Motion::Project::App.setup do |app|
9
+ app.files << "#{lib_dir_path}/motion-docs/version.rb"
10
+ app.files << "#{lib_dir_path}/motion-docs/motion-docs.rb"
11
+ app.files << "#{lib_dir_path}/motion-docs/monkeypatching.rb"
12
+ end
@@ -0,0 +1,28 @@
1
+ if !(UIDevice.currentDevice.model =~ /simulator/i).nil?
2
+ class Object
3
+ def self.docs(method_name=nil)
4
+ subject = self.to_s
5
+ if method_name
6
+ subject << "." unless method_name.start_with?("#") || method_name.start_with?(".")
7
+ subject << method_name.to_s
8
+ end
9
+ puts MotionDocs.new(subject).help
10
+ end
11
+ def self.ri(m=nil); docs(m); end
12
+ end
13
+
14
+ class String
15
+ def docs
16
+ puts MotionDocs.new(self).help
17
+ end
18
+ alias ri docs
19
+ end
20
+
21
+ module Kernel
22
+ def docs(subject)
23
+ puts MotionDocs.new(subject.to_s).help
24
+ nil
25
+ end
26
+ alias ri docs
27
+ end
28
+ end
@@ -0,0 +1,74 @@
1
+ if !(UIDevice.currentDevice.model =~ /simulator/i).nil?
2
+ class MotionDocs
3
+ attr_reader :subject
4
+
5
+ COLORS = {
6
+ gray: "\e[1;30m",
7
+ red: "\e[0;31m",
8
+ light_red: "\e[1;31m",
9
+ green: "\e[0;32m",
10
+ light_green: "\e[1;32m",
11
+ yellow: "\e[0;33m",
12
+ light_yellow: "\e[1;33m",
13
+ blue: "\e[0;34m",
14
+ light_blue: "\e[1;34m",
15
+ purple: "\e[0;35m",
16
+ light_purple: "\e[1;35m",
17
+ cyan: "\e[0;36m",
18
+ light_cyan: "\e[1;36m",
19
+ white: "\e[0m",
20
+ off: "\e[0m",
21
+ }
22
+
23
+ def initialize(subject)
24
+ @subject = subject
25
+ end
26
+
27
+ def help
28
+ ri_docs = `HOME=/tmp /Library/RubyMotion/lib/yard/bin/yri --db /Library/RubyMotion/doc/yardoc #{subject}`
29
+ colorized(ri_docs)
30
+ end
31
+
32
+ private
33
+
34
+ def colorized(ri_docs)
35
+ color = :blue
36
+ ri_docs.split("\n").map do |ri_line|
37
+ if ri_line == ""
38
+ nil
39
+ elsif ri_line.include?("Class:") || ri_line.include?("Method:")
40
+ color = :blue
41
+ colored_text ri_line.split(":", 2).last.strip, :light_blue
42
+ elsif ri_line.start_with? "--------------"
43
+ nil
44
+ elsif ri_line == ""
45
+ nil
46
+ elsif ri_line == "Includes:"
47
+ color = :purple
48
+ colored_text ri_line, :light_purple
49
+ elsif ri_line == "Class methods:"
50
+ color = :yellow
51
+ colored_text ri_line, :light_yellow
52
+ elsif ri_line == "Instance methods:"
53
+ color = :green
54
+ colored_text ri_line, :light_green
55
+ elsif ri_line == "Direct Known Subclasses:" || ri_line == "Overloads:"
56
+ color = :cyan
57
+ colored_text ri_line, :light_cyan
58
+ elsif ri_line == "Parameters:"
59
+ color = :gray
60
+ colored_text ri_line, :white
61
+ elsif ri_line == "Returns:"
62
+ color = :red
63
+ colored_text ri_line, :light_red
64
+ else
65
+ colored_text ri_line, color
66
+ end
67
+ end.compact.join("\n")
68
+ end
69
+
70
+ def colored_text(ri_line, color=:blue)
71
+ "#{COLORS[color]}#{ri_line}#{COLORS[:off]}"
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,5 @@
1
+ if !defined?(UIDevice) || !(UIDevice.currentDevice.model =~ /simulator/i).nil?
2
+ class MotionDocs
3
+ VERSION = "0.1.0" unless defined?(MotionDocs::VERSION)
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,64 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: motion-docs
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Jamon Holmgren
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-02-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description: Provides class and method documentation right in your RubyMotion REPL.
28
+ Only activates when running on simulator.
29
+ email:
30
+ - jamon@clearsightstudio.com
31
+ executables: []
32
+ extensions: []
33
+ extra_rdoc_files: []
34
+ files:
35
+ - README.md
36
+ - lib/motion-docs.rb
37
+ - lib/motion-docs/monkeypatching.rb
38
+ - lib/motion-docs/motion-docs.rb
39
+ - lib/motion-docs/version.rb
40
+ homepage: http://github.com/jamonholmgren/motion-docs
41
+ licenses:
42
+ - MIT
43
+ metadata: {}
44
+ post_install_message:
45
+ rdoc_options: []
46
+ require_paths:
47
+ - lib
48
+ required_ruby_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ required_rubygems_version: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: '0'
58
+ requirements: []
59
+ rubyforge_project:
60
+ rubygems_version: 2.4.5
61
+ signing_key:
62
+ specification_version: 4
63
+ summary: Provides class and method documentation right in your RubyMotion REPL.
64
+ test_files: []