voloko-sdoc 0.1.9 → 0.1.10

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :minor: 1
3
- :patch: 9
3
+ :patch: 10
4
4
  :major: 0
@@ -0,0 +1,31 @@
1
+ require "rdoc/parser/c"
2
+
3
+ # New RDoc somehow misses class comemnts.
4
+ # copyied this function from "2.2.2"
5
+ if ['2.4.2', '2.4.3'].include? RDoc::VERSION
6
+
7
+ class RDoc::Parser::C
8
+ def find_class_comment(class_name, class_meth)
9
+ comment = nil
10
+ if @content =~ %r{((?>/\*.*?\*/\s+))
11
+ (static\s+)?void\s+Init_#{class_name}\s*(?:_\(\s*)?\(\s*(?:void\s*)\)}xmi then
12
+ comment = $1
13
+ elsif @content =~ %r{Document-(?:class|module):\s#{class_name}\s*?(?:<\s+[:,\w]+)?\n((?>.*?\*/))}m
14
+ comment = $1
15
+ else
16
+ if @content =~ /rb_define_(class|module)/m then
17
+ class_name = class_name.split("::").last
18
+ comments = []
19
+ @content.split(/(\/\*.*?\*\/)\s*?\n/m).each_with_index do |chunk, index|
20
+ comments[index] = chunk
21
+ if chunk =~ /rb_define_(class|module).*?"(#{class_name})"/m then
22
+ comment = comments[index-1]
23
+ break
24
+ end
25
+ end
26
+ end
27
+ end
28
+ class_meth.comment = mangle_comment(comment) if comment
29
+ end
30
+ end
31
+ end
@@ -1,4 +1,12 @@
1
1
  require 'rubygems'
2
+ gem "rdoc", ">= 2.4.2"
3
+ if Gem.available? "json"
4
+ gem "json", ">= 1.1.3"
5
+ else
6
+ gem "json_pure", ">= 1.1.3"
7
+ end
8
+
9
+ require 'iconv'
2
10
  require 'json'
3
11
  require 'pathname'
4
12
  require 'fileutils'
@@ -259,7 +267,20 @@ class RDoc::Generator::SHtml
259
267
  else
260
268
  content = str.gsub(/^\s*(#+)\s*/, '')
261
269
  end
270
+
262
271
  content.sub(/^(.{100,}?)\s.*/m, "\\1").gsub(/\r?\n/m, ' ')
272
+
273
+ begin
274
+ content.to_json
275
+ rescue # might fail on non-unicode string
276
+ begin
277
+ content = Iconv.conv('latin1//ignore', "UTF8", content) # remove all non-unicode chars
278
+ content.to_json
279
+ rescue
280
+ content = '' # something hugely wrong happend
281
+ end
282
+ end
283
+ content
263
284
  end
264
285
 
265
286
  ### Build search index key
data/lib/sdoc.rb CHANGED
@@ -1,10 +1,14 @@
1
1
  $:.unshift File.dirname(__FILE__)
2
+ require "rubygems"
3
+ gem "rdoc", ">= 2.4.2"
4
+
2
5
  require "rdoc/rdoc"
3
6
 
4
7
  module SDoc
5
8
  end
6
9
 
7
10
  require "sdoc/generator/shtml"
11
+ require "sdoc/c_parser_fix"
8
12
 
9
13
  class RDoc::Options
10
14
  alias_method :rdoc_initialize, :initialize
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: voloko-sdoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.1.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Volodya Kolesnikov
@@ -47,6 +47,7 @@ files:
47
47
  - bin/sdoc
48
48
  - bin/sdoc-merge
49
49
  - lib/sdoc
50
+ - lib/sdoc/c_parser_fix.rb
50
51
  - lib/sdoc/generator
51
52
  - lib/sdoc/generator/shtml.rb
52
53
  - lib/sdoc/generator/template