From 1457e6e962408172748083d8b6d39ffa66c19276 Mon Sep 17 00:00:00 2001 From: Valentin Niess Date: Fri, 18 Mar 2016 22:41:50 +0100 Subject: [PATCH 1/6] Force string encoding to UTF-8. This prevents a crash when symbols, e.g. α are encoded using .to_json. --- lib/docurium.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/docurium.rb b/lib/docurium.rb index c2c5bbb8d..15c14741a 100644 --- a/lib/docurium.rb +++ b/lib/docurium.rb @@ -167,6 +167,7 @@ def generate_docs # There's still some work we need to do serially tally_sigs!(version, data) + force_utf8(data) sha = @repo.write(data.to_json, :blob) print "Generating documentation [#{i}/#{nversions}]\r" @@ -225,6 +226,21 @@ def generate_docs puts "\tupdated #{br}" end + def force_utf8(data) + # Walk the data to force strings encoding to UTF-8. + if data.instance_of? Hash + data.each do |key, value| + if [:comment, :comments, :description].include?(key) + data[key] = value.force_encoding('UTF-8') unless value.nil? + else + force_utf8(value) + end + end + elsif data.respond_to?(:each) + data.each { |x| force_utf8(x) } + end + end + def show_warnings(data) out '* checking your api' From 773fdd377dc0aea5e1168b1d25faadbd2c0ee274 Mon Sep 17 00:00:00 2001 From: Valentin Niess Date: Sat, 19 Mar 2016 00:10:05 +0100 Subject: [PATCH 2/6] Added callbacks to the struct usage info. Callbacks as well as functions are now shown in the stats of a structure usage. --- lib/docurium.rb | 7 +++++-- site/index.html | 4 ++-- site/js/docurium.js | 5 ++++- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/docurium.rb b/lib/docurium.rb index 15c14741a..4992c5566 100644 --- a/lib/docurium.rb +++ b/lib/docurium.rb @@ -378,9 +378,12 @@ def group_functions!(data) end def find_type_usage!(data) - # go through all the functions and see where types are used and returned + # go through all the functions and callbacks and see where other types are used and returned # store them in the types data - data[:functions].each do |func, fdata| + h = {} + h.merge!(data[:functions]) + h.merge!(data[:callbacks]) + h.each do |func, fdata| data[:types].each_with_index do |tdata, i| type, typeData = tdata data[:types][i][1][:used] ||= {:returns => [], :needs => []} diff --git a/site/index.html b/site/index.html index 49a5b093a..2bc455afa 100644 --- a/site/index.html +++ b/site/index.html @@ -191,7 +191,7 @@

<%= group.name %>

@@ -162,14 +164,14 @@

versions

<% } %> - <% if (alsoLinks) { %> + <% if (alsoLinks && (alsoLinks.length > 0)) { %>
Also in <%= groupName %> group:
<% _.each(_.initial(alsoLinks), function(link) { %> <%= link.name %>, <% }) %> <% var link = _.last(alsoLinks) %> - <%= link.name %> + <%= link.name %>.
<% } %> @@ -193,19 +195,19 @@

<%= group.name %>

<% if (returns.length > 0) { %>

Returned by

<% _.each(_.initial(returns), function(fun) { %> - <%= fun.name %> + <%= fun.name %>, <% }) %> <% var fun = _.last(returns) %> - <%= fun.name %> + <%= fun.name %>. <% } %> <% if (needs.length > 0) { %>

Argument in

<% _.each(_.initial(needs), function(fun) { %> - <%= fun.name %> + <%= fun.name %>, <% }) %> <% var fun = _.last(needs) %> - <%= fun.name %> + <%= fun.name %>. <% } %>