rubydictionary 0.1.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown CHANGED
@@ -2,7 +2,13 @@ This gem adds `rubydictionary` formatter to RDoc.
2
2
 
3
3
  ## Prerequisites
4
4
 
5
- You will need latest [*Xcode* developer tools](http://developer.apple.com/).
5
+ You will need latest [Command Line Tools for Xcode](https://developer.apple.com/downloads/index.action).
6
+
7
+ ### Dictionary Development Kit
8
+
9
+ Since OS X Mountain Lion, Dictionary Development Kit required to build dictionaries is not included by default with developer tools.
10
+
11
+ Dictionary Development Kit can be downloaded from [Downloads for Apple Developers](https://developer.apple.com/downloads/index.action) page and it is inside **Auxiliary Tools for Xcode** package. You must copy `Dictionary Development Kit` manually to `/Developer/Extras` folder.
6
12
 
7
13
  ## Install
8
14
 
@@ -12,9 +18,18 @@ You will need latest [*Xcode* developer tools](http://developer.apple.com/).
12
18
 
13
19
  Run `rubydictionary` in your source code directory. For example for source of Sinatra:
14
20
 
15
- rubydictionary --dict-name=Sinatra --dict-id=com.sinatrarb.Dictionary
21
+ rubydictionary \
22
+ --dict-name=Sinatra \
23
+ --dict-id=com.sinatrarb.Dictionary
24
+
25
+ If everything goes well, you should now have `Sinatra.dictionary` file under `./doc/objects` directory. Drop it into `~/Library/Dictionaries/` folder.
26
+
27
+ If Dictionary Development Kit is located somewhere else than in `/Developer/Extras` (which is recommended in 10.9+), you can specify the path for it with `--kit-path` option:
16
28
 
17
- If all goes well, you should now have `Sinatra.dictionary` file under `./doc/objects` directory. Drop it into `~/Library/Dictionaries/` folder.
29
+ rubydictionary \
30
+ --dict-name=Sinatra \
31
+ --dict-id=com.sinatrarb.Dictionary \
32
+ --kit-path=~/Source/DictionaryDevKit
18
33
 
19
34
  ## Authors
20
35
 
@@ -23,4 +38,4 @@ See the [Github contributors page](https://github.com/priithaamer/rubydictionary
23
38
  ## Links
24
39
 
25
40
  * [Dictionary Services programming guide at Apple Developer site](http://developer.apple.com/library/mac/documentation/UserExperience/Conceptual/DictionaryServicesProgGuide/index.html)
26
- * [https://github.com/breakpointer/ajax-rdoc](https://github.com/breakpointer/ajax-rdoc)
41
+ * [https://github.com/breakpointer/ajax-rdoc](https://github.com/breakpointer/ajax-rdoc)
@@ -9,6 +9,8 @@ class RDoc::Options
9
9
  attr_accessor :dictionary_name
10
10
 
11
11
  attr_accessor :dictionary_identifier
12
+
13
+ attr_accessor :kit_path
12
14
  end
13
15
 
14
16
  class RDoc::Generator::Dictionary
@@ -21,20 +23,18 @@ class RDoc::Generator::Dictionary
21
23
 
22
24
  # TODO: Raise an error when dictionary name is missing
23
25
  def self.setup_options(options)
24
- options.dictionary_identifier = 'com.priithaamer.Dictionary'
25
-
26
26
  opt = options.option_parser
27
27
  opt.separator "Dictionary generator options:"
28
28
  opt.separator nil
29
29
  opt.on('--dict-name=NAME', 'Title that appears in Dictionary.app') do |value|
30
30
  options.dictionary_name = value
31
31
  end
32
- opt.on('--dict-id=IDENTIFIER',
33
- 'Dictionary bundle identifier, such as',
34
- 'org.rubyonrails.Rails'
35
- ) do |value|
32
+ opt.on('--dict-id=IDENTIFIER', 'Dictionary bundle identifier, such as', 'org.rubyonrails.Rails') do |value|
36
33
  options.dictionary_identifier = value
37
34
  end
35
+ opt.on('--kit-path=DICTIONARY_KIT_PATH', 'Full path to Dictionary Development Kit') do |value|
36
+ options.kit_path = value
37
+ end
38
38
  opt.separator nil
39
39
  end
40
40
 
@@ -50,7 +50,7 @@ class RDoc::Generator::Dictionary
50
50
  def generate(top_levels)
51
51
  builder = Nokogiri::XML::Builder.new(:encoding => 'utf-8') do |xml|
52
52
  xml.send('dictionary', 'xmlns' => XMLNS, 'xmlns:d' => XMLNS_D) do
53
- xml.parent.namespace = xml.parent.namespace_definitions.first
53
+ xml.parent.namespace = xml.parent.add_namespace_definition('d', XMLNS_D)
54
54
 
55
55
  RDoc::TopLevel.all_classes_and_modules.each do |clazz|
56
56
  unless @class_ids.include?(class_id(clazz))
@@ -79,11 +79,15 @@ class RDoc::Generator::Dictionary
79
79
 
80
80
  plist_path = File.join(Pathname.pwd, 'Dictionary.plist')
81
81
 
82
- dict_build_tool = "/Developer/Extras/Dictionary Development Kit/bin/build_dict.sh"
82
+ dict_build_tool = File.join((@options.kit_path || '/Developer/Extras/Dictionary Development Kit'), 'bin', 'build_dict.sh')
83
83
 
84
84
  %x{"#{dict_build_tool}" "#{@options.dictionary_name}" #{dict_src_path} #{css_path} #{plist_path}}
85
85
  end
86
86
 
87
+ def file_dir
88
+ ''
89
+ end
90
+
87
91
  def class_dir
88
92
  'classes'
89
93
  end
@@ -92,14 +96,15 @@ class RDoc::Generator::Dictionary
92
96
 
93
97
  def append_class_entry(cls, xml)
94
98
  xml.entry('id' => class_id(cls), 'd:title' => class_title(cls)) do
95
- xml.index('d:value' => cls.full_name)
99
+ xml.parent.namespace = xml.parent.add_namespace_definition('d', XMLNS_D)
100
+ xml.index('d:value' => cls.full_name) { xml.parent.namespace = xml.parent.add_namespace_definition('d', XMLNS_D) }
96
101
 
97
102
  xml.h1(cls.full_name, :xmlns => XMLNS)
98
103
 
99
104
  xml.div(:xmlns => XMLNS) do
100
- xml << cls.description
105
+ xml << strip_pre_markup(cls.description)
101
106
  end
102
-
107
+
103
108
  # Link to class methods
104
109
  unless cls.class_method_list.empty?
105
110
  xml.h3('Class methods', :xmlns => XMLNS)
@@ -128,15 +133,17 @@ class RDoc::Generator::Dictionary
128
133
 
129
134
  def append_method_entry(mthd, xml)
130
135
  xml.entry('id' => method_id(mthd), 'd:title' => method_title(mthd)) do
131
- xml.index('d:value' => mthd.full_name)
132
- xml.index('d:value' => mthd.name)
136
+ xml.parent.namespace = xml.parent.add_namespace_definition('d', XMLNS_D)
137
+
138
+ xml.index('d:value' => mthd.full_name) { xml.parent.namespace = xml.parent.add_namespace_definition('d', XMLNS_D) }
139
+ xml.index('d:value' => mthd.name) { xml.parent.namespace = xml.parent.add_namespace_definition('d', XMLNS_D) }
133
140
 
134
141
  xml.h1(mthd.arglists, :xmlns => XMLNS)
135
142
 
136
143
  xml.p(mthd.full_name, :class => 'method_name', :xmlns => XMLNS)
137
144
 
138
145
  xml.div(:xmlns => XMLNS) do
139
- xml << mthd.description
146
+ xml << strip_pre_markup(mthd.description)
140
147
  end
141
148
  end
142
149
  end
@@ -161,6 +168,13 @@ class RDoc::Generator::Dictionary
161
168
  'method_' << mthd.object_id.to_s(36)
162
169
  end
163
170
 
171
+ # Strips ruby markup span elements generated by RDoc
172
+ def strip_pre_markup(content)
173
+ content.gsub!(/<pre class="ruby">.*?<\/pre>/m) do |m|
174
+ '<pre>' + m.gsub(/<\/?[^>]*>/, '') + '</pre>'
175
+ end
176
+ end
177
+
164
178
  def bundle_identifier
165
179
  @options.dictionary_identifier
166
180
  end
@@ -1,3 +1,3 @@
1
1
  module Rubydictionary
2
- VERSION = "0.1.0"
2
+ VERSION = '1.0.1'
3
3
  end
@@ -17,4 +17,8 @@ Gem::Specification.new do |s|
17
17
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
18
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
19
  s.require_paths = ['lib']
20
+
21
+ %w(rake).each do |gem|
22
+ s.add_development_dependency *gem.split(' ')
23
+ end
20
24
  end
metadata CHANGED
@@ -1,34 +1,41 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: rubydictionary
3
- version: !ruby/object:Gem::Version
4
- hash: 27
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.1
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 1
9
- - 0
10
- version: 0.1.0
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Priit Haamer
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2011-10-07 00:00:00 +03:00
19
- default_executable:
20
- dependencies: []
21
-
22
- description: Builds dictionary files for Mac OS Dictionary.app of Ruby documentation using RDoc
23
- email:
12
+ date: 2013-06-13 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rake
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ description: Builds dictionary files for Mac OS Dictionary.app of Ruby documentation
31
+ using RDoc
32
+ email:
24
33
  - priit@fraktal.ee
25
- executables:
34
+ executables:
26
35
  - rubydictionary
27
36
  extensions: []
28
-
29
37
  extra_rdoc_files: []
30
-
31
- files:
38
+ files:
32
39
  - .gitignore
33
40
  - Gemfile
34
41
  - README.markdown
@@ -40,39 +47,34 @@ files:
40
47
  - lib/rubydictionary/generator.rb
41
48
  - lib/rubydictionary/version.rb
42
49
  - rubydictionary.gemspec
43
- has_rdoc: true
44
50
  homepage: https://github.com/priithaamer/rubydictionary
45
51
  licenses: []
46
-
47
52
  post_install_message:
48
53
  rdoc_options: []
49
-
50
- require_paths:
54
+ require_paths:
51
55
  - lib
52
- required_ruby_version: !ruby/object:Gem::Requirement
56
+ required_ruby_version: !ruby/object:Gem::Requirement
53
57
  none: false
54
- requirements:
55
- - - ">="
56
- - !ruby/object:Gem::Version
57
- hash: 3
58
- segments:
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ segments:
59
63
  - 0
60
- version: "0"
61
- required_rubygems_version: !ruby/object:Gem::Requirement
64
+ hash: 1703439815085221063
65
+ required_rubygems_version: !ruby/object:Gem::Requirement
62
66
  none: false
63
- requirements:
64
- - - ">="
65
- - !ruby/object:Gem::Version
66
- hash: 3
67
- segments:
67
+ requirements:
68
+ - - ! '>='
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ segments:
68
72
  - 0
69
- version: "0"
73
+ hash: 1703439815085221063
70
74
  requirements: []
71
-
72
75
  rubyforge_project: rubydictionary
73
- rubygems_version: 1.4.2
76
+ rubygems_version: 1.8.23
74
77
  signing_key:
75
78
  specification_version: 3
76
79
  summary: Adds "rubydictionary" formatter to RDoc
77
80
  test_files: []
78
-