<commit_before>/*
 * Copyright (C) 2006-2009 Citrix Systems Inc.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published
 * by the Free Software Foundation; version 2.1 only. with the special
 * exception on linking described in file LICENSE.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 */
 
// global variables
 
var module = getQuerystring('m');
var module_chain = module.split('.');
var component = getQuerystring('c');

var components = executables.concat(libraries).concat(packages);
var component_modules = {};
var component_stats = {};
var component_deps = {};

var root = '/bind/myrepos/';
var code_url = 'http://xenbits.xen.org/xapi/';
    
function fill_components()
{
	for (i in components) {
		component_modules[components[i]] = eval('modules_' + components[i].replace(/\-/g, ''));
		component_stats[components[i]] = eval('stats_' + components[i].replace(/\-/g, ''));
		component_deps[components[i]] = eval('deps_' + components[i].replace(/\-/g, ''));
	}
}

function do_search()
{
	query = document.getElementById('search_box').value.toLowerCase();
	
	// search modules
	html = '<h2>Modules</h2>';
	for (z in components) {
		c = components[z];
		for (y in component_modules[c]) {
			m = component_modules[c][y].name;
			if (m.toLowerCase().indexOf(query) > -1)
				html += '<a href="codedoc.html?c=' + c + '&m=' + m + '">' + m + ' (' + c + ')</a><br/>';
		}
	}
	
	document.getElementById('results').innerHTML = html;
}

function search_key(event)
{
	if (event.keyCode == 13)
		do_search();
}

function search_page()
{
	html = "";
	html += '<h1 class="title">Search</h1>';
	html += '<input type="text" id="search_box" size="50" onkeydown="search_key(event)" /><input type="button" value="Find" onclick="do_search()" />';
	html += '<div id="results"></div>';
	set_content(html);
	
	set_sidebar("");
}

function find_component_for_module(m)
{
	// first look in own component
	modules = component_modules[component];
	for (z in modules)
		if (modules[z].name == m)
			return component;
	// search externals
	externals = libraries.concat(packages);
	for (y in externals) {
		modules = component_modules[externals[y]];
		for (z in modules)
			if (modules[z].name == m)
				return externals[y];
	}
	return "";
}

function construct_url(mod, fn)
{	
	comp = find_component_for_module(mod.split('.')[0]);
	if (comp != "")
		return 'codedoc.html?c=' + comp + '&m=' + mod + '#' + fn;
	else
		return '#';
}

function transform_links(s)
{
	return s.replace(/\{\w*\|([\w|\.]*)\.(\w*)\}/g, function(x,y,z){return construct_url(y, z)});
}

function transform_type(t)
{
	if (t != undefined && t != '') {
		params = t.split('->');
		for (i in params) {
			u = params[i];
			if (u.indexOf('?') > -1)
				optional = '<span class="optional">optional</span> ';
			else
				optional = '';
			u = u.replace(/[^\(]*:/, '');
			params[i] = optional + u;
		}
		// put back arrows
		html = params.join(' <span class="symbol large spaced">\u2192</span> ');
		// remove Pervasives.
		html = html.replace(/Pervasives\./g, '');
		// replace polymorphic params by greek letters
		html = html.replace(/\'([a-z])/g, function(x,y){return String.fromCharCode(y.charCodeAt(0) + 0x3b1 - 0x61)});
		// replaces asteriskes by times symbols
		html = html.replace(/\*/g, '<span class="symbol">\u00d7</span>');
		// replace brackets
		html = html.replace(/(\(|\))/g, '<span class="symbol large">$1</span>');
		// add links to known types
		html = html.replace(/([A-Z][\w|\.]*)\.(\w*)/g, function(x,y,z){return '<a href="' + construct_url(y, z) + '">' + y + '.' + z + '</a>'});
	}
	else
		html = '[none]';
	return html;
}

function value(v, n)
{
	l = v.name.split('.');
	name = l[l.length - 1];
	
	html = '<div class="field' + toggle(n) + '">';
	if (v.params.length > 0)
		html += '<input type="button" class="small-button" value="parameters" onclick="showhide(document.getElementById(\'' + name + '_params\'))" />';
	html += '<div class="field-type"><a name="' + name + '">[value]</a></div>';
	html += '<div class="field-name">' + name + '</div>';
			
	html += '<table class="field-table">';
	html += '<tr><td width="100px"><span class="field-head">Type:</span></td><td>' + transform_type(v.type);
/*	if (v.params.length > 0)
		html += '<tr><td></td><td><input type="button" class="small-button" value="parameters" onclick="document.getElementById(\'' + name + '_params\').style.display=\'\'; this.parentNode.parentNode.style.display=\'none\'" /></td></tr>';*/
	html += '</td></tr>';
	
	html += '<tr id="' + name +
		'_params" style="display: none"><td width="100px"><span class="field-head">Parameters:</span></td><td>';
	html += '<table>';
	for (c in v.params) {
		n = v.params[c].name;
		html += '<tr><td width="20%" style="padding: 0 0 .2em">' +
			(n == "" ? '(no name)' : v.params[c].name) + '</td>';
		html += '<td style="padding: 0 0 .2em">' + transform_type(v.params[c].type) + '</td></tr>';
	}
	html += '</table>';
	html += '</td></tr>';	
	html += '</table>';
	
	if (v.info.deprecated != undefined) {
		html += '<div class="deprecated"><b>Deprecated</b> ' + v.info.deprecated + '</div>';
	}
	
	html += '<div class="field-description">';
	if (v.info.description != undefined)
		html += transform_links(v.info.description) + '</div>';
	else
		html += '<span class="empty">to be completed!</span></div>';
		
	html += '</div>';
	append_content(html);
}

function exception(v, n)
{
	l = v.name.split('.');
	name = l[l.length - 1];
			<commit_msg>HTML code docs: Handle @param ocamldoc option<commit_after>/*
 * Copyright (C) 2006-2009 Citrix Systems Inc.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published
 * by the Free Software Foundation; version 2.1 only. with the special
 * exception on linking described in file LICENSE.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 */
 
// global variables
 
var module = getQuerystring('m');
var module_chain = module.split('.');
var component = getQuerystring('c');

var components = executables.concat(libraries).concat(packages);
var component_modules = {};
var component_stats = {};
var component_deps = {};

var root = '/bind/myrepos/';
var code_url = 'http://xenbits.xen.org/xapi/';
    
function fill_components()
{
	for (i in components) {
		component_modules[components[i]] = eval('modules_' + components[i].replace(/\-/g, ''));
		component_stats[components[i]] = eval('stats_' + components[i].replace(/\-/g, ''));
		component_deps[components[i]] = eval('deps_' + components[i].replace(/\-/g, ''));
	}
}

function do_search()
{
	query = document.getElementById('search_box').value.toLowerCase();
	
	// search modules
	html = '<h2>Modules</h2>';
	for (z in components) {
		c = components[z];
		for (y in component_modules[c]) {
			m = component_modules[c][y].name;
			if (m.toLowerCase().indexOf(query) > -1)
				html += '<a href="codedoc.html?c=' + c + '&m=' + m + '">' + m + ' (' + c + ')</a><br/>';
		}
	}
	
	document.getElementById('results').innerHTML = html;
}

function search_key(event)
{
	if (event.keyCode == 13)
		do_search();
}

function search_page()
{
	html = "";
	html += '<h1 class="title">Search</h1>';
	html += '<input type="text" id="search_box" size="50" onkeydown="search_key(event)" /><input type="button" value="Find" onclick="do_search()" />';
	html += '<div id="results"></div>';
	set_content(html);
	
	set_sidebar("");
}

function find_component_for_module(m)
{
	// first look in own component
	modules = component_modules[component];
	for (z in modules)
		if (modules[z].name == m)
			return component;
	// search externals
	externals = libraries.concat(packages);
	for (y in externals) {
		modules = component_modules[externals[y]];
		for (z in modules)
			if (modules[z].name == m)
				return externals[y];
	}
	return "";
}

function construct_url(mod, fn)
{	
	comp = find_component_for_module(mod.split('.')[0]);
	if (comp != "")
		return 'codedoc.html?c=' + comp + '&m=' + mod + '#' + fn;
	else
		return '#';
}

function transform_links(s)
{
	return s.replace(/\{\w*\|([\w|\.]*)\.(\w*)\}/g, function(x,y,z){return construct_url(y, z)});
}

function transform_type(t)
{
	if (t != undefined && t != '') {
		params = t.split('->');
		for (i in params) {
			u = params[i];
			if (u.indexOf('?') > -1)
				optional = '<span class="optional">optional</span> ';
			else
				optional = '';
			u = u.replace(/[^\(]*:/, '');
			params[i] = optional + u;
		}
		// put back arrows
		html = params.join(' <span class="symbol large spaced">\u2192</span> ');
		// remove Pervasives.
		html = html.replace(/Pervasives\./g, '');
		// replace polymorphic params by greek letters
		html = html.replace(/\'([a-z])/g, function(x,y){return String.fromCharCode(y.charCodeAt(0) + 0x3b1 - 0x61)});
		// replaces asteriskes by times symbols
		html = html.replace(/\*/g, '<span class="symbol">\u00d7</span>');
		// replace brackets
		html = html.replace(/(\(|\))/g, '<span class="symbol large">$1</span>');
		// add links to known types
		html = html.replace(/([A-Z][\w|\.]*)\.(\w*)/g, function(x,y,z){return '<a href="' + construct_url(y, z) + '">' + y + '.' + z + '</a>'});
	}
	else
		html = '[none]';
	return html;
}

function value(v, n)
{
	l = v.name.split('.');
	name = l[l.length - 1];
	
	html = '<div class="field' + toggle(n) + '">';
	if (v.params.length > 0)
		html += '<input type="button" class="small-button" value="parameters" onclick="showhide(document.getElementById(\'' + name + '_params\'))" />';
	html += '<div class="field-type"><a name="' + name + '">[value]</a></div>';
	html += '<div class="field-name">' + name + '</div>';
			
	html += '<table class="field-table">';
	html += '<tr><td width="100px"><span class="field-head">Type:</span></td><td>' + transform_type(v.type);
/*	if (v.params.length > 0)
		html += '<tr><td></td><td><input type="button" class="small-button" value="parameters" onclick="document.getElementById(\'' + name + '_params\').style.display=\'\'; this.parentNode.parentNode.style.display=\'none\'" /></td></tr>';*/
	html += '</td></tr>';
	
	html += '<tr id="' + name +
		'_params" style="display: none"><td width="100px"><span class="field-head">Parameters:</span></td><td>';
	html += '<table>';
	for (c in v.params) {
		n = v.params[c].name;
		html += '<tr><td width="20%" style="padding: 0 0 .2em">' +
			(n == "" ? '(no name)' : v.params[c].name) + '</td>';
		html += '<td style="padding: 0 0 .2em">' + transform_type(v.params[c].type) + '</td>';
		html += '<td style="padding: 0 0 .2em">' + (v.params[c].comment != undefined ? v.params[c].comment : '') + '</td></tr>';
	}
	html += '</table>';
	html += '</td></tr>';	
	html += '</table>';
	
	if (v.info.deprecated != undefined) {
		html += '<div class="deprecated"><b>Deprecated</b> ' + v.info.deprecated + '</div>';
	}
	
	html += '<div class="field-description">';
	if (v.info.description != undefined)
		html += transform_links(v.info.description) + '</div>';
	else
		html += '<span class="empty">to be completed!</span></div>';
		
	html += '</div>';
	append_content(html);
}

function exception(v, n)
{
	l = v.name.split('.');
	name = l[l.length - 1];
			
{'fraction_non_alphanumeric': 0.22246164454404413, 'fraction_numerical': 0.009567315980003448, 'mean_word_length': 3.9798283261802574, 'pattern_counts': {'":': 0, '<': 149, '<?xml version=': 0, '>': 159, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4784759', 'n_tokens_mistral': 4310, 'n_tokens_neox': 4034, 'n_words': 960}