finished converting doc writer to using Out_Context

master
Allen Webster 2016-09-04 12:39:21 -04:00
parent a80e99d575
commit a132a697b1
2 changed files with 433 additions and 3619 deletions

File diff suppressed because one or more lines are too long

View File

@ -1670,98 +1670,81 @@ compile_meta_unit(Partition *part, char **files, int32_t file_count,
} }
static void static void
print_struct_html(FILE *file, Item_Node *member){ print_struct_html(String *out, Item_Node *member){
String name = member->name; String name = member->name;
String type = member->type; String type = member->type;
String type_postfix = member->type_postfix; String type_postfix = member->type_postfix;
append_ss (out, type);
append_s_char (out, ' ');
append_ss (out, name);
append_ss (out, type_postfix);
if (match_ss(type, make_lit_string("struct")) || if (match_ss(type, make_lit_string("struct")) ||
match_ss(type, make_lit_string("union"))){ match_ss(type, make_lit_string("union"))){
fprintf(file, append_sc(out, " {<br><div style='margin-left: 8mm;'>");
"%.*s %.*s {<br>\n"
"<div style='margin-left: 8mm;'>\n",
type.size, type.str,
name.size, name.str);
for (Item_Node *member_iter = member->first_child; for (Item_Node *member_iter = member->first_child;
member_iter != 0; member_iter != 0;
member_iter = member_iter->next_sibling){ member_iter = member_iter->next_sibling){
print_struct_html(file, member_iter); print_struct_html(out, member_iter);
} }
fprintf(file, append_sc(out, "</div>};<br>");
"</div>\n"
"};<br>\n");
} }
else{ else{
fprintf(file, append_sc(out, ";<br>");
"%.*s %.*s%.*s;<br>\n",
type.size, type.str,
name.size, name.str,
type_postfix.size, type_postfix.str
);
} }
} }
static void static void
print_function_html(FILE *file, Item_Node item, String name, print_function_html(String *out, String ret, char *function_call_head, String name, Argument_Breakdown breakdown){
char *function_call_head){ append_ss (out, ret);
String ret = item.ret; append_s_char (out, ' ');
fprintf(file, append_sc (out, function_call_head);
"%.*s %s%.*s(\n" append_ss (out, name);
"<div style='margin-left: 4mm;'>", append_sc (out, "(<div style='margin-left: 4mm;'>");
ret.size, ret.str,
function_call_head,
name.size, name.str);
Argument_Breakdown breakdown = item.breakdown; for (int32_t j = 0; j < breakdown.count; ++j){
int32_t arg_count = breakdown.count; append_ss(out, breakdown.args[j].param_string);
for (int32_t j = 0; j < arg_count; ++j){ if (j < breakdown.count - 1){
String param_string = breakdown.args[j].param_string; append_s_char(out, ',');
if (j < arg_count - 1){
fprintf(file, "%.*s,<br>", param_string.size, param_string.str);
}
else{
fprintf(file, "%.*s<br>", param_string.size, param_string.str);
} }
append_sc(out, "<br>");
} }
fprintf(file, "</div>)\n"); append_sc(out, "</div>)");
} }
static void static void
print_macro_html(FILE *file, Item_Node item, String name){ print_macro_html(String *out, String name, Argument_Breakdown breakdown){
Argument_Breakdown breakdown = item.breakdown;
int32_t arg_count = breakdown.count; if (breakdown.count == 0){
if (arg_count == 0){ append_sc(out, "#define ");
fprintf(file, append_ss(out, name);
"#define %.*s()", append_sc(out, "()");
name.size, name.str);
} }
else if (arg_count == 1){ else if (breakdown.count == 1){
String param_string = breakdown.args[0].param_string; append_sc (out, "#define ");
fprintf(file, append_ss (out, name);
"#define %.*s(%.*s)", append_s_char (out, '(');
name.size, name.str, append_ss (out, breakdown.args[0].param_string);
param_string.size, param_string.str); append_s_char (out, ')');
} }
else{ else{
fprintf(file, append_sc (out, "#define ");
"#define %.*s(\n" append_ss (out, name);
"<div style='margin-left: 4mm;'>", append_sc (out, "(<div style='margin-left: 4mm;'>");
name.size, name.str);
for (int32_t j = 0; j < arg_count; ++j){ for (int32_t j = 0; j < breakdown.count; ++j){
String param_string = breakdown.args[j].param_string; append_ss(out, breakdown.args[j].param_string);
if (j < arg_count - 1){ if (j < breakdown.count - 1){
fprintf(file, "%.*s,<br>", param_string.size, param_string.str); append_s_char(out, ',');
}
else{
fprintf(file, "%.*s<br>", param_string.size, param_string.str);
} }
append_sc(out, "<br>");
} }
fprintf(file, "</div>)\n"); append_sc(out, ")</div>)");
} }
} }
@ -1796,28 +1779,47 @@ print_macro_html(FILE *file, Item_Node item, String name){
#define DOC_ITEM_CLOSE "</div>" #define DOC_ITEM_CLOSE "</div>"
static void static void
print_struct_docs(FILE *file, Partition *part, Item_Node *member){ print_struct_docs(String *out, Partition *part, Item_Node *member){
for (Item_Node *member_iter = member->first_child; for (Item_Node *member_iter = member->first_child;
member_iter != 0; member_iter != 0;
member_iter = member_iter->next_sibling){ member_iter = member_iter->next_sibling){
String type = member_iter->type; String type = member_iter->type;
if (match_ss(type, make_lit_string("struct")) || if (match_ss(type, make_lit_string("struct")) ||
match_ss(type, make_lit_string("union"))){ match_ss(type, make_lit_string("union"))){
print_struct_docs(file, part, member_iter); print_struct_docs(out, part, member_iter);
} }
else{ else{
Documentation doc = {0}; Documentation doc = {0};
perform_doc_parse(part, member_iter->doc_string, &doc); perform_doc_parse(part, member_iter->doc_string, &doc);
fprintf(file, append_sc(out, "<div>");
"<div>\n"
"<div style='"CODE_STYLE"'>"DOC_ITEM_HEAD_INL_OPEN append_sc(out, "<div style='"CODE_STYLE"'>"DOC_ITEM_HEAD_INL_OPEN);
"%.*s"DOC_ITEM_HEAD_INL_CLOSE"</div>\n" append_ss(out, member_iter->name);
"<div style='margin-bottom: 6mm;'>"DOC_ITEM_OPEN"%.*s"DOC_ITEM_CLOSE"</div>\n" append_sc(out, DOC_ITEM_HEAD_INL_CLOSE"</div>");
"</div>\n",
member_iter->name.size, member_iter->name.str, append_sc(out, "<div style='margin-bottom: 6mm;'>"DOC_ITEM_OPEN);
doc.main_doc.size, doc.main_doc.str append_ss(out, doc.main_doc);
); append_sc(out, DOC_ITEM_CLOSE"</div>");
append_sc(out, "</div>");
}
}
}
static void
print_see_also(String *out, Documentation *doc){
int32_t doc_see_count = doc->see_also_count;
if (doc_see_count > 0){
append_sc(out, DOC_HEAD_OPEN"See Also"DOC_HEAD_CLOSE);
for (int32_t j = 0; j < doc_see_count; ++j){
String see_also = doc->see_also[j];
append_sc(out, DOC_ITEM_OPEN"<a href='#");
append_ss(out, see_also);
append_sc(out, "_doc'>");
append_ss(out, see_also);
append_sc(out, "</a>"DOC_ITEM_CLOSE);
} }
} }
} }
@ -1839,36 +1841,6 @@ print_see_also(FILE *file, Documentation *doc){
} }
} }
#if 0
typedef struct String_Function_Marker{
int32_t parse_function;
int32_t is_inline;
int32_t parse_doc;
int32_t cpp_name;
} String_Function_Marker;
static String_Function_Marker
string_function_marker_check(String lexeme){
String_Function_Marker result = {0};
if (match_ss(lexeme, make_lit_string("FSTRING_INLINE"))){
result.is_inline = true;
result.parse_function = true;
}
else if (match_ss(lexeme, make_lit_string("FSTRING_LINK"))){
result.parse_function = true;
}
else if (match_ss(lexeme, make_lit_string("DOC_EXPORT"))){
result.parse_doc = true;
}
else if (match_ss(lexeme, make_lit_string("CPP_NAME"))){
result.cpp_name = true;
}
return(result);
}
#endif
static void static void
print_str(FILE *file, String str){ print_str(FILE *file, String str){
if (str.size > 0){ if (str.size > 0){
@ -1925,175 +1897,208 @@ print_function_body_code(String *out, Parse_Context *context, int32_t start){
} }
static void static void
print_function_docs(FILE *file, Partition *part, String name, String doc_string){ print_function_docs(String *out, Partition *part, String name, String doc_string){
if (doc_string.size == 0){ if (doc_string.size == 0){
fprintf(file, "No documentation generated for this function.\n"); append_sc(out, "No documentation generated for this function.");
fprintf(stderr, "warning: no documentation string for %.*s\n", name.size, name.str); fprintf(stderr, "warning: no documentation string for %.*s\n", name.size, name.str);
} }
Documentation doc_ = {0}; Temp_Memory temp = begin_temp_memory(part);
Documentation *doc = &doc_;
perform_doc_parse(part, doc_string, doc); Documentation doc = {0};
int32_t doc_param_count = doc->param_count; perform_doc_parse(part, doc_string, &doc);
int32_t doc_param_count = doc.param_count;
if (doc_param_count > 0){ if (doc_param_count > 0){
fprintf(file, DOC_HEAD_OPEN"Parameters"DOC_HEAD_CLOSE); append_sc(out, DOC_HEAD_OPEN"Parameters"DOC_HEAD_CLOSE);
for (int32_t j = 0; j < doc_param_count; ++j){ for (int32_t j = 0; j < doc_param_count; ++j){
String param_name = doc->param_name[j]; String param_name = doc.param_name[j];
String param_docs = doc->param_docs[j]; String param_docs = doc.param_docs[j];
// TODO(allen): check that param_name is actually // TODO(allen): check that param_name is actually
// a parameter to this function! // a parameter to this function!
fprintf(file, append_sc(out, "<div>"DOC_ITEM_HEAD_OPEN);
"<div>\n" append_ss(out, param_name);
DOC_ITEM_HEAD_OPEN"%.*s"DOC_ITEM_HEAD_CLOSE"\n" append_sc(out, DOC_ITEM_HEAD_CLOSE"<div style='margin-bottom: 6mm;'>"DOC_ITEM_OPEN);
"<div style='margin-bottom: 6mm;'>"DOC_ITEM_OPEN"%.*s"DOC_ITEM_CLOSE"</div>\n" append_ss(out, param_docs);
"</div>\n", append_sc(out, DOC_ITEM_CLOSE"</div></div>");
param_name.size, param_name.str,
param_docs.size, param_docs.str
);
} }
} }
String ret_doc = doc->return_doc; String ret_doc = doc.return_doc;
if (ret_doc.size != 0){ if (ret_doc.size != 0){
fprintf(file, DOC_HEAD_OPEN"Return"DOC_HEAD_CLOSE); append_sc(out, DOC_HEAD_OPEN"Return"DOC_HEAD_CLOSE DOC_ITEM_OPEN);
fprintf(file, append_ss(out, ret_doc);
DOC_ITEM_OPEN"%.*s"DOC_ITEM_CLOSE, append_sc(out, DOC_ITEM_CLOSE);
ret_doc.size, ret_doc.str
);
} }
String main_doc = doc->main_doc; String main_doc = doc.main_doc;
if (main_doc.size != 0){ if (main_doc.size != 0){
fprintf(file, DOC_HEAD_OPEN"Description"DOC_HEAD_CLOSE); append_sc(out, DOC_HEAD_OPEN"Description"DOC_HEAD_CLOSE DOC_ITEM_OPEN);
fprintf(file, append_ss(out, main_doc);
DOC_ITEM_OPEN"%.*s"DOC_ITEM_CLOSE, append_sc(out, DOC_ITEM_CLOSE);
main_doc.size, main_doc.str
);
} }
print_see_also(file, doc); print_see_also(out, &doc);
end_temp_memory(temp);
} }
static void static void
print_item(Partition *part, FILE *file, Item_Node *item, char *section, int32_t I){ print_item_in_list(String *out, String name, char *id_postfix){
append_sc(out, "<li><a href='#");
append_ss(out, name);
append_sc(out, id_postfix);
append_sc(out, "'>");
append_ss(out, name);
append_sc(out, "</a></li>");
}
static void
print_item(String *out, Partition *part, Item_Node *item,
char *id_postfix, char *function_prefix,
char *section, int32_t I){
Temp_Memory temp = begin_temp_memory(part);
String name = item->name; String name = item->name;
/* NOTE(allen): /* NOTE(allen):
Open a div for the whole item. Open a div for the whole item.
Put a heading in it with the name and section. Put a heading in it with the name and section.
Open a "descriptive" box for the display of the code interface. Open a "descriptive" box for the display of the code interface.
*/ */
fprintf(file, append_sc(out, "<div id='");
"<div id='%.*s_doc' style='margin-bottom: 1cm;'>\n" append_ss(out, name);
"<h4>&sect;%s.%d: %.*s</h4>\n" append_sc(out, id_postfix);
"<div style='"CODE_STYLE" "DESCRIPT_SECTION_STYLE"'>", append_sc(out, "' style='margin-bottom: 1cm;'>");
name.size, name.str, section, I, name.size, name.str);
Temp_Memory temp = begin_temp_memory(part); append_sc (out, "<h4>&sect;");
append_sc (out, section);
append_s_char (out, '.');
append_int_to_str (out, I);
append_sc (out, ": ");
append_ss (out, name);
append_sc (out, "</h4>");
append_sc(out, "<div style='"CODE_STYLE" "DESCRIPT_SECTION_STYLE"'>");
switch (item->t){ switch (item->t){
case Item_Function:
{
// NOTE(allen): Code box
Assert(function_prefix != 0);
print_function_html(out, item->ret, function_prefix, item->name, item->breakdown);
// NOTE(allen): Close the code box
append_sc(out, "</div>");
// NOTE(allen): Descriptive section
print_function_docs(out, part, item->name, item->doc_string);
}break;
case Item_Macro:
{
// NOTE(allen): Code box
print_macro_html(out, item->name, item->breakdown);
// NOTE(allen): Close the code box
append_sc(out, "</div>");
// NOTE(allen): Descriptive section
print_function_docs(out, part, item->name, item->doc_string);
}break;
case Item_Typedef: case Item_Typedef:
{ {
String type = item->type; String type = item->type;
// NOTE(allen): Code box // NOTE(allen): Code box
{ append_sc (out, "typedef ");
fprintf(file, append_ss (out, type);
"typedef %.*s %.*s;", append_s_char (out, ' ');
type.size, type.str, append_ss (out, name);
name.size, name.str append_s_char (out, ';');
);
}
// NOTE(allen): Close the descriptive box // NOTE(allen): Close the code box
fprintf(file, "</div>\n"); append_sc(out, "</div>");
// NOTE(allen): Descriptive section // NOTE(allen): Descriptive section
{
String doc_string = item->doc_string; String doc_string = item->doc_string;
Documentation doc = {0}; Documentation doc = {0};
perform_doc_parse(part, doc_string, &doc); perform_doc_parse(part, doc_string, &doc);
String main_doc = doc.main_doc; String main_doc = doc.main_doc;
if (main_doc.size != 0){ if (main_doc.size != 0){
fprintf(file, DOC_HEAD_OPEN"Description"DOC_HEAD_CLOSE); append_sc(out, DOC_HEAD_OPEN"Description"DOC_HEAD_CLOSE);
fprintf(file,
DOC_ITEM_OPEN"%.*s"DOC_ITEM_CLOSE, append_sc(out, DOC_ITEM_OPEN);
main_doc.size, main_doc.str append_ss(out, main_doc);
); append_sc(out, DOC_ITEM_CLOSE);
} }
print_see_also(file, &doc); print_see_also(out, &doc);
}
}break; }break;
case Item_Enum: case Item_Enum:
{ {
// NOTE(allen): Code box // NOTE(allen): Code box
{ append_sc (out, "enum ");
fprintf(file, append_ss (out, name);
"enum %.*s;", append_s_char (out, ';');
name.size, name.str);
}
// NOTE(allen): Close the descriptive box // NOTE(allen): Close the code box
fprintf(file, "</div>\n"); append_sc(out, "</div>");
// NOTE(allen): Descriptive section // NOTE(allen): Descriptive section
{
String doc_string = item->doc_string; String doc_string = item->doc_string;
Documentation doc = {0}; Documentation doc = {0};
perform_doc_parse(part, doc_string, &doc); perform_doc_parse(part, doc_string, &doc);
String main_doc = doc.main_doc; String main_doc = doc.main_doc;
if (main_doc.size != 0){ if (main_doc.size != 0){
fprintf(file, DOC_HEAD_OPEN"Description"DOC_HEAD_CLOSE); append_sc(out, DOC_HEAD_OPEN"Description"DOC_HEAD_CLOSE);
fprintf(file,
DOC_ITEM_OPEN"%.*s"DOC_ITEM_CLOSE, append_sc(out, DOC_ITEM_OPEN);
main_doc.size, main_doc.str append_ss(out, main_doc);
); append_sc(out, DOC_ITEM_CLOSE);
} }
if (item->first_child){ if (item->first_child){
fprintf(file, DOC_HEAD_OPEN"Values"DOC_HEAD_CLOSE); append_sc(out, DOC_HEAD_OPEN"Values"DOC_HEAD_CLOSE);
for (Item_Node *member = item->first_child; for (Item_Node *member = item->first_child;
member; member;
member = member->next_sibling){ member = member->next_sibling){
Documentation doc = {0}; Documentation doc = {0};
perform_doc_parse(part, member->doc_string, &doc); perform_doc_parse(part, member->doc_string, &doc);
append_sc(out, "<div>");
// NOTE(allen): Dafuq is this all?
append_sc(out, "<div><span style='"CODE_STYLE"'>"DOC_ITEM_HEAD_INL_OPEN);
append_ss(out, member->name);
append_sc(out, DOC_ITEM_HEAD_INL_CLOSE);
if (member->value.str){ if (member->value.str){
fprintf(file, append_sc(out, " = ");
"<div>\n" append_ss(out, member->value);
"<div><span style='"CODE_STYLE"'>"DOC_ITEM_HEAD_INL_OPEN
"%.*s"DOC_ITEM_HEAD_INL_CLOSE" = %.*s</span></div>\n"
"<div style='margin-bottom: 6mm;'>"DOC_ITEM_OPEN"%.*s"DOC_ITEM_CLOSE"</div>\n"
"</div>\n",
member->name.size, member->name.str,
member->value.size, member->value.str,
doc.main_doc.size, doc.main_doc.str
);
}
else{
fprintf(file,
"<div>\n"
"<div><span style='"CODE_STYLE"'>"DOC_ITEM_HEAD_INL_OPEN
"%.*s"DOC_ITEM_HEAD_INL_CLOSE"</span></div>\n"
"<div style='margin-bottom: 6mm;'>"DOC_ITEM_OPEN"%.*s"DOC_ITEM_CLOSE"</div>\n"
"</div>\n",
member->name.size, member->name.str,
doc.main_doc.size, doc.main_doc.str
);
} }
append_sc(out, "</span></div>");
append_sc(out, "<div style='margin-bottom: 6mm;'>"DOC_ITEM_OPEN);
append_ss(out, doc.main_doc);
append_sc(out, DOC_ITEM_CLOSE"</div>");
append_sc(out, "</div>");
} }
} }
print_see_also(file, &doc); print_see_also(out, &doc);
}
}break; }break;
case Item_Struct: case Item_Union: case Item_Struct: case Item_Union:
@ -2101,12 +2106,10 @@ print_item(Partition *part, FILE *file, Item_Node *item, char *section, int32_t
Item_Node *member = item; Item_Node *member = item;
// NOTE(allen): Code box // NOTE(allen): Code box
{ print_struct_html(out, member);
print_struct_html(file, member);
}
// NOTE(allen): Close the descriptive box // NOTE(allen): Close the code box
fprintf(file, "</div>\n"); append_sc(out, "</div>");
// NOTE(allen): Descriptive section // NOTE(allen): Descriptive section
{ {
@ -2116,25 +2119,25 @@ print_item(Partition *part, FILE *file, Item_Node *item, char *section, int32_t
String main_doc = doc.main_doc; String main_doc = doc.main_doc;
if (main_doc.size != 0){ if (main_doc.size != 0){
fprintf(file, DOC_HEAD_OPEN"Description"DOC_HEAD_CLOSE); append_sc(out, DOC_HEAD_OPEN"Description"DOC_HEAD_CLOSE);
fprintf(file,
DOC_ITEM_OPEN"%.*s"DOC_ITEM_CLOSE, append_sc(out, DOC_ITEM_OPEN);
main_doc.size, main_doc.str append_ss(out, main_doc);
); append_sc(out, DOC_ITEM_CLOSE);
} }
if (member->first_child){ if (member->first_child){
fprintf(file, DOC_HEAD_OPEN"Fields"DOC_HEAD_CLOSE); append_sc(out, DOC_HEAD_OPEN"Fields"DOC_HEAD_CLOSE);
print_struct_docs(file, part, member); print_struct_docs(out, part, member);
} }
print_see_also(file, &doc); print_see_also(out, &doc);
} }
}break; }break;
} }
// NOTE(allen): Close the item box // NOTE(allen): Close the item box
fprintf(file, "</div><hr>\n"); append_sc(out, "</div><hr>");
end_temp_memory(temp); end_temp_memory(temp);
} }
@ -2240,9 +2243,6 @@ generate_custom_headers(){
String out = str_alloc(part, 10 << 20); String out = str_alloc(part, 10 << 20);
Out_Context context = {0}; Out_Context context = {0};
// TODO(allen): delete this ASAP
FILE *file = 0;
// NOTE(allen): Custom API headers // NOTE(allen): Custom API headers
if (begin_file_out(&context, OS_API_H, &out)){ if (begin_file_out(&context, OS_API_H, &out)){
int32_t main_api_count = unit_custom.parse[0].item_count; int32_t main_api_count = unit_custom.parse[0].item_count;
@ -2328,8 +2328,6 @@ generate_custom_headers(){
// NOTE(allen): String Library // NOTE(allen): String Library
if (begin_file_out(&context, STRING_H, &out)){ if (begin_file_out(&context, STRING_H, &out)){
file = context.file;
Cpp_Token *token = 0; Cpp_Token *token = 0;
int32_t start = 0; int32_t start = 0;
@ -2615,8 +2613,6 @@ generate_custom_headers(){
append_sc(&out, append_sc(&out,
"<h3 style='margin:0;'>Table of Contents</h3>""<ul>"); "<h3 style='margin:0;'>Table of Contents</h3>""<ul>");
dump_file_out(context);
int32_t section_count = ArrayCount(sections); int32_t section_count = ArrayCount(sections);
for (int32_t i = 0; i < section_count; ++i){ for (int32_t i = 0; i < section_count; ++i){
append_sc (&out, "<li><a href='#section_"); append_sc (&out, "<li><a href='#section_");
@ -2670,19 +2666,12 @@ generate_custom_headers(){
append_sc(&out, sections[2].display_string); append_sc(&out, sections[2].display_string);
append_sc(&out, "</h2>"); append_sc(&out, "</h2>");
#undef SECTION #undef SECTION
#define SECTION MAJOR_SECTION".1" #define SECTION MAJOR_SECTION".1"
append_sc(&out, "<h3>&sect;"SECTION" Function List</h3><ul>"); append_sc(&out, "<h3>&sect;"SECTION" Function List</h3><ul>");
for (int32_t i = 0; i < unit_custom.set.count; ++i){ for (int32_t i = 0; i < unit_custom.set.count; ++i){
String name = func_4ed_names.names[i].public_name; print_item_in_list(&out, func_4ed_names.names[i].public_name, "_doc");
append_sc(&out, "<li><a href='#");
append_ss(&out, name);
append_sc(&out, "_doc'>");
append_ss(&out, name);
append_sc(&out, "</a></li>");
} }
append_sc(&out, "</ul>"); append_sc(&out, "</ul>");
@ -2690,22 +2679,17 @@ generate_custom_headers(){
#define SECTION MAJOR_SECTION".2" #define SECTION MAJOR_SECTION".2"
append_sc(&out, "<h3>&sect;"SECTION" Type List</h3><ul>"); append_sc(&out, "<h3>&sect;"SECTION" Type List</h3><ul>");
for (int32_t i = 0; i < unit.set.count; ++i){ for (int32_t i = 0; i < unit.set.count; ++i){
String name = unit.set.items[i].name; print_item_in_list(&out, unit.set.items[i].name, "_doc");
append_sc(&out, "<li><a href='#");
append_ss(&out, name);
append_sc(&out, "_doc'>");
append_ss(&out, name);
append_sc(&out, "</a></li>");
} }
append_sc(&out, "</ul>"); append_sc(&out, "</ul>");
#undef SECTION #undef SECTION
#define SECTION MAJOR_SECTION".3" #define SECTION MAJOR_SECTION".3"
append_sc(&out, "<h3>&sect;"SECTION" Function Descriptions</h3>\n"); append_sc(&out, "<h3>&sect;"SECTION" Function Descriptions</h3>");
for (int32_t i = 0; i < unit_custom.set.count; ++i){ for (int32_t i = 0; i < unit_custom.set.count; ++i){
Item_Node *item = &unit_custom.set.items[i];
String name = func_4ed_names.names[i].public_name; String name = func_4ed_names.names[i].public_name;
append_sc (&out, "<div id='"); append_sc (&out, "<div id='");
@ -2716,139 +2700,61 @@ generate_custom_headers(){
append_ss (&out, name); append_ss (&out, name);
append_sc (&out, "</h4><div style='"CODE_STYLE" "DESCRIPT_SECTION_STYLE"'>"); append_sc (&out, "</h4><div style='"CODE_STYLE" "DESCRIPT_SECTION_STYLE"'>");
dump_file_out(context); print_function_html(&out, item->ret, "app->", name, item->breakdown);
append_sc(&out, "</div>");
// TODO(allen): Continue converting this to the string system. print_function_docs(&out, part, name, item->doc_string);
print_function_html(file, unit_custom.set.items[i], name, "app->");
fprintf(file, "</div>\n");
String doc_string = unit_custom.set.items[i].doc_string; append_sc(&out, "</div><hr>");
print_function_docs(file, part, name, doc_string);
fprintf(file, "</div><hr>\n");
} }
#undef SECTION #undef SECTION
#define SECTION MAJOR_SECTION".4" #define SECTION MAJOR_SECTION".4"
fprintf(file, "<h3>&sect;"SECTION" Type Descriptions</h3>\n"); append_sc(&out, "<h3>&sect;"SECTION" Type Descriptions</h3>");
int32_t I = 1; int32_t I = 1;
for (int32_t i = 0; i < unit.set.count; ++i, ++I){ for (int32_t i = 0; i < unit.set.count; ++i, ++I){
print_item(part, file, unit.set.items + i, SECTION, I); print_item(&out, part, unit.set.items + i, "_doc", 0, SECTION, I);
} }
#undef MAJOR_SECTION #undef MAJOR_SECTION
#define MAJOR_SECTION "4" #define MAJOR_SECTION "4"
fprintf(file, append_sc(&out, "\n<h2 id='section_");
"<h2 id='section_%s'>&sect;"MAJOR_SECTION" %s</h2>\n", append_sc(&out, sections[3].id_string);
sections[3].id_string, append_sc(&out, "'>&sect;"MAJOR_SECTION" ");
sections[3].display_string); append_sc(&out, sections[3].display_string);
append_sc(&out, "</h2>");
{
#undef SECTION #undef SECTION
#define SECTION MAJOR_SECTION".1" #define SECTION MAJOR_SECTION".1"
fprintf(file, append_sc(&out, "<h3>&sect;"SECTION" String Intro</h3>");
"<h3>&sect;"SECTION" String Intro</h3>\n"
"<ul>\n");
{ append_sc(&out, "<div><i>Coming Soon</i><div>");
fprintf(file,
"<div><i>\n"
"Coming Soon"
"</i><div>\n");
}
#undef SECTION #undef SECTION
#define SECTION MAJOR_SECTION".2" #define SECTION MAJOR_SECTION".2"
fprintf(file, append_sc(&out, "<h3>&sect;"SECTION" String Function List</h3>");
"<h3>&sect;"SECTION" String Function List</h3>\n"
"<ul>\n");
// TODO(allen): I don't think used_strings is necessary any more
// since I have made the default names C compatible there will
// be no overloading.
String *used_strings = 0;
int32_t used_string_count = 0;
used_strings = push_array(part, String, string_unit.set.count);
memset(used_strings, 0, sizeof(String)*string_unit.set.count);
append_sc(&out, "<ul>");
for (int32_t i = 0; i < string_unit.set.count; ++i){ for (int32_t i = 0; i < string_unit.set.count; ++i){
String name = string_unit.set.items[i].name; print_item_in_list(&out, string_unit.set.items[i].name, "_str_doc");
int32_t index = 0;
if (!string_set_match(used_strings, used_string_count, name, &index)){
fprintf(file,
"<li><a href='#%.*s_str_doc'>%.*s</a></li>\n",
name.size, name.str,
name.size, name.str
);
used_strings[used_string_count++] = name;
} }
} append_sc(&out, "</ul>");
fprintf(file, "</ul>\n");
used_string_count = 0;
#undef SECTION #undef SECTION
#define SECTION MAJOR_SECTION".3" #define SECTION MAJOR_SECTION".3"
fprintf(file, append_sc(&out, "<h3>&sect;"SECTION" String Function Descriptions</h3>");
"<h3>&sect;"SECTION" String Function Descriptions</h3>\n"
"<ul>\n");
for (int32_t i = 0; i < string_unit.set.count; ++i){ for (int32_t i = 0; i < string_unit.set.count; ++i){
Item_Node *item = &string_unit.set.items[i]; print_item(&out, part, string_unit.set.items+i, "_str_doc", "", SECTION, i+1);
String name = item->name;
int32_t index = 0;
int32_t do_id = false;
if (!string_set_match(used_strings, used_string_count, name, &index)){
do_id = true;
used_strings[used_string_count++] = name;
} }
if (do_id){ append_sc(&out, "</div></body></html>");
fprintf(file,
"<div id='%.*s_str_doc'>",
name.size, name.str
);
}
else{
fprintf(file, "<div>");
}
fprintf(file,
"<h4>&sect;"SECTION".%d: %.*s</h4>\n"
"<div style='"CODE_STYLE" "DESCRIPT_SECTION_STYLE"'>\n",
i+1, name.size, name.str);
if (item->t == Item_Macro){
print_macro_html(file, *item, name);
}
else{
print_function_html(file, *item, name, "");
}
fprintf(file, "</div>\n");
print_function_docs(file, part, name, item->doc_string);
fprintf(file, "</div><hr>\n");
}
}
fprintf(file,
"</div>\n"
"</body>\n"
"</html>\n"
);
end_file_out(context); end_file_out(context);
} }
else{ else{