<commit_before>/* 
 * jcom.hub - autodoc
 * Generate HTML documentation for the jcom.hub external
 * By <NAME> & <NAME>, Copyright  2006
 * 
 * License: This code is licensed under the terms of the GNU LGPL
 * http://www.gnu.org/licenses/lgpl.html 
 */

#include "jcom.hub.h"


void hub_autodoc(t_hub *x, t_symbol *userpath)
{
	defer_low(x, (method)hub_doautodoc, userpath, 0, 0L);
}


void hub_doautodoc(t_hub *x, t_symbol *userpath)
{
	long 			type = 'TEXT';				// four-char code for Mac file type
	char 			filename[256];				// for storing the name of the file locally
	short 			path, err;					// pathID#, error number
	long			outtype;					// the file type that is actually true
	t_filehandle	file_handle;				// a reference to our file (for opening it, closing it, etc.)
	long			myEof = 0;
	char 			tempstring[1024];
	subscriberList	*subscriber = x->subscriber;	// the head of the linked list
	long			argc;
	t_atom			a[2];
	t_atom			*argv = &a[0];
	t_symbol		*result;
	t_symbol		*msg_type;
	//long			num_signals;
	float			range[2];

	// SPECIFY THE FILE WE WANT TO WRITE
	if(!userpath->s_name[0]){												// Empty string - Throw up a dialog
		sprintf(filename, "%s.html", x->attr_name->s_name);					// Default File Name
		saveas_promptset("Save Generated HTML Documentation...");			// Instructional Text in the dialog
		err = saveasdialog_extended(filename, &path, &outtype, &type, 1);	// Returns 0 if successful
		if(err)																// User Cancelled
			return;															
	}
	else{
		strcpy(filename, userpath->s_name);									// Copy symbol argument to a local string
		path = 0;		
	}

	// NOW ATTEMPT TO CREATE THE FILE...
	err = path_createsysfile(filename, path, type, &file_handle);
	if(err){																// Handle any errors that occur
		error("jcom.hub: %s - error %d creating file", filename, err);
		return;	
	}

	// HERE WE CAN FINALLY WRITE THE DATA OUT TO THE FILE
	
	// html header
	jcom_core_file_writeline(&file_handle, &myEof, "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">");	
	jcom_core_file_writeline(&file_handle, &myEof, "<html>");
	jcom_core_file_writeline(&file_handle, &myEof, "\t<head>");
	jcom_core_file_writeline(&file_handle, &myEof, "\t\t<meta http-equiv=\"content-type\" content=\"text/html;charset=ISO-8859-1\">");
	sprintf(tempstring, "<title> %s </title>", x->attr_name->s_name);	
	jcom_core_file_writeline(&file_handle, &myEof, tempstring);
//	jcom_core_file_writeline(&file_handle, &myEof, "\t\t<link href=\"../styles/jamoma.css\" rel=\"stylesheet\" type=\"text/css\">");	
	hub_autodoc_css(&file_handle, &myEof);
	jcom_core_file_writeline(&file_handle, &myEof, "\t</head>");
	jcom_core_file_writeline(&file_handle, &myEof, "");

	// html body
	jcom_core_file_writeline(&file_handle, &myEof, "<body>");
	jcom_core_file_writeline(&file_handle, &myEof, "\t<div id=\"jmod_header\">");

	// Top of page displaying name of module etc.
	jcom_core_file_writeline(&file_handle, &myEof, "\t<img src=\"../images/jmod.icon.mod.png\" width=\"128\" height=\"128\">");	
	sprintf(tempstring, "\t<h1> %s </h1>", x->attr_name->s_name);
	jcom_core_file_writeline(&file_handle, &myEof, tempstring);
	sprintf(tempstring, "\t<h2> %s </h2>", x->attr_description->s_name);
	jcom_core_file_writeline(&file_handle, &myEof, tempstring);

	// Menu
	jcom_core_file_writeline(&file_handle, &myEof, "\t<h6><a href=\"../index.html\">Table of Contents</a> | <a href=\"../modules/\">Index of Modules</a> | <a href=\"http://jamoma.org/\">Jamoma.org</a></h6>");
	jcom_core_file_writeline(&file_handle, &myEof, "\t</div>");
	jcom_core_file_writeline(&file_handle, &myEof, "");
		
	// Configuration
	jcom_core_file_writeline(&file_handle, &myEof, "\t<h3> Configuration </h3>");<commit_msg>Getting CSS, Jamoma Icon and Index URL working again in html documentation.<commit_after>/* 
 * jcom.hub - autodoc
 * Generate HTML documentation for the jcom.hub external
 * By <NAME> & <NAME>, Copyright  2006
 * 
 * License: This code is licensed under the terms of the GNU LGPL
 * http://www.gnu.org/licenses/lgpl.html 
 */

#include "jcom.hub.h"


void hub_autodoc(t_hub *x, t_symbol *userpath)
{
	defer_low(x, (method)hub_doautodoc, userpath, 0, 0L);
}


void hub_doautodoc(t_hub *x, t_symbol *userpath)
{
	long 			type = 'TEXT';				// four-char code for Mac file type
	char 			filename[256];				// for storing the name of the file locally
	short 			path, err;					// pathID#, error number
	long			outtype;					// the file type that is actually true
	t_filehandle	file_handle;				// a reference to our file (for opening it, closing it, etc.)
	long			myEof = 0;
	char 			tempstring[1024];
	subscriberList	*subscriber = x->subscriber;	// the head of the linked list
	long			argc;
	t_atom			a[2];
	t_atom			*argv = &a[0];
	t_symbol		*result;
	t_symbol		*msg_type;
	//long			num_signals;
	float			range[2];

	// SPECIFY THE FILE WE WANT TO WRITE
	if(!userpath->s_name[0]){												// Empty string - Throw up a dialog
		sprintf(filename, "%s.html", x->attr_name->s_name);					// Default File Name
		saveas_promptset("Save Generated HTML Documentation...");			// Instructional Text in the dialog
		err = saveasdialog_extended(filename, &path, &outtype, &type, 1);	// Returns 0 if successful
		if(err)																// User Cancelled
			return;															
	}
	else{
		strcpy(filename, userpath->s_name);									// Copy symbol argument to a local string
		path = 0;		
	}

	// NOW ATTEMPT TO CREATE THE FILE...
	err = path_createsysfile(filename, path, type, &file_handle);
	if(err){																// Handle any errors that occur
		error("jcom.hub: %s - error %d creating file", filename, err);
		return;	
	}

	// HERE WE CAN FINALLY WRITE THE DATA OUT TO THE FILE
	
	// html header
	jcom_core_file_writeline(&file_handle, &myEof, "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">");	
	jcom_core_file_writeline(&file_handle, &myEof, "<html>");
	jcom_core_file_writeline(&file_handle, &myEof, "\t<head>");
	jcom_core_file_writeline(&file_handle, &myEof, "\t\t<meta http-equiv=\"content-type\" content=\"text/html;charset=ISO-8859-1\">");
	sprintf(tempstring, "<title> %s </title>", x->attr_name->s_name);	
	jcom_core_file_writeline(&file_handle, &myEof, tempstring);
//	jcom_core_file_writeline(&file_handle, &myEof, "\t\t<link href=\"../../../documentation/html/styles/jamoma.css\" rel=\"stylesheet\" type=\"text/css\">");	
	hub_autodoc_css(&file_handle, &myEof);
	jcom_core_file_writeline(&file_handle, &myEof, "\t</head>");
	jcom_core_file_writeline(&file_handle, &myEof, "");

	// html body
	jcom_core_file_writeline(&file_handle, &myEof, "<body>");
	jcom_core_file_writeline(&file_handle, &myEof, "\t<div id=\"jmod_header\">");

	// Top of page displaying name of module etc.
	jcom_core_file_writeline(&file_handle, &myEof, "\t<img src=\"../../../documentation/images/jmod.icon.mod.png\" width=\"128\" height=\"128\">");	
	sprintf(tempstring, "\t<h1> %s </h1>", x->attr_name->s_name);
	jcom_core_file_writeline(&file_handle, &myEof, tempstring);
	sprintf(tempstring, "\t<h2> %s </h2>", x->attr_description->s_name);
	jcom_core_file_writeline(&file_handle, &myEof, tempstring);

	// Menu
	jcom_core_file_writeline(&file_handle, &myEof, "\t<h6><a href=\"../../../documentation/html/index.html\">Table of Contents</a> | <a href=\"../modules/\">Index of Modules</a> | <a href=\"http://jamoma.org/\">Jamoma.org</a></h6>");
	jcom_core_file_writeline(&file_handle, &myEof, "\t</div>");
	jcom_core_file_writeline(&file_handle, &myEof, "");
		
	// Configuration
	jcom_core_file_writeline(&file_handle, &myEof, "\t<h3> Configuration </h3>");
{'fraction_non_alphanumeric': 0.16363396624472573, 'fraction_numerical': 0.011603375527426161, 'mean_word_length': 3.880952380952381, 'pattern_counts': {'":': 0, '<': 59, '<?xml version=': 0, '>': 81, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '2397064', 'n_tokens_mistral': 3131, 'n_tokens_neox': 2846, 'n_words': 648}