Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

link example use

  • Loading branch information...
commit d127721bcbdcaaf9e88781f7bd824f172ec4383a 1 parent 5a2b8ba
@schacon schacon authored
Showing with 35 additions and 18 deletions.
  1. +13 −5 lib/docurium.rb
  2. +4 −0 site/css/style.css
  3. +18 −13 site/js/docurium.js
View
18 lib/docurium.rb
@@ -76,18 +76,26 @@ def generate_docs
rocco_layout.version = version
rf = rocco_layout.render
+ rf_path = File.basename(file).split('.')[0..-2].join('.') + '.html'
+ rel_path = "ex/#{version}/#{rf_path}"
+ rf_path = File.join(outdir, rel_path)
+
# look for function names in the examples and link
+ id_num = 0
@data[:functions].each do |f, fdata|
- rf.gsub!(f) do |f|
+ rf.gsub!(/#{f}([^\w])/) do |fmatch|
+ extra = $1
+ id_num += 1
+ name = f + '-' + id_num.to_s
# save data for cross-link
- "<a href=\"../../##{version}/group/#{fdata[:group]}/#{f}\">#{f}</a>"
+ @data[:functions][f][:examples] ||= {}
+ @data[:functions][f][:examples][file] ||= []
+ @data[:functions][f][:examples][file] << rel_path + '#' + name
+ "<a name=\"#{name}\" href=\"../../##{version}/group/#{fdata[:group]}/#{f}\">#{f}</a>#{extra}"
end
end
# write example to docs directory
- rf_path = File.basename(file).split('.')[0..-2].join('.') + '.html'
- rel_path = "ex/#{version}/#{rf_path}"
- rf_path = File.join(outdir, rel_path)
FileUtils.mkdir_p(File.dirname(rf_path))
File.open(rf_path, 'w+') do |f|
@data[:examples] ||= []
View
4 site/css/style.css
@@ -184,6 +184,10 @@ h1.funcTitle small {
padding: 10px;
}
+.funcEx {
+ padding: 10px;
+}
+
.signatures a {
background: #ddd;
padding: 4px;
View
31 site/js/docurium.js
@@ -181,6 +181,23 @@ $(function() {
flink = $('<a>').attr('target', 'github').attr('href', link).append(fdata[fname].file)
content.append($('<div>').addClass('fileLink').append("Defined in: ").append(flink))
+ // Show where this is used in the examples
+ if(ex = fdata[fname].examples) {
+ also = $('<div>').addClass('funcEx')
+ also.append("Used in examples: ")
+ for( fname in ex ) {
+ lines = ex[fname]
+ line = $('<li>')
+ line.append($('<strong>').append(fname))
+ for( var i in lines ) {
+ flink = $('<a>').attr('href', lines[i]).append(' [' + (parseInt(i) + 1) + '] ')
+ line.append(flink)
+ }
+ also.append(line)
+ }
+ content.append(also)
+ }
+
// Show other functions in this group
also = $('<div>').addClass('also')
flink = $('<a href="#" ref="' + ref.toString() + '" id="groupItem' + group[0] + '">' + group[0] + '</a>')
@@ -377,19 +394,7 @@ $(function() {
groupHash: false,
groupOf: function (func) {
- if(!this.groupHash) {
- this.groupHash = {}
- data = this.get('data')
- for(var i=0; i<data['groups'].length; i++) {
- group = data['groups'][i][1]
- groupName = data['groups'][i][0]
- for(var j=0; j<group.length; j++) {
- f = group[j]
- this.groupHash[f] = groupName
- }
- }
- }
- return this.groupHash[func]
+ return this.get('data').functions[func].group
},
addHotlinks: function() {
Please sign in to comment.
Something went wrong with that request. Please try again.