# HG changeset patch # User Rob Hoes [ocamldoc] Links to source code on module pages Signed-off-by: Rob Hoes diff -r 22784973b624 ocaml/doc/ocamldoc.js --- a/ocaml/doc/ocamldoc.js Wed Jan 13 12:13:48 2010 +0000 +++ b/ocaml/doc/ocamldoc.js Wed Jan 13 15:56:30 2010 +0000 @@ -19,10 +19,12 @@ var component = getQuerystring('c'); var components = executables.concat(libraries).concat(packages); -var component_modules = {} -var component_stats = {} -var component_deps = {} +var component_modules = {}; +var component_stats = {}; +var component_deps = {}; +var root = '/bind/myrepos/'; +var code_url = 'http://xenbits.xen.org/xapi/'; // function from http://www.bloggingdeveloper.com/post/JavaScript-QueryString-ParseGet-QueryString-with-Client-Side-JavaScript.aspx function getQuerystring(key, default_) @@ -452,12 +454,30 @@ '&m=' + module_chain.slice(0,i+1).join('.') + '">' + module_chain[i] + ''; html += chain.join('.') + '\n'; - html += '
Defined in ' + mod.file + ' (' + component + ')
'; + html += '
'; if (mod.info.description != undefined) html += mod.info.description + '
'; else html += 'to be completed!'; + + html += '
'; + html += ''; + r = new RegExp(root + '([^\|]*)\|\d*'); + if (mod.location.interface != 'unknown') { + if_file = r.exec(mod.location.interface)[1]; + x = /([\.\-\w]*)\/([^\|]*)/.exec(if_file); + url = code_url + x[1] + '?raw-file/tip/' + x[2]; + html += ''; + } + if (mod.location.implementation != 'unknown') { + im_file = r.exec(mod.location.implementation)[1]; + x = /([\.\-\w]*)\/([^\|]*)/.exec(im_file); + url = code_url + x[1] + '?raw-file/tip/' + x[2]; + html += ''; + } + html += '
Component:' + component + ' 
Interface file:' + if_file + '
Implementation file:' + im_file + '
'; + set_content(html); if (mod.module_structure != undefined) diff -r 22784973b624 ocaml/doc/odoc_json.ml --- a/ocaml/doc/odoc_json.ml Wed Jan 13 12:13:48 2010 +0000 +++ b/ocaml/doc/odoc_json.ml Wed Jan 13 15:56:30 2010 +0000 @@ -132,18 +132,21 @@ let escape_json s = let len = String.length s in - let buf = Buffer.create len in - for i = 0 to len - 1 do - match s.[i] with - | '\"' -> Buffer.add_string buf "\\\"" - | '\\' -> Buffer.add_string buf "\\\\" - | '\b' -> Buffer.add_string buf "\\b" - | '\n' -> Buffer.add_string buf "\\n" - | '\r' -> Buffer.add_string buf "\\r" - | '\t' -> Buffer.add_string buf "\\t" - | c -> Buffer.add_char buf c - done; - Buffer.contents buf + if len > 0 then begin + let buf = Buffer.create len in + for i = 0 to len - 1 do + match s.[i] with + | '\"' -> Buffer.add_string buf "\\\"" + | '\\' -> Buffer.add_string buf "\\\\" + | '\b' -> Buffer.add_string buf "\\b" + | '\n' -> Buffer.add_string buf "\\n" + | '\r' -> Buffer.add_string buf "\\r" + | '\t' -> Buffer.add_string buf "\\t" + | c -> Buffer.add_char buf c + done; + Buffer.contents buf + end + else "" type json = | Object of (string * json) list diff -r 22784973b624 ocaml/doc/style.css --- a/ocaml/doc/style.css Wed Jan 13 12:13:48 2010 +0000 +++ b/ocaml/doc/style.css Wed Jan 13 15:56:30 2010 +0000 @@ -187,8 +187,9 @@ } .defined { - font-style: italic; margin: 1em 0; + padding: 0 .5em; + background-color: #ffcc66; } .description {