<commit_before>/*
 * Valadoc - a documentation tool for vala.
 * Copyright (C) 2008 <NAME>
 * 
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the 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 General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */


using GLib;
using Gee;


public class Valadoc.Html.TypeLinkInlineTaglet : Valadoc.InlineTaglet {
	private string? link = null;
	private string? name = null;
	private string? css = null;

	protected override string to_string ( ) {
		return this.name;
	}

	protected override bool write ( void* res, int max, int index ) {
		if ( this.link == null ) {
			((GLib.FileStream)res).printf ( "<span class=\"%s\">%s</span>", this.css, this.name );
		}
		else {
			((GLib.FileStream)res).printf ( "<a class=\"%s\" href=\"%s\">%s</a>", this.css, this.link, this.name );
		}

		return true;
	}

	protected override bool parse ( Settings settings, Tree tree, Documentation self, string content, ref ErrorLevel errlvl, out string? errmsg ) {
		Valadoc.DocumentedElement? element = tree.search_symbol_str ( (self is DocumentedElement)? (DocumentedElement)self : null, content.strip() );
		if ( element == null ) {
			errmsg = "Linked type is not available";
			errlvl = ErrorLevel.ERROR;
			return false;
		}

		this.name = element.full_name ();
		this.css = get_html_content_link_css_class ( element );
		this.link = get_html_link ( settings, element, self );
		return true;
	}
}


<commit_msg>Make type links showing relative names<commit_after>/*
 * Valadoc - a documentation tool for vala.
 * Copyright (C) 2008 <NAME>
 * 
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the 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 General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */


using GLib;
using Gee;


public class Valadoc.Html.TypeLinkInlineTaglet : Valadoc.InlineTaglet {
	private string? link = null;
	private string? name = null;
	private string? css = null;

	protected override string to_string ( ) {
		return this.name;
	}

	protected override bool write ( void* res, int max, int index ) {
		if ( this.link == null ) {
			((GLib.FileStream)res).printf ( "<span class=\"%s\">%s</span>", this.css, this.name );
		}
		else {
			((GLib.FileStream)res).printf ( "<a class=\"%s\" href=\"%s\">%s</a>", this.css, this.link, this.name );
		}

		return true;
	}

	protected override bool parse ( Settings settings, Tree tree, Documentation self, string content, ref ErrorLevel errlvl, out string? errmsg ) {
		Valadoc.DocumentedElement? element = tree.search_symbol_str ( (self is DocumentedElement)? (DocumentedElement)self : null, content.strip() );
		if ( element == null ) {
			errmsg = "Linked type is not available";
			errlvl = ErrorLevel.ERROR;
			return false;
		}

		this.name = element.full_name ();
		if (self is DocumentedElement) {
			var doc_element = (DocumentedElement) self;
			var doc_element_name = doc_element.full_name ();

			if (this.name == doc_element_name) {
				this.name = element.name;
			} else if (this.name.has_prefix (doc_element_name)) {
				this.name = this.name.substring (doc_element_name.length + 1);
			} else if (doc_element.parent != null && doc_element.parent is DocumentedElement) {
				var doc_parent_element_name = ((DocumentedElement) doc_element.parent).full_name ();
				if (this.name == doc_parent_element_name) {
					this.name = element.name;
				} else if (this.name.has_prefix (doc_parent_element_name)) {
					this.name = this.name.substring (doc_parent_element_name.length + 1);
				}
			}
		}
		this.css = get_html_content_link_css_class ( element );
		this.link = get_html_link ( settings, element, self );
		return true;
	}
}



{'fraction_non_alphanumeric': 0.10848252344416028, 'fraction_numerical': 0.007246376811594203, 'mean_word_length': 3.7548125633232017, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '6531759', 'n_tokens_mistral': 1533, 'n_tokens_neox': 1394, 'n_words': 499}