Commit 49861796 authored by claes's avatar claes

Groups of classes in html files

parent 06b046df
......@@ -487,7 +487,7 @@ int ClassRead::read( char *filename)
break;
default:
printf( "Error, unknown linetype, at line %d\n", line_cnt);
printf( "Error, unknown linetype, %s, at line %d\n", filename, line_cnt);
return sts = CNV__UNKNOWN_LINETYPE;
}
if ( EVEN(sts))
......@@ -827,8 +827,10 @@ void ClassRead::doc_init()
memset( doc_clink_text, 0, sizeof(doc_clink_text));
memset( doc_link_ref, 0, sizeof(doc_link_ref));
memset( doc_link_text, 0, sizeof(doc_link_text));
memset( doc_groups, 0, sizeof(doc_groups));
doc_clink_cnt = 0;
doc_link_cnt = 0;
doc_group_cnt = 0;
}
int ClassRead::doc_add( char *line)
......@@ -841,32 +843,35 @@ int ClassRead::doc_add( char *line)
sizeof( line_part) / sizeof( line_part[0]),
sizeof( line_part[0]), 0);
if ( strcmp( low(line_part[1]), "@author") == 0)
{
for ( i = 2; i < nr; i++)
{
if ( strcmp( low(line_part[1]), "@author") == 0) {
for ( i = 2; i < nr; i++) {
if ( i != 2)
strcat( doc_author, " ");
strcat( doc_author, line_part[i]);
}
}
else if ( strcmp( low(line_part[1]), "@version") == 0)
{
for ( i = 2; i < nr; i++)
{
else if ( strcmp( low(line_part[1]), "@version") == 0) {
for ( i = 2; i < nr; i++) {
if ( i != 2)
strcat( doc_version, " ");
strcat( doc_version, line_part[i]);
}
}
else if ( strcmp( low(line_part[1]), "@link") == 0)
{
else if ( strcmp( low(line_part[1]), "@group") == 0) {
char str[400];
remove_spaces( line, str);
remove_spaces( &str[6], str);
doc_group_cnt = dcli_parse( str, " ,", "", (char *)doc_groups,
sizeof( doc_groups) / sizeof( doc_groups[0]),
sizeof( doc_groups[0]), 0);
}
else if ( strcmp( low(line_part[1]), "@link") == 0) {
if ( doc_link_cnt >= (int) (sizeof(doc_link_ref)/sizeof(doc_link_ref[0]))) {
printf("Error: max number of links exceeded\n");
return 1;
}
for ( i = 2; i < nr; i++)
{
for ( i = 2; i < nr; i++) {
if ( i == nr - 1)
strcpy( doc_link_ref[doc_link_cnt], line_part[i]);
else {
......@@ -877,14 +882,12 @@ int ClassRead::doc_add( char *line)
}
doc_link_cnt++;
}
else if ( strcmp( low(line_part[1]), "@classlink") == 0)
{
else if ( strcmp( low(line_part[1]), "@classlink") == 0) {
if ( doc_clink_cnt >= (int) (sizeof(doc_clink_ref)/sizeof(doc_clink_ref[0]))) {
printf("Error: max number of classlinks exceeded\n");
return 1;
}
for ( i = 2; i < nr; i++)
{
for ( i = 2; i < nr; i++) {
if ( i == nr - 1)
strcpy( doc_clink_ref[doc_clink_cnt], line_part[i]);
else {
......@@ -895,13 +898,11 @@ int ClassRead::doc_add( char *line)
}
doc_clink_cnt++;
}
else if ( strcmp( low(line_part[1]), "@code") == 0)
{
else if ( strcmp( low(line_part[1]), "@code") == 0) {
if ( nr > 2)
strcpy( doc_code, line_part[2]);
}
else if ( strcmp( low(line_part[1]), "@summary") == 0)
{
else if ( strcmp( low(line_part[1]), "@summary") == 0) {
char low_line[400];
char *s;
......@@ -912,8 +913,7 @@ int ClassRead::doc_add( char *line)
strcpy( doc_summary, &line[s - low_line + 9]);
}
else
{
else {
if ( doc_cnt > int(sizeof(doc_text)/sizeof(doc_text[0]) - 1))
return 0;
strcpy( doc_text[doc_cnt], &line[1]);
......
......@@ -18,6 +18,8 @@ extern "C" {
using namespace std;
#define MAX_GROUPS 100
typedef enum {
cread_eLine_No,
cread_eLine_EOF,
......@@ -86,11 +88,11 @@ class CnvFile {
class ClassRead {
public:
ClassRead() : first_class(1), verbose(0), generate_html(0),
html_class_open(0), html_index_open(0),
html_class_open(0), html_index_open(0),
generate_xtthelp(0), xtthelp_index_open(0), xtthelp_in_topic(0),
generate_src(0), generate_struct(0), struct_class_open(0),
common_structfile_only(0)
{};
generate_src(0), generate_struct(0), struct_class_open(0),
common_structfile_only(0), setup_group_cnt(0)
{ strcpy( setup_filename, "");};
~ClassRead() {};
FILE *fp;
......@@ -126,6 +128,8 @@ class ClassRead {
char graphplccon_name[20];
char doc_author[200];
char doc_version[80];
char doc_groups[10][40];
int doc_group_cnt;
char doc_code[200];
char doc_link_ref[20][80];
char doc_link_text[20][200];
......@@ -181,6 +185,7 @@ class ClassRead {
CnvFile *html_clf;
ofstream fp_html_index;
ofstream fp_tmp;
ofstream fp_html_group[MAX_GROUPS];
char html_first[80];
char html_tmp_name[80];
int html_class_open;
......@@ -250,6 +255,12 @@ class ClassRead {
void struct_get_filename( char *struct_file);
int struct_check_typename( char *name);
// Setup
char setup_filename[120];
int setup_group_cnt;
char setup_groups[MAX_GROUPS][40];
char setup_groups_startpage[MAX_GROUPS][80];
int setup();
};
#if defined __cplusplus
......
......@@ -16,6 +16,7 @@ extern "C" {
int ClassRead::html_init( char *first)
{
char fname[200];
char gname[200];
char allclasses_name[80];
strcpy( html_first, volume_name);
......@@ -28,13 +29,22 @@ int ClassRead::html_init( char *first)
cdh_ToLower( allclasses_name, allclasses_name);
// Create index file
strcpy( fname, dir);
strcat( fname, volume_name);
strcat( fname, "_index.html");
cdh_ToLower( fname, fname);
fp_html_index.open( fname);
{
strcpy( fname, dir);
strcat( fname, volume_name);
strcat( fname, "_index.html");
cdh_ToLower( fname, fname);
ofstream fp( fname);
// Get group menu name
if ( setup_group_cnt) {
strcpy( gname, low(volume_name));
strcat( gname, "_menu_group.html");
cdh_ToLower( fname, fname);
}
fp_html_index <<
fp <<
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\"\"http://www.w3.org/TR/REC-html40/loose.dtd>" << endl <<
"<!--NewPage-->" << endl <<
"<HTML>" << endl <<
......@@ -44,8 +54,18 @@ int ClassRead::html_init( char *first)
"Generated Documentation (Untitled)" << endl <<
"</TITLE>" << endl <<
"</HEAD>" << endl <<
"<FRAMESET cols=\"20%,80%\">" << endl <<
"<FRAME src=\"" << allclasses_name << "\" name=\"packageFrame\">" << endl <<
"<FRAMESET cols=\"20%,80%\">" << endl;
if ( setup_group_cnt)
fp <<
"<FRAMESET rows=\"20%,80%\">" << endl <<
"<FRAME src=\"" << gname << "\" name=\"groupFrame\">" << endl <<
"<FRAME src=\"" << allclasses_name << "\" name=\"menuFrame\">" << endl <<
"</FRAMESET>" << endl;
else
fp <<
"<FRAME src=\"" << allclasses_name << "\" name=\"menuFrame\">" << endl;
fp <<
"<FRAME src=\"" << html_first << ".html\" name=\"classFrame\">" << endl <<
"</FRAMESET>" << endl <<
"<NOFRAMES>" << endl <<
......@@ -57,8 +77,68 @@ int ClassRead::html_init( char *first)
"<BR>" << endl <<
"Link to <A HREF=\"" << html_first << ".html\">Non-frame version.</A></NOFRAMES>" << endl <<
"</HTML>" << endl;
}
fp_html_index.close();
// Create group menu file
if ( setup_group_cnt) {
strcpy( fname, dir);
strcat( fname, gname);
cdh_ToLower( fname, fname);
ofstream fp( fname);
fp <<
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Frameset//EN\"\"http://www.w3.org/TR/REC-html40/frameset.dtd\">" << endl <<
"<!--NewPage-->" << endl <<
"<HTML>" << endl <<
"<HEAD>" << endl <<
"<!-- Generated by wbdoc on... -->" << endl <<
"<TITLE>" << endl <<
"Groups" << endl <<
"</TITLE>" << endl <<
"<LINK REL =\"stylesheet\" TYPE=\"text/css\" HREF=\"stylesheet.css\" TITLE=\"Style\">" << endl <<
"</HEAD>" << endl <<
"<BODY BGCOLOR=\"white\">" << endl <<
"<FONT size=\"+1\" CLASS=\"FrameHeadingFont\">" << endl <<
"<B>Groups</B></FONT>" << endl <<
"<BR>" << endl <<
"" << endl <<
"<TABLE BORDER=\"0\" WIDTH=\"100%\">" << endl <<
"<TR>" << endl <<
"<TD NOWRAP><FONT CLASS=\"FrameItemFont\"> " << endl;
// Put index filename in fname
strcpy( fname, volume_name);
strcat( fname, "_index.html");
cdh_ToLower( fname, fname);
fp <<
"<A HREF=\"" << fname << "\" TARGET=\"_parent\">AllClasses</A>" << endl <<
"<BR>" << endl;
for ( int i = 0; i < setup_group_cnt; i++) {
// Put group index filename in fname
strcpy( fname, volume_name);
strcat( fname, "_group_");
strcat( fname, setup_groups[i]);
strcat( fname, "_index.html");
cdh_ToLower( fname, fname);
fp <<
"<A HREF=\"" << fname << "\" TARGET=\"_parent\">" << setup_groups[i] << "</A>" << endl <<
"<BR>" << endl;
}
fp <<
"</FONT></TD>" << endl <<
"</TR>" << endl <<
"</TABLE>" << endl <<
"" << endl <<
"</BODY>" << endl <<
"</HTML>" << endl;
}
// Open allclasses file
strcpy( fname, dir);
......@@ -89,6 +169,92 @@ int ClassRead::html_init( char *first)
"<TR>" << endl <<
"<TD NOWRAP><FONT CLASS=\"FrameItemFont\"> " << endl;
// Open one index file for each configured group
for ( int i = 0; i < setup_group_cnt; i++) {
// Create index page for each group
strcpy( fname, dir);
strcat( fname, volume_name);
strcat( fname, "_group_");
strcat( fname, setup_groups[i]);
strcat( fname, "_index.html");
cdh_ToLower( fname, fname);
{
ofstream fp( fname);
// Put menu filename in fname
strcpy( fname, volume_name);
strcat( fname, "_group_");
strcat( fname, setup_groups[i]);
strcat( fname, ".html");
cdh_ToLower( fname, fname);
fp <<
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\"\"http://www.w3.org/TR/REC-html40/loose.dtd>" << endl <<
"<!--NewPage-->" << endl <<
"<HTML>" << endl <<
"<HEAD>" << endl <<
"<!-- Generated by co_convert.-->" << endl <<
"<TITLE>" << endl <<
"Generated Documentation (Untitled)" << endl <<
"</TITLE>" << endl <<
"</HEAD>" << endl <<
"<FRAMESET cols=\"20%,80%\">" << endl <<
"<FRAMESET rows=\"20%,80%\">" << endl <<
"<FRAME src=\"" << gname << "\" name=\"groupFrame\">" << endl <<
"<FRAME src=\"" << fname << "\" name=\"menuFrame\">" << endl <<
"</FRAMESET>" << endl;
if ( strcmp( setup_groups_startpage[i], "") == 0)
fp <<
"<FRAME name=\"classFrame\">" << endl;
else
fp <<
"<FRAME src=\"" << setup_groups_startpage[i] << "\" name=\"classFrame\">" << endl;
fp <<
"</FRAMESET>" << endl <<
"<NOFRAMES>" << endl <<
"<H2>" << endl <<
"Frame Alert</H2>" << endl <<
"<P>" << endl <<
"This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client." << endl <<
"<BR>" << endl <<
"Link to <A HREF=\"" << html_first << ".html\">Non-frame version.</A></NOFRAMES>" << endl <<
"</HTML>" << endl;
}
// Create menu page
strcpy( fname, dir);
strcat( fname, volume_name);
strcat( fname, "_group_");
strcat( fname, setup_groups[i]);
strcat( fname, ".html");
cdh_ToLower( fname, fname);
fp_html_group[i].open( fname);
fp_html_group[i] <<
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Frameset//EN\"\"http://www.w3.org/TR/REC-html40/frameset.dtd\">" << endl <<
"<!--NewPage-->" << endl <<
"<HTML>" << endl <<
"<HEAD>" << endl <<
"<!-- Generated by wbdoc on... -->" << endl <<
"<TITLE>" << endl <<
setup_groups[i] << endl <<
"</TITLE>" << endl <<
"<LINK REL =\"stylesheet\" TYPE=\"text/css\" HREF=\"stylesheet.css\" TITLE=\"Style\">" << endl <<
"</HEAD>" << endl <<
"<BODY BGCOLOR=\"white\">" << endl <<
"<FONT size=\"+1\" CLASS=\"FrameHeadingFont\">" << endl <<
"<B>" << setup_groups[i] << "</B></FONT>" << endl <<
"<BR>" << endl <<
"" << endl <<
"<TABLE BORDER=\"0\" WIDTH=\"100%\">" << endl <<
"<TR>" << endl <<
"<TD NOWRAP><FONT CLASS=\"FrameItemFont\"> " << endl;
}
return 1;
}
......@@ -104,6 +270,17 @@ int ClassRead::html_close()
"</HTML>" << endl;
fp_html_index.close();
for ( int i = 0; i < setup_group_cnt; i++) {
fp_html_group[i] <<
"</FONT></TD>" << endl <<
"</TR>" << endl <<
"</TABLE>" << endl <<
"" << endl <<
"</BODY>" << endl <<
"</HTML>" << endl;
fp_html_group[i].close();
}
return 1;
}
......@@ -138,6 +315,17 @@ int ClassRead::html_class()
"<A HREF=\"" << html_file_name << ".html\" TARGET=\"classFrame\">" << class_name << "</A>" << endl <<
"<BR>" << endl;
// Add into group file
for ( int i = 0; i < doc_group_cnt; i++) {
for ( int j = 0; j < setup_group_cnt; j++) {
if ( cdh_NoCaseStrcmp( doc_groups[i], setup_groups[j]) == 0) {
fp_html_group[j] <<
"<A HREF=\"" << html_file_name << ".html\" TARGET=\"classFrame\">" << class_name << "</A>" << endl <<
"<BR>" << endl;
}
}
}
// Create class html file
strcpy( fname, dir);
......
......@@ -547,17 +547,26 @@ int ClassRead::struct_volname_to_id()
int sts;
unsigned int vid_0, vid_1, vid_2, vid_3;
strcpy( struct_volid, "");
strcpy( fname, source_dir);
strcat( fname, low(volume_name));
strcat( fname, "_v.wb_load");
strcpy( struct_volid, "");
fp = fopen( fname, "r");
if ( !fp)
{
// printf( "** Unable to open volume wb_load file\n");
return 0;
if ( !fp) {
strcpy( fname, source_dir);
strcat( fname, "usertypes.wb_load");
fp = fopen( fname, "r");
if ( !fp) {
strcpy( fname, source_dir);
strcat( fname, "userclasses.wb_load");
fp = fopen( fname, "r");
if ( !fp) {
printf( "** Unable to open volume wb_load file\n");
return 0;
}
}
}
while( 1)
......
#include <stdio.h>
#include <float.h>
#include <string.h>
#include <stdlib.h>
#include <iostream.h>
#include <fstream.h>
extern "C" {
#include "pwr.h"
#include "co_dcli.h"
#include "co_cdh.h"
}
#include "cnv_classread.h"
int ClassRead::setup()
{
int sts;
char line[400];
char line_part[4][80];
int nr;
char line_cnt = 0;
fp = fopen( setup_filename, "r");
if ( !fp)
return 0;
while( 1) {
sts = read_line( line, sizeof(line), fp);
if ( !sts)
break;
else {
line_cnt++;
remove_spaces( line, line);
if ( strcmp( line, "") == 0)
continue;
if ( line[0] == '!' || line[0] == '#')
continue;
nr = dcli_parse( line, " =", "", (char *)line_part,
sizeof( line_part) / sizeof( line_part[0]),
sizeof( line_part[0]), 0);
if ( strcmp( low( line_part[0]), "group") == 0){
if ( nr < 2) {
printf("** Setup syntax error in file %s, line %d\n", setup_filename, line_cnt);
continue;
}
if ( setup_group_cnt >= (int)(sizeof(setup_groups)/sizeof(setup_groups[0]))) {
printf("** Max number of groups exceeded in file %s, line %d\n", setup_filename, line_cnt);
continue;
}
strcpy( setup_groups[setup_group_cnt], line_part[1]);
if ( nr >= 3)
strcpy( setup_groups_startpage[setup_group_cnt], line_part[2]);
else
strcpy( setup_groups_startpage[setup_group_cnt], "");
setup_group_cnt++;
}
}
}
fclose(fp);
return 1;
}
......@@ -25,6 +25,7 @@ static void usage()
printf( " -so: Create one common h file from wb_load-files\n");
printf( " -t: Create html from xtthelp-file\n");
printf( " -d: Output directory\n");
printf( " -g: Setup file\n");
printf( " -h: Help\n\n");
}
......@@ -78,20 +79,16 @@ int main( int argc, char *argv[])
int xtthelp_to_html = 0;
if ( argc < 2 || argc > 6)
{
if ( argc < 2 || argc > 8) {
usage();
exit(0);
}
cr = new ClassRead();
for ( i = 1; i < argc; i++)
{
if ( strcmp( argv[i], "-d") == 0)
{
if ( i+1 >= argc)
{
for ( i = 1; i < argc; i++) {
if ( strcmp( argv[i], "-d") == 0) {
if ( i+1 >= argc) {
usage();
exit(0);
}
......@@ -107,13 +104,18 @@ int main( int argc, char *argv[])
strcat( cr->dir , "/");
#endif
}
else if ( argv[i][0] == '-')
{
if ( strcmp( argv[i], "-g") == 0) {
if ( i+1 >= argc) {
usage();
exit(0);
}
strcpy( cr->setup_filename, argv[i+1]);
i++;
}
else if ( argv[i][0] == '-') {
s = &argv[i][1];
while( *s)
{
switch( *s)
{
while( *s) {
switch( *s) {
case 'h':
help();
exit(0);
......@@ -149,6 +151,9 @@ int main( int argc, char *argv[])
strcpy( files, argv[i]);
}
if ( strcmp( cr->setup_filename, "") != 0)
cr->setup();
if ( xtthelp_to_html) {
XhelpToHtml *xh = new XhelpToHtml( files, cr->dir);
delete xh;
......@@ -187,11 +192,9 @@ int main( int argc, char *argv[])
printf( "Processing file %s\n", file_p[i]);
if ( cr->generate_src)
cr->src_read( file_p[i]);
else
{
else {
sts = cr->read( file_p[i]);
if ( EVEN(sts))
{
if ( EVEN(sts)) {
exit_sts = sts;
break;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment