diff --git a/meta/4ed_file_moving.h b/meta/4ed_file_moving.h index a76328a7..970a236c 100644 --- a/meta/4ed_file_moving.h +++ b/meta/4ed_file_moving.h @@ -6,8 +6,8 @@ By Allen Webster // TOP -#if !defined(FTECH_FILE_MOVING_H) -#define FTECH_FILE_MOVING_H +#if !defined(FRED_FILE_MOVING_H) +#define FRED_FILE_MOVING_H #include "../4ed_os_comp_cracking.h" diff --git a/site/4ed_abstract_document.cpp b/site/4ed_abstract_document.cpp index 0fad1c9f..9ed8a8ff 100644 --- a/site/4ed_abstract_document.cpp +++ b/site/4ed_abstract_document.cpp @@ -21,9 +21,9 @@ load_enriched_text(char *directory, char *filename){ char space[256]; String fname = make_fixed_width_string(space); - append_sc(&fname, directory); - append_sc(&fname, "/"); - append_sc(&fname, filename); + append(&fname, directory); + append(&fname, "/"); + append(&fname, filename); terminate_with_null(&fname); result.source = file_dump(fname.str); @@ -235,7 +235,7 @@ set_section_name(Document_Item *item, char *name, i32 show_title){ i32 name_len = str_size(name); item->section.name = make_string_cap(fm_push_array(char, name_len+1), 0, name_len+1); fm_align(); - append_sc(&item->section.name, name); + append(&item->section.name, name); item->section.show_title = show_title; } @@ -244,7 +244,7 @@ set_section_id(Document_Item *item, char *id){ i32 id_len = str_size(id); item->section.id = make_string_cap(fm_push_array(char, id_len+1), 0, id_len+1); fm_align(); - append_sc(&item->section.id, id); + append(&item->section.id, id); } internal void @@ -474,28 +474,28 @@ struct Section_Counter{ i32 nest_level; }; -internal i32 +internal b32 doc_get_link_string(Abstract_Item *doc, char *space, i32 capacity){ String str = make_string_cap(space, 0, capacity); - append_sc(&str, doc->name); - append_sc(&str, ".html"); - i32 result = terminate_with_null(&str); + append(&str, doc->name); + append(&str, ".html"); + b32 result = terminate_with_null(&str); return(result); } -internal i32 +internal b32 img_get_link_string(Abstract_Item *img, char *space, i32 capacity, i32 w, i32 h){ String str = make_string_cap(space, 0, capacity); - append_sc(&str, img->name); + append(&str, img->name); - append_sc(&str, "_"); + append(&str, "_"); append_int_to_str(&str, w); - append_sc(&str, "_"); + append(&str, "_"); append_int_to_str(&str, h); - append_sc(&str, "."); - append_sc(&str, img->extension); - i32 result = terminate_with_null(&str); + append(&str, "."); + append(&str, img->extension); + b32 result = terminate_with_null(&str); return(result); } @@ -505,7 +505,7 @@ append_section_number_reduced(String *out, Section_Counter *section_counter, i32 for (i32 i = 1; i <= level; ++i){ append_int_to_str(out, section_counter->counter[i]); if (i != level){ - append_sc(out, "."); + append(out, "."); } } } @@ -549,11 +549,10 @@ extract_command_body(String *out, String l, i32 *i_in_out, i32 *body_start_out, if (require_body){ #define STR_START "! Doc generator error: missing body for " #define STR_SLOW " !" - append_sc(out, STR_START); - append_ss(out, command_name); - append_sc(out, STR_SLOW); + append(out, STR_START); + append(out, command_name); + append(out, STR_SLOW); #undef STR - fprintf(stderr, "error: missing body for %.*s\n", command_name.size, command_name.str); } } @@ -569,31 +568,31 @@ internal void html_render_section_header(String *out, String section_name, String section_id, Section_Counter *section_counter){ if (section_counter->nest_level <= 1){ if (section_id.size > 0){ - append_sc(out, "\n

§"); + append(out, "\n

§"); } else{ - append_sc(out, "\n

§"); + append(out, "\n

§"); } append_section_number(out, section_counter); - append_sc(out, " "); - append_ss(out, section_name); - append_sc(out, "

"); + append(out, " "); + append(out, section_name); + append(out, ""); } else{ if (section_id.size > 0){ - append_sc(out, "

§"); + append(out, "

§"); } else{ - append_sc(out, "

§"); + append(out, "

§"); } append_section_number(out, section_counter); - append_sc(out, " "); - append_ss(out, section_name); - append_sc(out, "

"); + append(out, " "); + append(out, section_name); + append(out, ""); } } @@ -603,7 +602,7 @@ internal void write_enriched_text_html(String *out, Enriched_Text *text, Document_System *doc_system, Section_Counter *section_counter){ String source = text->source; - append_sc(out, "
"); + append(out, "
"); i32 item_counter = 0; @@ -611,7 +610,7 @@ write_enriched_text_html(String *out, Enriched_Text *text, Document_System *doc_ line.str; line = get_next_double_line(source, line)){ String l = skip_chop_whitespace(line); - append_sc(out, "

"); + append(out, "

"); i32 start = 0, i = 0; for (; i < l.size; ++i){ @@ -619,21 +618,21 @@ write_enriched_text_html(String *out, Enriched_Text *text, Document_System *doc_ switch (ch){ case '<': { - append_ss(out, substr(l, start, i-start)); - append_sc(out, "<"); + append(out, substr(l, start, i-start)); + append(out, "<"); start = i+1; }break; case '>': { - append_ss(out, substr(l, start, i-start)); - append_sc(out, ">"); + append(out, substr(l, start, i-start)); + append(out, ">"); start = i+1; }break; case '\\': { - append_ss(out, substr(l, start, i-start)); + append(out, substr(l, start, i-start)); i32 command_start = i+1; i32 command_end = command_start; @@ -694,8 +693,8 @@ write_enriched_text_html(String *out, Enriched_Text *text, Document_System *doc_ i32 match_index = 0; if (string_set_match(enriched_commands, ArrayCount(enriched_commands), command_string, &match_index)){ switch (match_index){ - case Cmd_BackSlash: append_sc(out, "\\"); break; - case Cmd_Version: append_sc(out, VERSION); break; + case Cmd_BackSlash: append(out, "\\"); break; + case Cmd_Version: append(out, VERSION); break; case Cmd_BeginStyle: { @@ -705,14 +704,14 @@ write_enriched_text_html(String *out, Enriched_Text *text, Document_System *doc_ String body_text = substr(l, body_start, body_end - body_start); body_text = skip_chop_whitespace(body_text); if (match_sc(body_text, "code")){ - append_sc(out, ""); + append(out, ""); } } }break; case Cmd_EndStyle: { - append_sc(out, ""); + append(out, ""); }break; // TODO(allen): upgrade this bs @@ -723,39 +722,39 @@ write_enriched_text_html(String *out, Enriched_Text *text, Document_System *doc_ if (has_body){ String body_text = substr(l, body_start, body_end - body_start); body_text = skip_chop_whitespace(body_text); - append_sc(out, ""); - append_ss(out, body_text); - append_sc(out, ""); + append(out, ""); + append(out, body_text); + append(out, ""); } }break; case Cmd_BeginList: { - append_sc(out,"

"); }break; case Cmd_BeginItem: { if (item_counter == 0){ - append_sc(out, "
  • "); + append(out, "
  • "); ++item_counter; } else{ - append_sc(out, "
  • "); + append(out, "
  • "); item_counter = 0; } }break; case Cmd_EndItem: { - append_sc(out, "
  • "); + append(out, ""); }break; case Cmd_Section: @@ -781,20 +780,20 @@ write_enriched_text_html(String *out, Enriched_Text *text, Document_System *doc_ String body_text = substr(l, body_start, body_end - body_start); body_text = skip_chop_whitespace(body_text); - append_sc(out, "doc_list, doc_name); if (doc_lookup){ char space[256]; if (doc_get_link_string(doc_lookup, space, sizeof(space))){ - append_sc(out, space); + append(out, space); } else{ NotImplemented; @@ -802,15 +801,15 @@ write_enriched_text_html(String *out, Enriched_Text *text, Document_System *doc_ } } else{ - append_ss(out, body_text); + append(out, body_text); } - append_sc(out, "'>"); + append(out, "'>"); } }break; case Cmd_EndLink: { - append_sc(out, ""); + append(out, ""); }break; case Cmd_Image: @@ -845,22 +844,22 @@ write_enriched_text_html(String *out, Enriched_Text *text, Document_System *doc_ if (img_lookup){ pixel_height = ceil32(pixel_width*img_lookup->h_w_ratio); - append_sc(out, "img_instantiations, pixel_width, pixel_height); } else{ NotImplemented; } - append_sc(out, "' style='width: "); + append(out, "' style='width: "); append_int_to_str(out, pixel_width); - append_sc(out, "px; height: "); + append(out, "px; height: "); append_int_to_str(out, pixel_height); - append_sc(out, "px;'>"); + append(out, "px;'>"); } } } @@ -882,20 +881,20 @@ write_enriched_text_html(String *out, Enriched_Text *text, Document_System *doc_ if (match_part_sc(body_text, "youtube:")){ String youtube_str = substr_tail(body_text, sizeof("youtube:")-1); - append_sc(out, ""); + append(out, "' src='"); + append(out, youtube_str); + append(out, "' allowfullscreen> "); } } }break; } } else{ - append_sc(out, "! Doc generator error: unrecognized command !"); + append(out, "! Doc generator error: unrecognized command !"); fprintf(stderr, "error: unrecognized command %.*s\n", command_string.size, command_string.str); } @@ -905,23 +904,23 @@ write_enriched_text_html(String *out, Enriched_Text *text, Document_System *doc_ } if (start != i){ - append_ss(out, substr(l, start, i-start)); + append(out, substr(l, start, i-start)); } - append_sc(out, "

    "); + append(out, "

    "); } - append_sc(out, "
    "); + append(out, "
    "); } internal void print_item_in_list(String *out, String name, char *id_postfix){ - append_sc(out, "
  • "); - append_ss(out, name); - append_sc(out, "
  • "); + append(out, "
  • "); + append(out, name); + append(out, "
  • "); } internal void @@ -931,18 +930,17 @@ init_used_links(Used_Links *used, i32 count){ used->max = count; } -internal i32 -try_to_use(Used_Links *used, String str){ - i32 result = 1; +internal b32 +try_to_use_link(Used_Links *used, String str){ + b32 result = true; i32 index = 0; - if (string_set_match(used->strs, used->count, str, &index)){ - result = 0; + result = false; } else{ + Assert(used->count < used->max); used->strs[used->count++] = str; } - return(result); } @@ -952,19 +950,19 @@ print_struct_html(String *out, Item_Node *member, i32 hide_children){ String type = member->type; String type_postfix = member->type_postfix; - append_ss (out, type); + append (out, type); append_s_char (out, ' '); - append_ss (out, name); - append_ss (out, type_postfix); + append (out, name); + append (out, type_postfix); if (match_ss(type, make_lit_string("struct")) || match_ss(type, make_lit_string("union"))){ if (hide_children){ - append_sc(out, " { /* non-public internals */ } ;"); + append(out, " { /* non-public internals */ } ;"); } else{ - append_sc(out, " {
    "); + append(out, " {
    "); for (Item_Node *member_iter = member->first_child; member_iter != 0; @@ -972,71 +970,71 @@ print_struct_html(String *out, Item_Node *member, i32 hide_children){ print_struct_html(out, member_iter, hide_children); } - append_sc(out, "
    };
    "); + append(out, "
    };
    "); } } else{ - append_sc(out, ";
    "); + append(out, ";
    "); } } internal void print_function_html(String *out, Used_Links *used, String cpp_name, String ret, char *function_call_head, String name, Argument_Breakdown breakdown){ - append_ss (out, ret); + append (out, ret); append_s_char (out, ' '); - append_sc (out, function_call_head); - append_ss (out, name); + append (out, function_call_head); + append (out, name); if (breakdown.count == 0){ - append_sc(out, "()"); + append(out, "()"); } else if (breakdown.count == 1){ - append_sc(out, "("); - append_ss(out, breakdown.args[0].param_string); - append_sc(out, ")"); + append(out, "("); + append(out, breakdown.args[0].param_string); + append(out, ")"); } else{ - append_sc(out, "(
    "); + append(out, "(
    "); for (i32 j = 0; j < breakdown.count; ++j){ - append_ss(out, breakdown.args[j].param_string); + append(out, breakdown.args[j].param_string); if (j < breakdown.count - 1){ append_s_char(out, ','); } - append_sc(out, "
    "); + append(out, "
    "); } - append_sc(out, "
    )"); + append(out, "
    )"); } } internal void print_macro_html(String *out, String name, Argument_Breakdown breakdown){ - append_sc (out, "#define "); - append_ss (out, name); + append (out, "#define "); + append (out, name); if (breakdown.count == 0){ - append_sc(out, "()"); + append(out, "()"); } else if (breakdown.count == 1){ append_s_char (out, '('); - append_ss (out, breakdown.args[0].param_string); + append (out, breakdown.args[0].param_string); append_s_char (out, ')'); } else{ - append_sc (out, "(
    "); + append (out, "(
    "); for (i32 j = 0; j < breakdown.count; ++j){ - append_ss(out, breakdown.args[j].param_string); + append(out, breakdown.args[j].param_string); if (j < breakdown.count - 1){ append_s_char(out, ','); } - append_sc(out, "
    "); + append(out, "
    "); } - append_sc(out, ")
    )"); + append(out, ")
    )"); } } @@ -1138,8 +1136,8 @@ print_doc_description(String *out, String src){ for (String line = get_first_double_line(chunk); line.str; line = get_next_double_line(chunk, line)){ - append_ss(out, line); - append_sc(out, "

    "); + append(out, line); + append(out, "

    "); } }break; @@ -1152,7 +1150,7 @@ print_doc_description(String *out, String src){ while (end > start && chunk.str[end] != ')') --end; - append_sc(out, HTML_EXAMPLE_CODE_OPEN); + append(out, HTML_EXAMPLE_CODE_OPEN); if (start < end){ String code_example = substr(chunk, start, end - start); @@ -1166,7 +1164,7 @@ print_doc_description(String *out, String src){ i32 space_i = 0; for (; space_i < line.size; ++space_i){ if (line.str[space_i] == ' '){ - append_sc(out, " "); + append(out, " "); } else{ break; @@ -1174,14 +1172,14 @@ print_doc_description(String *out, String src){ } String line_tail = substr_tail(line, space_i); - append_ss(out, line_tail); - append_sc(out, "
    "); + append(out, line_tail); + append(out, "
    "); } first_line = 0; } } - append_sc(out, HTML_EXAMPLE_CODE_CLOSE); + append(out, HTML_EXAMPLE_CODE_CLOSE); }break; } } @@ -1201,17 +1199,17 @@ print_struct_docs(String *out, Item_Node *member){ Documentation doc = {0}; perform_doc_parse(member_iter->doc_string, &doc); - append_sc(out, "
    "); + append(out, "
    "); - append_sc(out, "
    "HTML_DOC_ITEM_HEAD_INL_OPEN); - append_ss(out, member_iter->name); - append_sc(out, HTML_DOC_ITEM_HEAD_INL_CLOSE"
    "); + append(out, "
    "HTML_DOC_ITEM_HEAD_INL_OPEN); + append(out, member_iter->name); + append(out, HTML_DOC_ITEM_HEAD_INL_CLOSE"
    "); - append_sc(out, "
    "HTML_DOC_ITEM_OPEN); + append(out, "
    "HTML_DOC_ITEM_OPEN); print_doc_description(out, doc.main_doc); - append_sc(out, HTML_DOC_ITEM_CLOSE"
    "); + append(out, HTML_DOC_ITEM_CLOSE"
    "); - append_sc(out, "
    "); + append(out, "
    "); } } } @@ -1220,15 +1218,15 @@ internal void print_see_also(String *out, Documentation *doc){ i32 doc_see_count = doc->see_also_count; if (doc_see_count > 0){ - append_sc(out, HTML_DOC_HEAD_OPEN"See Also"HTML_DOC_HEAD_CLOSE); + append(out, HTML_DOC_HEAD_OPEN"See Also"HTML_DOC_HEAD_CLOSE); for (i32 j = 0; j < doc_see_count; ++j){ String see_also = doc->see_also[j]; - append_sc(out, HTML_DOC_ITEM_OPEN""); - append_ss(out, see_also); - append_sc(out, ""HTML_DOC_ITEM_CLOSE); + append(out, HTML_DOC_ITEM_OPEN""); + append(out, see_also); + append(out, ""HTML_DOC_ITEM_CLOSE); } } } @@ -1236,7 +1234,7 @@ print_see_also(String *out, Documentation *doc){ internal void print_function_docs(String *out, String name, String doc_string){ if (doc_string.size == 0){ - append_sc(out, "No documentation generated for this function."); + append(out, "No documentation generated for this function."); fprintf(stderr, "warning: no documentation string for %.*s\n", name.size, name.str); } @@ -1248,35 +1246,34 @@ print_function_docs(String *out, String name, String doc_string){ i32 doc_param_count = doc.param_count; if (doc_param_count > 0){ - append_sc(out, HTML_DOC_HEAD_OPEN"Parameters"HTML_DOC_HEAD_CLOSE); + append(out, HTML_DOC_HEAD_OPEN"Parameters"HTML_DOC_HEAD_CLOSE); for (i32 j = 0; j < doc_param_count; ++j){ String param_name = doc.param_name[j]; String param_docs = doc.param_docs[j]; - // TODO(allen): check that param_name is actually - // a parameter to this function! + // TODO(allen): check that param_name is actually a parameter to this function! - append_sc(out, "
    "HTML_DOC_ITEM_HEAD_OPEN); - append_ss(out, param_name); - append_sc(out, HTML_DOC_ITEM_HEAD_CLOSE"
    "HTML_DOC_ITEM_OPEN); - append_ss(out, param_docs); - append_sc(out, HTML_DOC_ITEM_CLOSE"
    "); + append(out, "
    "HTML_DOC_ITEM_HEAD_OPEN); + append(out, param_name); + append(out, HTML_DOC_ITEM_HEAD_CLOSE"
    "HTML_DOC_ITEM_OPEN); + append(out, param_docs); + append(out, HTML_DOC_ITEM_CLOSE"
    "); } } String ret_doc = doc.return_doc; if (ret_doc.size != 0){ - append_sc(out, HTML_DOC_HEAD_OPEN"Return"HTML_DOC_HEAD_CLOSE HTML_DOC_ITEM_OPEN); - append_ss(out, ret_doc); - append_sc(out, HTML_DOC_ITEM_CLOSE); + append(out, HTML_DOC_HEAD_OPEN"Return"HTML_DOC_HEAD_CLOSE HTML_DOC_ITEM_OPEN); + append(out, ret_doc); + append(out, HTML_DOC_ITEM_CLOSE); } String main_doc = doc.main_doc; if (main_doc.size != 0){ - append_sc(out, HTML_DOC_HEAD_OPEN"Description"HTML_DOC_HEAD_CLOSE HTML_DOC_ITEM_OPEN); + append(out, HTML_DOC_HEAD_OPEN"Description"HTML_DOC_HEAD_CLOSE HTML_DOC_ITEM_OPEN); print_doc_description(out, main_doc); - append_sc(out, HTML_DOC_ITEM_CLOSE); + append(out, HTML_DOC_ITEM_CLOSE); } print_see_also(out, &doc); @@ -1307,31 +1304,31 @@ print_item_html(String *out, Used_Links *used, Item_Node *item, char *id_postfix Put a heading in it with the name and section. Open a "descriptive" box for the display of the code interface. */ - append_sc(out, "
    "); + append(out, "
    "); i32 has_cpp_name = 0; if (item->cpp_name.str != 0){ - if (try_to_use(used, item->cpp_name)){ - append_sc(out, "
    "); + if (try_to_use_link(used, item->cpp_name)){ + append(out, "
    "); has_cpp_name = 1; } } - append_sc (out, "

    §"); - append_sc (out, section); + append (out, "

    §"); + append (out, section); append_s_char (out, '.'); append_int_to_str (out, I); - append_sc (out, ": "); - append_ss (out, name); - append_sc (out, "

    "); + append (out, ": "); + append (out, name); + append (out, ""); - append_sc(out, "
    "); + append(out, "
    "); switch (item->t){ case Item_Function: @@ -1340,7 +1337,7 @@ print_item_html(String *out, Used_Links *used, Item_Node *item, char *id_postfix print_function_html(out, used, item->cpp_name, item->ret, "", name, item->breakdown); // NOTE(allen): Close the code box - append_sc(out, "
    "); + append(out, "
    "); // NOTE(allen): Descriptive section print_function_docs(out, name, item->doc_string); @@ -1352,7 +1349,7 @@ print_item_html(String *out, Used_Links *used, Item_Node *item, char *id_postfix print_macro_html(out, name, item->breakdown); // NOTE(allen): Close the code box - append_sc(out, "
    "); + append(out, "
    "); // NOTE(allen): Descriptive section print_function_docs(out, name, item->doc_string); @@ -1363,14 +1360,14 @@ print_item_html(String *out, Used_Links *used, Item_Node *item, char *id_postfix String type = item->type; // NOTE(allen): Code box - append_sc (out, "typedef "); - append_ss (out, type); + append (out, "typedef "); + append (out, type); append_s_char (out, ' '); - append_ss (out, name); + append (out, name); append_s_char (out, ';'); // NOTE(allen): Close the code box - append_sc(out, "
    "); + append(out, "
    "); // NOTE(allen): Descriptive section String doc_string = item->doc_string; @@ -1379,11 +1376,11 @@ print_item_html(String *out, Used_Links *used, Item_Node *item, char *id_postfix String main_doc = doc.main_doc; if (main_doc.size != 0){ - append_sc(out, HTML_DOC_HEAD_OPEN"Description"HTML_DOC_HEAD_CLOSE); + append(out, HTML_DOC_HEAD_OPEN"Description"HTML_DOC_HEAD_CLOSE); - append_sc(out, HTML_DOC_ITEM_OPEN); + append(out, HTML_DOC_ITEM_OPEN); print_doc_description(out, main_doc); - append_sc(out, HTML_DOC_ITEM_CLOSE); + append(out, HTML_DOC_ITEM_CLOSE); } else{ fprintf(stderr, "warning: no documentation string for %.*s\n", name.size, name.str); @@ -1396,12 +1393,12 @@ print_item_html(String *out, Used_Links *used, Item_Node *item, char *id_postfix case Item_Enum: { // NOTE(allen): Code box - append_sc (out, "enum "); - append_ss (out, name); + append (out, "enum "); + append (out, name); append_s_char (out, ';'); // NOTE(allen): Close the code box - append_sc(out, ""); + append(out, ""); // NOTE(allen): Descriptive section String doc_string = item->doc_string; @@ -1410,18 +1407,18 @@ print_item_html(String *out, Used_Links *used, Item_Node *item, char *id_postfix String main_doc = doc.main_doc; if (main_doc.size != 0){ - append_sc(out, HTML_DOC_HEAD_OPEN"Description"HTML_DOC_HEAD_CLOSE); + append(out, HTML_DOC_HEAD_OPEN"Description"HTML_DOC_HEAD_CLOSE); - append_sc(out, HTML_DOC_ITEM_OPEN); + append(out, HTML_DOC_ITEM_OPEN); print_doc_description(out, main_doc); - append_sc(out, HTML_DOC_ITEM_CLOSE); + append(out, HTML_DOC_ITEM_CLOSE); } else{ fprintf(stderr, "warning: no documentation string for %.*s\n", name.size, name.str); } if (item->first_child){ - append_sc(out, HTML_DOC_HEAD_OPEN"Values"HTML_DOC_HEAD_CLOSE); + append(out, HTML_DOC_HEAD_OPEN"Values"HTML_DOC_HEAD_CLOSE); for (Item_Node *member = item->first_child; member; @@ -1429,25 +1426,25 @@ print_item_html(String *out, Used_Links *used, Item_Node *item, char *id_postfix Documentation doc = {0}; perform_doc_parse(member->doc_string, &doc); - append_sc(out, "
    "); + append(out, "
    "); // NOTE(allen): Dafuq is this all? - append_sc(out, "
    "HTML_DOC_ITEM_HEAD_INL_OPEN); - append_ss(out, member->name); - append_sc(out, HTML_DOC_ITEM_HEAD_INL_CLOSE); + append(out, "
    "HTML_DOC_ITEM_HEAD_INL_OPEN); + append(out, member->name); + append(out, HTML_DOC_ITEM_HEAD_INL_CLOSE); if (member->value.str){ - append_sc(out, " = "); - append_ss(out, member->value); + append(out, " = "); + append(out, member->value); } - append_sc(out, "
    "); + append(out, "
    "); - append_sc(out, "
    "HTML_DOC_ITEM_OPEN); + append(out, "
    "HTML_DOC_ITEM_OPEN); print_doc_description(out, doc.main_doc); - append_sc(out, HTML_DOC_ITEM_CLOSE"
    "); + append(out, HTML_DOC_ITEM_CLOSE"
    "); - append_sc(out, "
    "); + append(out, "
    "); } } @@ -1479,7 +1476,7 @@ print_item_html(String *out, Used_Links *used, Item_Node *item, char *id_postfix print_struct_html(out, item, hide_members); // NOTE(allen): Close the code box - append_sc(out, ""); + append(out, ""); // NOTE(allen): Descriptive section { @@ -1488,11 +1485,11 @@ print_item_html(String *out, Used_Links *used, Item_Node *item, char *id_postfix String main_doc = doc.main_doc; if (main_doc.size != 0){ - append_sc(out, HTML_DOC_HEAD_OPEN"Description"HTML_DOC_HEAD_CLOSE); + append(out, HTML_DOC_HEAD_OPEN"Description"HTML_DOC_HEAD_CLOSE); - append_sc(out, HTML_DOC_ITEM_OPEN); + append(out, HTML_DOC_ITEM_OPEN); print_doc_description(out, main_doc); - append_sc(out, HTML_DOC_ITEM_CLOSE); + append(out, HTML_DOC_ITEM_CLOSE); } else{ fprintf(stderr, "warning: no documentation string for %.*s\n", name.size, name.str); @@ -1500,7 +1497,7 @@ print_item_html(String *out, Used_Links *used, Item_Node *item, char *id_postfix if (!hide_members){ if (item->first_child){ - append_sc(out, HTML_DOC_HEAD_OPEN"Fields"HTML_DOC_HEAD_CLOSE); + append(out, HTML_DOC_HEAD_OPEN"Fields"HTML_DOC_HEAD_CLOSE); print_struct_docs(out, item); } } @@ -1511,210 +1508,214 @@ print_item_html(String *out, Used_Links *used, Item_Node *item, char *id_postfix } if (has_cpp_name){ - append_sc(out, ""); + append(out, ""); } // NOTE(allen): Close the item box - append_sc(out, "
    "); + append(out, "
    "); fm_end_temp(temp); } +global char* html_css = +""; + internal void -doc_item_head_html(String *out, Document_System *doc_system, Used_Links *used_links, Document_Item *item, Section_Counter *section_counter){ +doc_item_html(String *out, Document_System *doc_system, Used_Links *used_links, Document_Item *item, Section_Counter *section_counter, b32 head){ switch (item->type){ case Doc_Root: { - append_sc(out, - "" - "" - "" - ""); - - append_ss(out, item->section.name); - - append_sc(out, - "" - "" - "\n" - "" - "
    "); - - if (item->section.show_title){ - append_sc(out, "

    "); - append_ss(out, item->section.name); - append_sc(out, "

    "); + if (head){ + append(out, + "" + "" + "" + ""); + append(out, item->section.name); + append(out, ""); + + append(out, html_css); + + append(out, + "\n" + "" + "
    "); + + if (item->section.show_title){ + append(out, "

    "); + append(out, item->section.name); + append(out, "

    "); + } + } + else{ + append(out, "
    "); } }break; case Doc_Section: { - html_render_section_header(out, item->section.name, item->section.id, section_counter); + if (head){ + html_render_section_header(out, item->section.name, item->section.id, section_counter); + } }break; case Doc_Todo: { - append_sc(out, "
    Coming Soon
    "); + if (head){ + append(out, "
    Coming Soon
    "); + } }break; case Doc_Enriched_Text: { - write_enriched_text_html(out, item->text.text, doc_system, section_counter); + if (head){ + write_enriched_text_html(out, item->text.text, doc_system, section_counter); + } }break; case Doc_Element_List: { - append_sc(out, "
      "); - - Meta_Unit *unit = item->unit_elements.unit; - Alternate_Names_Array *alt_names = item->unit_elements.alt_names; - i32 count = unit->set.count; - - switch (item->unit_elements.alt_name_type){ - case AltName_Standard: - { - for (i32 i = 0; i < count; ++i){ - print_item_in_list(out, unit->set.items[i].name, "_doc"); - } - }break; + if (head){ + append(out, "
        "); - case AltName_Macro: - { - for (i32 i = 0; i < count; ++i){ - print_item_in_list(out, alt_names->names[i].macro, "_doc"); - } - }break; + Meta_Unit *unit = item->unit_elements.unit; + Alternate_Names_Array *alt_names = item->unit_elements.alt_names; + i32 count = unit->set.count; - case AltName_Public_Name: - { - for (i32 i = 0; i < count; ++i){ - print_item_in_list(out, alt_names->names[i].public_name, "_doc"); - } - }break; + switch (item->unit_elements.alt_name_type){ + case AltName_Standard: + { + for (i32 i = 0; i < count; ++i){ + print_item_in_list(out, unit->set.items[i].name, "_doc"); + } + }break; + + case AltName_Macro: + { + for (i32 i = 0; i < count; ++i){ + print_item_in_list(out, alt_names->names[i].macro, "_doc"); + } + }break; + + case AltName_Public_Name: + { + for (i32 i = 0; i < count; ++i){ + print_item_in_list(out, alt_names->names[i].public_name, "_doc"); + } + }break; + } + + append(out, "
      "); } - - append_sc(out, "
    "); }break; case Doc_Full_Elements: { - Meta_Unit *unit = item->unit_elements.unit; - Alternate_Names_Array *alt_names = item->unit_elements.alt_names; - i32 count = unit->set.count; - - char section_space[32]; - String section_str = make_fixed_width_string(section_space); - append_section_number_reduced(§ion_str, section_counter, 1); - terminate_with_null(§ion_str); - - if (alt_names){ - i32 I = 1; - for (i32 i = 0; i < count; ++i, ++I){ - print_item_html(out, used_links, &unit->set.items[i], "_doc", section_str.str, I, &alt_names->names[i], item->unit_elements.alt_name_type); + if (head){ + Meta_Unit *unit = item->unit_elements.unit; + Alternate_Names_Array *alt_names = item->unit_elements.alt_names; + i32 count = unit->set.count; + + char section_space[32]; + String section_str = make_fixed_width_string(section_space); + append_section_number_reduced(§ion_str, section_counter, 1); + terminate_with_null(§ion_str); + + if (alt_names){ + i32 I = 1; + for (i32 i = 0; i < count; ++i, ++I){ + print_item_html(out, used_links, &unit->set.items[i], "_doc", section_str.str, I, &alt_names->names[i], item->unit_elements.alt_name_type); + } } - } - else{ - i32 I = 1; - for (i32 i = 0; i < count; ++i, ++I){ - print_item_html(out, used_links, &unit->set.items[i], "_doc", section_str.str, I, 0, 0); + else{ + i32 I = 1; + for (i32 i = 0; i < count; ++i, ++I){ + print_item_html(out, used_links, &unit->set.items[i], "_doc", section_str.str, I, 0, 0); + } } } }break; case Doc_Table_Of_Contents: { - append_sc(out, "

    Table of Contents

    "); }break; } } -internal void -doc_item_foot_html(String *out, Document_System *doc_system, Used_Links *used_links, Document_Item *item, Section_Counter *section_counter){ - switch (item->type){ - case Doc_Root: - { - append_sc(out, "
    "); - }break; - - case Doc_Section: break; - - case Doc_Table_Of_Contents: break; - } -} - internal void generate_item_html(String *out, Document_System *doc_system, Used_Links *used_links, Document_Item *item, Section_Counter *section_counter){ - doc_item_head_html(out, doc_system, used_links, item, section_counter); + doc_item_html(out, doc_system, used_links, item, section_counter, true); if (item->type == Doc_Root || item->type == Doc_Section){ i32 level = ++section_counter->nest_level; @@ -1728,7 +1729,7 @@ generate_item_html(String *out, Document_System *doc_system, Used_Links *used_li ++section_counter->counter[section_counter->nest_level]; } - doc_item_foot_html(out, doc_system, used_links, item, section_counter); + doc_item_html(out, doc_system, used_links, item, section_counter, false); } internal void diff --git a/site/4ed_sitegen.cpp b/site/4ed_sitegen.cpp index 538505e0..6a451c1e 100644 --- a/site/4ed_sitegen.cpp +++ b/site/4ed_sitegen.cpp @@ -115,18 +115,6 @@ do_html_output(Document_System *doc_system, char *dst_directory, Abstract_Item * free(mem); } -static Abstract_Item* -generate_homepage(Document_System *doc_system, char *src_directory){ - Enriched_Text *home = fm_push_array(Enriched_Text, 1); - *home = load_enriched_text(src_directory, "home.txt"); - - Abstract_Item *doc = begin_document_description(doc_system, "4coder Home", "home", 0); - add_enriched_text(doc, home); - end_document_description(doc); - - return(doc); -} - // TODO(allen): replace the documentation declaration system with a straight up enriched text system static Abstract_Item* generate_4coder_docs(Document_System *doc_system, char *code_directory, char *src_directory){ @@ -251,49 +239,13 @@ generate_4coder_docs(Document_System *doc_system, char *code_directory, char *sr return(doc); } -static Abstract_Item* -generate_feature_list(Document_System *doc_system, char *src_directory){ - Enriched_Text *feature_list = fm_push_array(Enriched_Text, 1); - *feature_list = load_enriched_text(src_directory, "feature_list.txt"); +internal Abstract_Item* +generate_page(Document_System *doc_system, char *src_directory, char *source_text, char *big_title, char *small_name){ + Enriched_Text *home = fm_push_array(Enriched_Text, 1); + *home = load_enriched_text(src_directory, source_text); - Abstract_Item *doc = begin_document_description(doc_system, "4coder Feature List", "features", 0); - add_enriched_text(doc, feature_list); - end_document_description(doc); - - return(doc); -} - -static Abstract_Item* -generate_binding_list(Document_System *doc_system, char *src_directory){ - Enriched_Text *binding_list = fm_push_array(Enriched_Text, 1); - *binding_list = load_enriched_text(src_directory, "binding_list.txt"); - - Abstract_Item *doc = begin_document_description(doc_system, "4coder Binding List", "bindings", 0); - add_enriched_text(doc, binding_list); - end_document_description(doc); - - return(doc); -} - -static Abstract_Item* -generate_roadmap(Document_System *doc_system, char *src_directory){ - Enriched_Text *roadmap = fm_push_array(Enriched_Text, 1); - *roadmap = load_enriched_text(src_directory, "roadmap.txt"); - - Abstract_Item *doc = begin_document_description(doc_system, "4coder Roadmap", "roadmap", 0); - add_enriched_text(doc, roadmap); - end_document_description(doc); - - return(doc); -} - -static Abstract_Item* -generate_tutorials(Document_System *doc_system, char *src_directory){ - Enriched_Text *roadmap = fm_push_array(Enriched_Text, 1); - *roadmap = load_enriched_text(src_directory, "tutorials.txt"); - - Abstract_Item *doc = begin_document_description(doc_system, "4coder Tutorials", "tutorials", 0); - add_enriched_text(doc, roadmap); + Abstract_Item *doc = begin_document_description(doc_system, big_title, small_name, 0); + add_enriched_text(doc, home); end_document_description(doc); return(doc); @@ -310,10 +262,11 @@ push_string(i32 size){ static void do_image_resize(char *src_file, char *dst_file, char *extension, i32 w, i32 h){ + Temp temp = fm_begin_temp(); + i32 x = 0, y = 0, channels = 0; stbi_uc *image = stbi_load(src_file, &x, &y, &channels, 0); - - stbi_uc *resized_image = (stbi_uc*)malloc(w*h*channels); + stbi_uc *resized_image = fm_push_array(stbi_uc, w*h*channels); stbir_resize_uint8(image, x, y, x*channels, resized_image, w, h, w*channels, channels); if (match_cc(extension, "png")){ @@ -321,16 +274,13 @@ do_image_resize(char *src_file, char *dst_file, char *extension, i32 w, i32 h){ } free(image); - free(resized_image); + fm_end_temp(temp); } static void generate_site(char *code_directory, char *asset_directory, char *src_directory, char *dst_directory){ - String str; - Document_System doc_system = create_document_system(); - // TODO(allen): code compression here struct Site_Asset{ char *filename; char *extension; @@ -354,33 +304,30 @@ generate_site(char *code_directory, char *asset_directory, char *src_directory, for (u32 i = 0; i < ArrayCount(asset_list); ++i){ Site_Asset *asset = &asset_list[i]; - str = push_string(256); - append_sc(&str, asset_directory); - append_sc(&str, "/"); - append_sc(&str, asset->filename); - terminate_with_null(&str); + char *name = fm_str(asset_directory, "/", asset->filename); switch (asset_list[i].type){ case SiteAsset_Generic: { - add_generic_file(&doc_system, str.str, asset->extension, asset->name); + add_generic_file(&doc_system, name, asset->extension, asset->name); }break; case SiteAsset_Image: { - add_image_description(&doc_system, str.str, asset->extension, asset->name); + add_image_description(&doc_system, name, asset->extension, asset->name); }break; default: InvalidCodePath; } } - generate_homepage(&doc_system, src_directory); generate_4coder_docs(&doc_system, code_directory, src_directory); - generate_feature_list(&doc_system, src_directory); - generate_binding_list(&doc_system, src_directory); - generate_roadmap(&doc_system, src_directory); - generate_tutorials(&doc_system, src_directory); + + generate_page(&doc_system, src_directory, "home.txt" , "4coder Home" , "home" ); + generate_page(&doc_system, src_directory, "feature_list.txt", "4coder Feature List", "features" ); + generate_page(&doc_system, src_directory, "binding_list.txt", "4coder Binding List", "bindings" ); + generate_page(&doc_system, src_directory, "roadmap.txt" , "4coder Roadmap" , "roadmap" ); + generate_page(&doc_system, src_directory, "tutorials.txt" , "4coder Tutorials" , "tutorials" ); for (Basic_Node *node = doc_system.doc_list.head; node != 0; @@ -411,17 +358,10 @@ generate_site(char *code_directory, char *asset_directory, char *src_directory, node = node->next){ Image_Instantiation *inst = NodeGetData(node, Image_Instantiation); - char space[256]; - if (img_get_link_string(img, space, sizeof(space), inst->w, inst->h)){ - char space2[256]; - String str = make_fixed_width_string(space2); - - append_sc(&str, dst_directory); - append_sc(&str, "/"); - append_sc(&str, space); - terminate_with_null(&str); - - do_image_resize(img->source_file, space2, img->extension, inst->w, inst->h); + char img_link[256]; + if (img_get_link_string(img, img_link, sizeof(img_link), inst->w, inst->h)){ + char *dest_file = fm_str(dst_directory, "/", img_link); + do_image_resize(img->source_file, dest_file, img->extension, inst->w, inst->h); } } } diff --git a/string/4coder_string_build_num.txt b/string/4coder_string_build_num.txt index d8a4f975..c4fa2f97 100644 --- a/string/4coder_string_build_num.txt +++ b/string/4coder_string_build_num.txt @@ -1,5 +1,5 @@ 1 0 -97 +98 diff --git a/string/4ed_string_builder.cpp b/string/4ed_string_builder.cpp index 4b6d3254..3544e457 100644 --- a/string/4ed_string_builder.cpp +++ b/string/4ed_string_builder.cpp @@ -32,7 +32,6 @@ #include "../meta/4ed_meta_keywords.h" #include "../meta/4ed_out_context.cpp" -#include #include #include @@ -160,12 +159,6 @@ int main(){ META_BEGIN(); fm_init_system(); -#if 0 - i32 size = (512 << 20); - void *mem = malloc(size); - memset(mem, 0, size); -#endif - // NOTE(allen): Parse the internal string file. char *string_files[] = { INTERNAL_STRING, 0 }; Meta_Unit string_unit = compile_meta_unit(".", string_files, ExpandArray(meta_keywords));