finished switching over to new system, could probably use a little more cleanup still
parent
77c9be21b7
commit
6064912b03
File diff suppressed because it is too large
Load Diff
|
@ -28,21 +28,57 @@ load_enriched_text(char *directory, char *filename){
|
|||
|
||||
////////////////////////////////
|
||||
|
||||
struct Alternate_Name{
|
||||
String macro;
|
||||
String public_name;
|
||||
};
|
||||
|
||||
struct Alternate_Names_Array{
|
||||
Alternate_Name *names;
|
||||
};
|
||||
|
||||
typedef u32 Mangle_Rule;
|
||||
enum{
|
||||
AltName_Standard,
|
||||
AltName_Macro,
|
||||
AltName_Public_Name,
|
||||
MangleRule_None,
|
||||
MangleRule_MacroSig,
|
||||
MangleRule_ToLower,
|
||||
};
|
||||
|
||||
internal Mangle_Rule
|
||||
get_mangle_rule(String mangle){
|
||||
Mangle_Rule result = MangleRule_None;
|
||||
if (match(mangle, "macro sig")){
|
||||
result = MangleRule_MacroSig;
|
||||
}
|
||||
else if (match(mangle, "to lower")){
|
||||
result = MangleRule_ToLower;
|
||||
}
|
||||
return(result);
|
||||
}
|
||||
|
||||
internal String
|
||||
apply_mangle_rule(String name, u32 mangle_rule){
|
||||
String result = {0};
|
||||
switch (mangle_rule){
|
||||
case MangleRule_MacroSig:
|
||||
{
|
||||
result = str_alloc(name.size + 5);
|
||||
fm_align();
|
||||
copy(&result, name);
|
||||
to_upper(&result);
|
||||
append(&result, "_SIG");
|
||||
terminate_with_null(&result);
|
||||
}break;
|
||||
|
||||
case MangleRule_ToLower:
|
||||
{
|
||||
result = str_alloc(name.size + 1);
|
||||
fm_align();
|
||||
copy(&result, name);
|
||||
to_lower(&result);
|
||||
terminate_with_null(&result);
|
||||
}break;
|
||||
|
||||
default:
|
||||
{
|
||||
result = name;
|
||||
}break;
|
||||
}
|
||||
|
||||
return(result);
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
|
||||
enum{
|
||||
|
@ -88,8 +124,8 @@ struct Document_Item{
|
|||
|
||||
struct{
|
||||
Meta_Unit *unit;
|
||||
Alternate_Names_Array *alt_names;
|
||||
i32 alt_name_type;
|
||||
//Alternate_Names_Array *alt_names;
|
||||
u32 mangle_rule;
|
||||
} unit_elements;
|
||||
|
||||
struct{
|
||||
|
@ -156,6 +192,7 @@ enum{
|
|||
ItemType_Document,
|
||||
ItemType_Image,
|
||||
ItemType_GenericFile,
|
||||
ItemType_MetaUnit,
|
||||
//
|
||||
ItemType_COUNT,
|
||||
};
|
||||
|
@ -173,6 +210,9 @@ struct Abstract_Item{
|
|||
float w_h_ratio;
|
||||
float h_w_ratio;
|
||||
Basic_List img_instantiations;
|
||||
|
||||
// Meta parse members
|
||||
Meta_Unit *unit;
|
||||
};
|
||||
global Abstract_Item null_abstract_item = {0};
|
||||
|
||||
|
@ -210,16 +250,24 @@ struct Image_Instantiation{
|
|||
};
|
||||
|
||||
struct Document_System{
|
||||
char *code_dir;
|
||||
char *asset_dir;
|
||||
char *src_dir;
|
||||
|
||||
Basic_List doc_list;
|
||||
Basic_List img_list;
|
||||
Basic_List file_list;
|
||||
Basic_List meta_list;
|
||||
|
||||
Basic_List unresolved_includes;
|
||||
};
|
||||
|
||||
internal Document_System
|
||||
create_document_system(){
|
||||
create_document_system(char *code_dir, char *asset_dir, char *src_dir){
|
||||
Document_System system = {0};
|
||||
system.code_dir = code_dir;
|
||||
system.asset_dir = asset_dir;
|
||||
system.src_dir = src_dir;
|
||||
return(system);
|
||||
}
|
||||
|
||||
|
@ -280,13 +328,53 @@ create_abstract_item(Basic_List *list, char *name){
|
|||
return(result);
|
||||
}
|
||||
|
||||
internal char*
|
||||
get_null_terminated_version(String str){
|
||||
char *ptr = 0;
|
||||
if (terminate_with_null(&str)){
|
||||
ptr = str.str;
|
||||
}
|
||||
else{
|
||||
String b = str_alloc(str.size + 1);
|
||||
copy(&b, str);
|
||||
terminate_with_null(&b);
|
||||
ptr = b.str;
|
||||
}
|
||||
return(ptr);
|
||||
}
|
||||
|
||||
internal b32
|
||||
create_meta_unit(Document_System *doc_system, String name_str, String file_str){
|
||||
char *name = get_null_terminated_version(name_str);
|
||||
char *file = get_null_terminated_version(file_str);
|
||||
|
||||
Abstract_Item *item = create_abstract_item(&doc_system->meta_list, name);
|
||||
|
||||
b32 result = false;
|
||||
if (item != 0){
|
||||
Meta_Unit *unit = fm_push_array(Meta_Unit, 1);
|
||||
*unit = compile_meta_unit(doc_system->code_dir, file, ExpandArray(meta_keywords));
|
||||
|
||||
if (unit->count != 0){
|
||||
result = true;
|
||||
item->item_type = ItemType_MetaUnit;
|
||||
item->name = name;
|
||||
item->unit = unit;
|
||||
}
|
||||
}
|
||||
|
||||
return(result);
|
||||
}
|
||||
|
||||
internal Abstract_Item*
|
||||
add_generic_file(Document_System *system, char *source_file, char *extension, char *name){
|
||||
Abstract_Item *item = create_abstract_item(&system->file_list, name);
|
||||
if (item){
|
||||
char *full_file = fm_str(system->asset_dir, "/", source_file);
|
||||
|
||||
item->item_type = ItemType_GenericFile;
|
||||
item->extension = extension;
|
||||
item->source_file = source_file;
|
||||
item->source_file = full_file;
|
||||
item->name = name;
|
||||
}
|
||||
return(item);
|
||||
|
@ -296,15 +384,17 @@ internal Abstract_Item*
|
|||
add_image_description(Document_System *system, char *source_file, char *extension, char *name){
|
||||
Abstract_Item *item = create_abstract_item(&system->img_list, name);
|
||||
if (item != 0){
|
||||
char *full_file = fm_str(system->asset_dir, "/", source_file);
|
||||
|
||||
item->item_type = ItemType_Image;
|
||||
item->extension = extension;
|
||||
item->source_file = source_file;
|
||||
item->name = name;
|
||||
item->extension = extension;
|
||||
item->source_file = full_file;
|
||||
|
||||
i32 w = 0, h = 0, comp = 0;
|
||||
i32 stbi_r = stbi_info(source_file, &w, &h, &comp);
|
||||
i32 stbi_r = stbi_info(full_file, &w, &h, &comp);
|
||||
if (!stbi_r){
|
||||
fprintf(stdout, "Did not find file %s\n", source_file);
|
||||
fprintf(stdout, "Did not find file %s\n", full_file);
|
||||
item->w_h_ratio = 1.f;
|
||||
item->h_w_ratio = 1.f;
|
||||
}
|
||||
|
@ -440,31 +530,17 @@ add_include(Document_System *doc_system, Document_Builder *builder, String text)
|
|||
}
|
||||
|
||||
internal void
|
||||
add_element_list(Document_Builder *builder, Meta_Unit *unit){
|
||||
add_doc_list(Document_Builder *builder, Meta_Unit *unit, Mangle_Rule mangle_rule){
|
||||
Document_Item *item = doc_new_item(builder, Doc_DocList);
|
||||
item->unit_elements.unit = unit;
|
||||
item->unit_elements.mangle_rule = mangle_rule;
|
||||
}
|
||||
|
||||
internal void
|
||||
add_element_list(Document_Builder *builder, Meta_Unit *unit, Alternate_Names_Array *alt_names, i32 alt_name_type){
|
||||
Document_Item *item = doc_new_item(builder, Doc_DocList);
|
||||
item->unit_elements.unit = unit;
|
||||
item->unit_elements.alt_names = alt_names;
|
||||
item->unit_elements.alt_name_type = alt_name_type;
|
||||
}
|
||||
|
||||
internal void
|
||||
add_full_elements(Document_Builder *builder, Meta_Unit *unit){
|
||||
add_doc_full(Document_Builder *builder, Meta_Unit *unit, Mangle_Rule mangle_rule){
|
||||
Document_Item *item = doc_new_item(builder, Doc_DocFull);
|
||||
item->unit_elements.unit = unit;
|
||||
}
|
||||
|
||||
internal void
|
||||
add_full_elements(Document_Builder *builder, Meta_Unit *unit, Alternate_Names_Array *alt_names, i32 alt_name_type){
|
||||
Document_Item *item = doc_new_item(builder, Doc_DocFull);
|
||||
item->unit_elements.unit = unit;
|
||||
item->unit_elements.alt_names = alt_names;
|
||||
item->unit_elements.alt_name_type = alt_name_type;
|
||||
item->unit_elements.mangle_rule = mangle_rule;
|
||||
}
|
||||
|
||||
internal void
|
||||
|
@ -500,10 +576,7 @@ add_end_style(Document_Builder *builder){
|
|||
|
||||
internal void
|
||||
add_document_link(Document_Builder *builder, String text){
|
||||
Document_Item *item = doc_new_item(builder, Doc_BeginStyle);
|
||||
item->string.string = str_alloc(text.size);
|
||||
fm_align();
|
||||
copy(&item->string.string, text);
|
||||
doc_new_item_strings(builder, Doc_DocumentLink, text, null_string);
|
||||
}
|
||||
|
||||
internal void
|
||||
|
@ -577,6 +650,9 @@ enum Command_Types{
|
|||
Cmd_TableOfContents,
|
||||
Cmd_Todo,
|
||||
Cmd_Include,
|
||||
Cmd_MetaParse,
|
||||
Cmd_DocList,
|
||||
Cmd_DocFull,
|
||||
// never below this
|
||||
Cmd_COUNT,
|
||||
};
|
||||
|
@ -606,6 +682,9 @@ get_enriched_commands(){
|
|||
enriched_commands_global_array[Cmd_TableOfContents] = make_lit_string("TABLE_OF_CONTENTS");
|
||||
enriched_commands_global_array[Cmd_Todo] = make_lit_string("TODO");
|
||||
enriched_commands_global_array[Cmd_Include] = make_lit_string("INCLUDE");
|
||||
enriched_commands_global_array[Cmd_MetaParse] = make_lit_string("META_PARSE");
|
||||
enriched_commands_global_array[Cmd_DocList] = make_lit_string("DOC_LIST");
|
||||
enriched_commands_global_array[Cmd_DocFull] = make_lit_string("DOC_FULL");
|
||||
}
|
||||
return(enriched_commands_global_array);
|
||||
}
|
||||
|
@ -867,6 +946,59 @@ make_document_from_text(Document_System *doc_system, char *title, char *name, En
|
|||
}
|
||||
}break;
|
||||
|
||||
case Cmd_MetaParse:
|
||||
{
|
||||
String name = {0};
|
||||
String file = {0};
|
||||
if (extract_command_body(l, &i, &name)){
|
||||
if (extract_command_body(l, &i, &file)){
|
||||
if (!create_meta_unit(doc_system, name, file)){
|
||||
char space[512];
|
||||
String str = make_fixed_width_string(space);
|
||||
append(&str, "parse failed for ");
|
||||
append(&str, file);
|
||||
add_error(&builder, str);
|
||||
}
|
||||
}
|
||||
else{
|
||||
report_error_missing_body(&builder, command_string);
|
||||
}
|
||||
}
|
||||
else{
|
||||
report_error_missing_body(&builder, command_string);
|
||||
}
|
||||
}break;
|
||||
|
||||
case Cmd_DocList:
|
||||
case Cmd_DocFull:
|
||||
{
|
||||
String name = {0};
|
||||
if (extract_command_body(l, &i, &name)){
|
||||
String mangle = {0};
|
||||
extract_command_body(l, &i, &mangle);
|
||||
|
||||
Abstract_Item *item = get_item_by_name(doc_system->meta_list, name);
|
||||
if (item != 0){
|
||||
u32 mangle_rule = MangleRule_None;
|
||||
if (match_part(mangle, "mangle:")){
|
||||
String mangle_name = substr_tail(mangle, sizeof("mangle:")-1);
|
||||
mangle_name = skip_chop_whitespace(mangle_name);
|
||||
mangle_rule = get_mangle_rule(mangle_name);
|
||||
}
|
||||
|
||||
if (match_index == Cmd_DocList){
|
||||
add_doc_list(&builder, item->unit, mangle_rule);
|
||||
}
|
||||
else{
|
||||
add_doc_full(&builder, item->unit, mangle_rule);
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
report_error_missing_body(&builder, command_string);
|
||||
}
|
||||
}break;
|
||||
|
||||
default:
|
||||
{
|
||||
char space[512];
|
||||
|
@ -919,7 +1051,7 @@ get_unresolved_includes(Document_System *doc_system){
|
|||
}
|
||||
|
||||
internal void
|
||||
resolve_all_includes(Document_System *doc_system, char *src_directory){
|
||||
resolve_all_includes(Document_System *doc_system){
|
||||
for (;doc_system->unresolved_includes.count > 0;){
|
||||
Unresolved_Include_Array includes = get_unresolved_includes(doc_system);
|
||||
clear_list(&doc_system->unresolved_includes);
|
||||
|
@ -932,7 +1064,7 @@ resolve_all_includes(Document_System *doc_system, char *src_directory){
|
|||
if (inc_doc == 0){
|
||||
String source_text = item->include.name;
|
||||
Enriched_Text *text = fm_push_array(Enriched_Text, 1);
|
||||
*text = load_enriched_text(src_directory, source_text.str);
|
||||
*text = load_enriched_text(doc_system->src_dir, source_text.str);
|
||||
inc_doc = make_document_from_text(doc_system, source_text.str, source_text.str, text);
|
||||
}
|
||||
item->include.document = inc_doc;
|
||||
|
@ -1143,7 +1275,7 @@ output_begin_link(Document_System *doc_system, String *out, String l){
|
|||
l.size--;
|
||||
}
|
||||
append(out, "href='");
|
||||
if (match_part_sc(l, "document:")){
|
||||
if (match_part(l, "document:")){
|
||||
String doc_name = substr_tail(l, sizeof("document:")-1);
|
||||
Abstract_Item *doc_lookup = get_item_by_name(doc_system->doc_list, doc_name);
|
||||
if (doc_lookup){
|
||||
|
@ -1181,7 +1313,7 @@ output_image(Document_System *doc_system, String *out, String l, String l2){
|
|||
}
|
||||
}
|
||||
|
||||
if (match_part_sc(l, "image:")){
|
||||
if (match_part(l, "image:")){
|
||||
String img_name = substr_tail(l, sizeof("image:")-1);
|
||||
Abstract_Item *img_lookup = get_item_by_name(doc_system->img_list, img_name);
|
||||
|
||||
|
@ -1210,7 +1342,7 @@ output_image(Document_System *doc_system, String *out, String l, String l2){
|
|||
|
||||
internal void
|
||||
output_video(String *out, String l){
|
||||
if (match_part_sc(l, "youtube:")){
|
||||
if (match_part(l, "youtube:")){
|
||||
i32 pixel_width = HTML_WIDTH;
|
||||
i32 pixel_height = (i32)(pixel_width * 0.5625f);
|
||||
|
||||
|
@ -1288,200 +1420,6 @@ output_end_item(String *out){
|
|||
append(out, "</li>");
|
||||
}
|
||||
|
||||
internal void
|
||||
write_enriched_text_html(String *out, Enriched_Text *text, Document_System *doc_system, Section_Counter *section_counter){
|
||||
String source = text->source;
|
||||
|
||||
append(out, "<div>");
|
||||
|
||||
for (String line = get_first_double_line(source);
|
||||
line.str;
|
||||
line = get_next_double_line(source, line)){
|
||||
String l = skip_chop_whitespace(line);
|
||||
output_begin_paragraph(out);
|
||||
|
||||
i32 start = 0, i = 0;
|
||||
for (; i < l.size; ++i){
|
||||
char ch = l.str[i];
|
||||
if (ch == '\\'){
|
||||
output_plain_old_text(out, substr(l, start, i - start));
|
||||
|
||||
i32 command_start = i + 1;
|
||||
i32 command_end = command_start;
|
||||
for (; command_end < l.size; ++command_end){
|
||||
if (!char_is_alpha_numeric(l.str[command_end])){
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (command_end == command_start){
|
||||
if (command_end < l.size && l.str[command_end] == '\\'){
|
||||
++command_end;
|
||||
}
|
||||
}
|
||||
|
||||
String command_string = substr(l, command_start, command_end - command_start);
|
||||
|
||||
String *enriched_commands = get_enriched_commands();
|
||||
u32 enriched_commands_count = get_enriched_commands_count();
|
||||
|
||||
i = command_end;
|
||||
|
||||
i32 match_index = 0;
|
||||
if (!string_set_match(enriched_commands, enriched_commands_count, command_string, &match_index)){
|
||||
match_index = -1;
|
||||
}
|
||||
|
||||
switch (match_index){
|
||||
case Cmd_BackSlash: append(out, "\\"); break;
|
||||
|
||||
case Cmd_BeginStyle:
|
||||
{
|
||||
String body_text = {0};
|
||||
b32 has_body = extract_command_body(l, &i, &body_text);
|
||||
if (has_body){
|
||||
output_begin_style(out, body_text);
|
||||
}
|
||||
else{
|
||||
report_error_html_missing_body(out, command_string);
|
||||
}
|
||||
}break;
|
||||
|
||||
case Cmd_EndStyle:
|
||||
{
|
||||
output_end_style(out);
|
||||
}break;
|
||||
|
||||
// TODO(allen): upgrade this bs
|
||||
case Cmd_DocumentLink:
|
||||
{
|
||||
String body_text = {0};
|
||||
b32 has_body = extract_command_body(l, &i, &body_text);
|
||||
if (has_body){
|
||||
output_document_link(out, body_text);
|
||||
}
|
||||
else{
|
||||
report_error_html_missing_body(out, command_string);
|
||||
}
|
||||
}break;
|
||||
|
||||
case Cmd_BeginList:
|
||||
{
|
||||
output_begin_list(out);
|
||||
}break;
|
||||
|
||||
case Cmd_EndList:
|
||||
{
|
||||
output_end_list(out);
|
||||
}break;
|
||||
|
||||
case Cmd_BeginItem:
|
||||
{
|
||||
output_begin_item(out, section_counter);
|
||||
}break;
|
||||
|
||||
case Cmd_EndItem:
|
||||
{
|
||||
output_end_item(out);
|
||||
}break;
|
||||
|
||||
case Cmd_BeginLink:
|
||||
{
|
||||
String body_text = {0};
|
||||
b32 has_body = extract_command_body(l, &i, &body_text);
|
||||
if (has_body){
|
||||
output_begin_link(doc_system, out, body_text);
|
||||
}
|
||||
else{
|
||||
report_error_html_missing_body(out, command_string);
|
||||
}
|
||||
}break;
|
||||
|
||||
case Cmd_EndLink:
|
||||
{
|
||||
output_end_link(out);
|
||||
}break;
|
||||
|
||||
case Cmd_Image:
|
||||
{
|
||||
String body_text = {0};
|
||||
b32 has_body = extract_command_body(l, &i, &body_text);
|
||||
if (has_body){
|
||||
String size_parameter = {0};
|
||||
extract_command_body(l, &i, &size_parameter);
|
||||
output_image(doc_system, out, body_text, size_parameter);
|
||||
}
|
||||
else{
|
||||
report_error_html_missing_body(out, command_string);
|
||||
}
|
||||
}break;
|
||||
|
||||
case Cmd_Video:
|
||||
{
|
||||
String body_text = {0};
|
||||
b32 has_body = extract_command_body(l, &i, &body_text);
|
||||
if (has_body){
|
||||
output_video(out, body_text);
|
||||
}
|
||||
else{
|
||||
report_error_html_missing_body(out, command_string);
|
||||
}
|
||||
}break;
|
||||
|
||||
case Cmd_Section:
|
||||
{
|
||||
String body_text = {0};
|
||||
b32 has_body = extract_command_body(l, &i, &body_text);
|
||||
if (has_body){
|
||||
String extra_text = {0};
|
||||
extract_command_body(l, &i, &extra_text);
|
||||
output_begin_section(out, section_counter, body_text, extra_text);
|
||||
}
|
||||
else{
|
||||
report_error_html_missing_body(out, command_string);
|
||||
}
|
||||
}break;
|
||||
|
||||
case Cmd_EndSection:
|
||||
{
|
||||
output_end_section(out, section_counter);
|
||||
}break;
|
||||
|
||||
case Cmd_Version:
|
||||
{
|
||||
append(out, VERSION);
|
||||
}break;
|
||||
|
||||
case Cmd_TableOfContents:
|
||||
{
|
||||
String str = make_lit_string("Cmd_TableOfContents does not work in this system");
|
||||
output_error(out, str);
|
||||
}break;
|
||||
|
||||
default:
|
||||
{
|
||||
char space[512];
|
||||
String str = make_fixed_width_string(space);
|
||||
append(&str, "unrecognized command ");
|
||||
append(&str, command_string);
|
||||
output_error(out, str);
|
||||
}break;
|
||||
}
|
||||
|
||||
start = i;
|
||||
}
|
||||
}
|
||||
|
||||
if (start != i){
|
||||
output_plain_old_text(out, substr(l, start, i - start));
|
||||
}
|
||||
|
||||
output_end_paragraph(out);
|
||||
}
|
||||
|
||||
append(out, "</div>");
|
||||
}
|
||||
|
||||
internal void
|
||||
print_item_in_list(String *out, String name, char *id_postfix){
|
||||
append(out, "<li><a href='#");
|
||||
|
@ -1851,22 +1789,10 @@ print_function_docs(String *out, String name, String doc_string){
|
|||
}
|
||||
|
||||
internal void
|
||||
print_item_html(String *out, Used_Links *used, Item_Node *item, char *id_postfix, char *section, i32 I, Alternate_Name *alt_name, i32 alt_name_type){
|
||||
print_item_html(String *out, Used_Links *used, Item_Node *item, char *id_postfix, char *section, i32 I, u32 mangle_rule){
|
||||
Temp temp = fm_begin_temp();
|
||||
|
||||
String name = item->name;
|
||||
|
||||
switch (alt_name_type){
|
||||
case AltName_Macro:
|
||||
{
|
||||
name = alt_name->macro;
|
||||
}break;
|
||||
|
||||
case AltName_Public_Name:
|
||||
{
|
||||
name = alt_name->public_name;
|
||||
}break;
|
||||
}
|
||||
String name = apply_mangle_rule(item->name, mangle_rule);
|
||||
|
||||
/* NOTE(allen):
|
||||
Open a div for the whole item.
|
||||
|
@ -2221,31 +2147,13 @@ doc_item_html(Document_Output_System sys, Document_Item *item, b32 head){
|
|||
if (head){
|
||||
append(sys.out, "<ul>");
|
||||
|
||||
Mangle_Rule mangle_rule = item->unit_elements.mangle_rule;
|
||||
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(sys.out, unit->set.items[i].name, "_doc");
|
||||
}
|
||||
}break;
|
||||
|
||||
case AltName_Macro:
|
||||
{
|
||||
for (i32 i = 0; i < count; ++i){
|
||||
print_item_in_list(sys.out, alt_names->names[i].macro, "_doc");
|
||||
}
|
||||
}break;
|
||||
|
||||
case AltName_Public_Name:
|
||||
{
|
||||
for (i32 i = 0; i < count; ++i){
|
||||
print_item_in_list(sys.out, alt_names->names[i].public_name, "_doc");
|
||||
}
|
||||
}break;
|
||||
for (i32 i = 0; i < count; ++i){
|
||||
String name = apply_mangle_rule(unit->set.items[i].name, mangle_rule);
|
||||
print_item_in_list(sys.out, name, "_doc");
|
||||
}
|
||||
|
||||
append(sys.out, "</ul>");
|
||||
|
@ -2255,8 +2163,8 @@ doc_item_html(Document_Output_System sys, Document_Item *item, b32 head){
|
|||
case Doc_DocFull:
|
||||
{
|
||||
if (head){
|
||||
Mangle_Rule mangle_rule = item->unit_elements.mangle_rule;
|
||||
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];
|
||||
|
@ -2264,17 +2172,9 @@ doc_item_html(Document_Output_System sys, Document_Item *item, b32 head){
|
|||
append_section_number_reduced(§ion_str, sys.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(sys.out, sys.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(sys.out, sys.used_links, &unit->set.items[i], "_doc", section_str.str, I, 0, 0);
|
||||
}
|
||||
i32 I = 1;
|
||||
for (i32 i = 0; i < count; ++i, ++I){
|
||||
print_item_html(sys.out, sys.used_links, &unit->set.items[i], "_doc", section_str.str, I, mangle_rule);
|
||||
}
|
||||
}
|
||||
}break;
|
||||
|
|
|
@ -41,146 +41,10 @@
|
|||
// Meta Parse Rules
|
||||
//
|
||||
|
||||
internal void
|
||||
do_html_output(Document_System *doc_system, char *dst_directory, Abstract_Item *doc){
|
||||
String out = make_string_cap(fm__push(10 << 20), 0, 10 << 20);
|
||||
Assert(out.str != 0);
|
||||
|
||||
char doc_link[256];
|
||||
if (doc_get_link_string(doc, doc_link, sizeof(doc_link))){
|
||||
generate_document_html(&out, doc_system, doc);
|
||||
char *name = fm_str(dst_directory, "/", doc_link);
|
||||
fm_write_file(name, out.str, out.size);
|
||||
out.size = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO(allen): replace the documentation declaration system with a straight up enriched text system
|
||||
internal Abstract_Item*
|
||||
generate_4coder_docs(Document_System *doc_system, char *code_directory, char *src_directory){
|
||||
Meta_Unit *custom_types_unit = fm_push_array(Meta_Unit, 1);
|
||||
Meta_Unit *lexer_funcs_unit = fm_push_array(Meta_Unit, 1);
|
||||
Meta_Unit *lexer_types_unit = fm_push_array(Meta_Unit, 1);
|
||||
Meta_Unit *string_unit = fm_push_array(Meta_Unit, 1);
|
||||
Meta_Unit *custom_funcs_unit = fm_push_array(Meta_Unit, 1);
|
||||
|
||||
Enriched_Text *introduction = fm_push_array(Enriched_Text, 1);
|
||||
Enriched_Text *lexer_introduction = fm_push_array(Enriched_Text, 1);
|
||||
|
||||
// NOTE(allen): Parse the code.
|
||||
*custom_types_unit = compile_meta_unit(code_directory, "4coder_API/types.h", ExpandArray(meta_keywords));
|
||||
Assert(custom_types_unit->count != 0);
|
||||
|
||||
*lexer_funcs_unit = compile_meta_unit(code_directory, "4cpp/4cpp_lexer.h", ExpandArray(meta_keywords));
|
||||
Assert(lexer_funcs_unit->count != 0);
|
||||
|
||||
*lexer_types_unit = compile_meta_unit(code_directory, "4cpp/4cpp_lexer_types.h", ExpandArray(meta_keywords));
|
||||
Assert(lexer_types_unit->count != 0);
|
||||
|
||||
*string_unit = compile_meta_unit(code_directory, "string/internal_4coder_string.cpp", ExpandArray(meta_keywords));
|
||||
Assert(string_unit->count != 0);
|
||||
|
||||
*custom_funcs_unit = compile_meta_unit(code_directory, "4ed_api_implementation.cpp", ExpandArray(meta_keywords));
|
||||
Assert(custom_funcs_unit->count != 0);
|
||||
|
||||
// NOTE(allen): Compute and store variations of the custom function names
|
||||
Alternate_Names_Array *custom_func_names = fm_push_array(Alternate_Names_Array, 1);
|
||||
i32 name_count = custom_funcs_unit->set.count;
|
||||
custom_func_names->names = fm_push_array(Alternate_Name, name_count);
|
||||
memset(custom_func_names->names, 0, sizeof(*custom_func_names->names)*name_count);
|
||||
|
||||
for (i32 i = 0; i < custom_funcs_unit->set.count; ++i){
|
||||
String name_string = custom_funcs_unit->set.items[i].name;
|
||||
String *macro = &custom_func_names->names[i].macro;
|
||||
String *public_name = &custom_func_names->names[i].public_name;
|
||||
|
||||
*macro = str_alloc(name_string.size+4);
|
||||
to_upper_ss(macro, name_string);
|
||||
append_ss(macro, make_lit_string("_SIG"));
|
||||
|
||||
*public_name = str_alloc(name_string.size);
|
||||
to_lower_ss(public_name, name_string);
|
||||
|
||||
fm_align();
|
||||
}
|
||||
|
||||
// NOTE(allen): Load enriched text materials
|
||||
*introduction = load_enriched_text(src_directory, "introduction.txt");
|
||||
*lexer_introduction = load_enriched_text(src_directory, "lexer_introduction.txt");
|
||||
|
||||
// NOTE(allen): Put together the abstract document
|
||||
Document_Builder builder = begin_document_description(doc_system, "4coder API Docs", "custom_docs", true);
|
||||
|
||||
add_table_of_contents(&builder);
|
||||
|
||||
begin_section(&builder, "Introduction", "introduction");
|
||||
add_enriched_text(&builder, introduction);
|
||||
end_section(&builder);
|
||||
|
||||
begin_section(&builder, "4coder Systems", "4coder_systems");
|
||||
add_todo(&builder);
|
||||
end_section(&builder);
|
||||
|
||||
begin_section(&builder, "Types and Functions", "types_and_functions");
|
||||
{
|
||||
begin_section(&builder, "Function List", 0);
|
||||
add_element_list(&builder, custom_funcs_unit, custom_func_names, AltName_Public_Name);
|
||||
end_section(&builder);
|
||||
begin_section(&builder, "Type List", 0);
|
||||
add_element_list(&builder, custom_types_unit);
|
||||
end_section(&builder);
|
||||
begin_section(&builder, "Function Descriptions", 0);
|
||||
add_full_elements(&builder, custom_funcs_unit, custom_func_names, AltName_Public_Name);
|
||||
end_section(&builder);
|
||||
begin_section(&builder, "Type Descriptions", 0);
|
||||
add_full_elements(&builder, custom_types_unit);
|
||||
end_section(&builder);
|
||||
}
|
||||
end_section(&builder);
|
||||
|
||||
begin_section(&builder, "String Library", "string_library");
|
||||
{
|
||||
begin_section(&builder, "String Library Intro", 0);
|
||||
add_todo(&builder);
|
||||
end_section(&builder);
|
||||
begin_section(&builder, "String Function List", 0);
|
||||
add_element_list(&builder, string_unit);
|
||||
end_section(&builder);
|
||||
begin_section(&builder, "String Function Descriptions", 0);
|
||||
add_full_elements(&builder, string_unit);
|
||||
end_section(&builder);
|
||||
}
|
||||
end_section(&builder);
|
||||
|
||||
begin_section(&builder, "Lexer Library", "lexer_library");
|
||||
{
|
||||
begin_section(&builder, "Lexer Intro", 0);
|
||||
add_enriched_text(&builder, lexer_introduction);
|
||||
end_section(&builder);
|
||||
begin_section(&builder, "Lexer Function List", 0);
|
||||
add_element_list(&builder, lexer_funcs_unit);
|
||||
end_section(&builder);
|
||||
begin_section(&builder, "Lexer Type List", 0);
|
||||
add_element_list(&builder, lexer_types_unit);
|
||||
end_section(&builder);
|
||||
begin_section(&builder, "Lexer Function Descriptions", 0);
|
||||
add_full_elements(&builder, lexer_funcs_unit);
|
||||
end_section(&builder);
|
||||
begin_section(&builder, "Lexer Type Descriptions", 0);
|
||||
add_full_elements(&builder, lexer_types_unit);
|
||||
end_section(&builder);
|
||||
}
|
||||
end_section(&builder);
|
||||
|
||||
end_document_description(&builder);
|
||||
|
||||
return(builder.doc);
|
||||
}
|
||||
|
||||
internal Abstract_Item*
|
||||
generate_page(Document_System *doc_system, char *code_directory, char *src_directory, char *source_text, char *big_title, char *small_name){
|
||||
generate_page(Document_System *doc_system, 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);
|
||||
*home = load_enriched_text(doc_system->src_dir, source_text);
|
||||
|
||||
Abstract_Item *doc = make_document_from_text(doc_system, big_title, small_name, home);
|
||||
if (doc == 0){
|
||||
|
@ -190,15 +54,6 @@ generate_page(Document_System *doc_system, char *code_directory, char *src_direc
|
|||
return(doc);
|
||||
}
|
||||
|
||||
internal String
|
||||
push_string(i32 size){
|
||||
String str = {0};
|
||||
str.memory_size = size;
|
||||
str.str = fm_push_array(char, size);
|
||||
fm_align();
|
||||
return(str);
|
||||
}
|
||||
|
||||
internal void
|
||||
do_image_resize(char *src_file, char *dst_file, char *extension, i32 w, i32 h){
|
||||
Temp temp = fm_begin_temp();
|
||||
|
@ -223,72 +78,47 @@ internal void
|
|||
generate_site(char *code_directory, char *asset_directory, char *src_directory, char *dst_directory){
|
||||
fm_clear_folder(dst_directory);
|
||||
|
||||
Document_System doc_system = create_document_system();
|
||||
Document_System doc_system = create_document_system(code_directory, asset_directory, src_directory);
|
||||
|
||||
struct Site_Asset{
|
||||
char *filename;
|
||||
char *extension;
|
||||
char *name;
|
||||
u32 type;
|
||||
};
|
||||
enum Site_Asset_Type{
|
||||
SiteAsset_None,
|
||||
SiteAsset_Generic,
|
||||
SiteAsset_Image,
|
||||
};
|
||||
add_image_description(&doc_system, "4coder_logo_low_green.png", "png", "4coder_logo");
|
||||
add_image_description(&doc_system, "screen_1.png", "png", "screen_1");
|
||||
add_image_description(&doc_system, "screen_2.png", "png", "screen_2");
|
||||
add_image_description(&doc_system, "screen_3.png", "png", "screen_3");
|
||||
add_generic_file (&doc_system, "4coder_icon.ico", "ico", "4coder_icon");
|
||||
|
||||
Site_Asset asset_list[] = {
|
||||
{"4coder_logo_low_green.png", "png", "4coder_logo", SiteAsset_Image },
|
||||
{"screen_1.png", "png", "screen_1", SiteAsset_Image },
|
||||
{"screen_2.png", "png", "screen_2", SiteAsset_Image },
|
||||
{"screen_3.png", "png", "screen_3", SiteAsset_Image },
|
||||
{"4coder_icon.ico", "ico", "4coder_icon", SiteAsset_Generic },
|
||||
};
|
||||
|
||||
for (u32 i = 0; i < ArrayCount(asset_list); ++i){
|
||||
Site_Asset *asset = &asset_list[i];
|
||||
char *name = fm_str(asset_directory, "/", asset->filename);
|
||||
switch (asset_list[i].type){
|
||||
case SiteAsset_Generic:
|
||||
{
|
||||
add_generic_file(&doc_system, name, asset->extension, asset->name);
|
||||
}break;
|
||||
|
||||
case SiteAsset_Image:
|
||||
{
|
||||
add_image_description(&doc_system, name, asset->extension, asset->name);
|
||||
}break;
|
||||
|
||||
default: InvalidCodePath;
|
||||
}
|
||||
}
|
||||
|
||||
char *cdir = code_directory;
|
||||
char *sdir = src_directory;
|
||||
Document_System *docs = &doc_system;
|
||||
|
||||
generate_4coder_docs(docs, cdir, sdir);
|
||||
// TODO(allen): From the text file get "Big Title" and "smallname".
|
||||
generate_page(docs, "home.txt" , "4coder Home" , "home" );
|
||||
generate_page(docs, "docs.txt" , "4coder API Docs" , "custom_docs" );
|
||||
generate_page(docs, "feature_list.txt", "4coder Feature List", "features" );
|
||||
generate_page(docs, "binding_list.txt", "4coder Binding List", "bindings" );
|
||||
generate_page(docs, "roadmap.txt" , "4coder Roadmap" , "roadmap" );
|
||||
generate_page(docs, "tutorials.txt" , "4coder Tutorials" , "tutorials" );
|
||||
|
||||
// TODO(allen): From the text file get the "Big Title" and "smallname".
|
||||
generate_page(docs, cdir, sdir, "home.txt" , "4coder Home" , "home" );
|
||||
generate_page(docs, cdir, sdir, "docs.txt" , "4coder API Docs" , "custom_docs_2" );
|
||||
generate_page(docs, cdir, sdir, "feature_list.txt", "4coder Feature List", "features" );
|
||||
generate_page(docs, cdir, sdir, "binding_list.txt", "4coder Binding List", "bindings" );
|
||||
generate_page(docs, cdir, sdir, "roadmap.txt" , "4coder Roadmap" , "roadmap" );
|
||||
generate_page(docs, cdir, sdir, "tutorials.txt" , "4coder Tutorials" , "tutorials" );
|
||||
|
||||
// NOTE(allen): Create a list of the documents we want to generate.
|
||||
// NOTE(allen): Create a list of the primary documents to generate.
|
||||
Abstract_Item_Array original_documents = get_abstract_item_array(&doc_system.doc_list);
|
||||
|
||||
// NOTE(allen): Cross link all the includes and pull in any non-primary documents.
|
||||
resolve_all_includes(&doc_system, src_directory);
|
||||
resolve_all_includes(&doc_system);
|
||||
|
||||
// NOTE(allen): Generate the html from the primary documents and publish them.
|
||||
String out = make_string_cap(fm__push(10 << 20), 0, 10 << 20);
|
||||
Assert(out.str != 0);
|
||||
|
||||
// NOTE(allen): Generate the html from the documents and publish them
|
||||
Abstract_Item **doc_ptr = original_documents.items;
|
||||
for (u32 j = 0; j < original_documents.count; ++j, ++doc_ptr){
|
||||
Abstract_Item *doc = *doc_ptr;
|
||||
Assert(doc->item_type == ItemType_Document);
|
||||
do_html_output(&doc_system, dst_directory, doc);
|
||||
|
||||
char doc_link[256];
|
||||
if (doc_get_link_string(doc, doc_link, sizeof(doc_link))){
|
||||
generate_document_html(&out, &doc_system, doc);
|
||||
|
||||
char *name = fm_str(dst_directory, "/", doc_link);
|
||||
fm_write_file(name, out.str, out.size);
|
||||
out.size = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE(allen): Publish files
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
\SECTION{Types and Functions}{types_and_functions}
|
||||
|
||||
\SECTION{Function List}
|
||||
\DOC_LIST{custom_funcs}
|
||||
\DOC_LIST{custom_funcs}{mangle:to lower}
|
||||
\END_SECTION
|
||||
|
||||
\SECTION{Type List}
|
||||
|
@ -30,7 +30,7 @@
|
|||
\END_SECTION
|
||||
|
||||
\SECTION{Function Descriptions}
|
||||
\DOC_FULL{custom_funcs}
|
||||
\DOC_FULL{custom_funcs}{mangle:to lower}
|
||||
\END_SECTION
|
||||
|
||||
\SECTION{Type Descriptions}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
1
|
||||
0
|
||||
102
|
||||
103
|
||||
|
||||
|
||||
|
|
|
@ -1,28 +1,28 @@
|
|||
// 4tech_standard_preamble.h
|
||||
// 4ed_standard_preamble.h
|
||||
#if !defined(FTECH_INTEGERS)
|
||||
#define FTECH_INTEGERS
|
||||
#include <stdint.h>
|
||||
typedef int8_t i8_4tech;
|
||||
typedef int16_t i16_4tech;
|
||||
typedef int32_t i32_4tech;
|
||||
typedef int64_t i64_4tech;
|
||||
typedef int8_t i8_4ed;
|
||||
typedef int16_t i16_4ed;
|
||||
typedef int32_t i32_4ed;
|
||||
typedef int64_t i64_4ed;
|
||||
|
||||
typedef uint8_t u8_4tech;
|
||||
typedef uint16_t u16_4tech;
|
||||
typedef uint32_t u32_4tech;
|
||||
typedef uint64_t u64_4tech;
|
||||
typedef uint8_t u8_4ed;
|
||||
typedef uint16_t u16_4ed;
|
||||
typedef uint32_t u32_4ed;
|
||||
typedef uint64_t u64_4ed;
|
||||
|
||||
#if defined(FTECH_32_BIT)
|
||||
typedef u32_4tech umem_4tech;
|
||||
typedef u32_4ed umem_4ed;
|
||||
#else
|
||||
typedef u64_4tech umem_4tech;
|
||||
typedef u64_4ed umem_4ed;
|
||||
#endif
|
||||
|
||||
typedef float f32_4tech;
|
||||
typedef double f64_4tech;
|
||||
typedef float f32_4ed;
|
||||
typedef double f64_4ed;
|
||||
|
||||
typedef int8_t b8_4tech;
|
||||
typedef int32_t b32_4tech;
|
||||
typedef int8_t b8_4ed;
|
||||
typedef int32_t b32_4ed;
|
||||
#endif
|
||||
|
||||
#if !defined(Assert)
|
||||
|
|
|
@ -19,7 +19,7 @@ internal_4coder_string.cpp - Base file for generating 4coder_string.h
|
|||
FSTRING_BEGIN
|
||||
// TOP
|
||||
|
||||
#include "4tech_standard_preamble.h"
|
||||
#include "4ed_standard_preamble.h"
|
||||
|
||||
#if !defined(FSTRING_LINK)
|
||||
# define FSTRING_LINK static
|
||||
|
@ -393,14 +393,21 @@ match_part_ccl(char *a, char *b, i32_4tech *len)/*
|
|||
DOC_PARAM(len, If this call returns non-zero this parameter is used to output the length of b.)
|
||||
DOC(This call is similar to a match call, except that it is permitted for a to be longer than b.
|
||||
In other words this call returns non-zero if b is a prefix of a.) */{
|
||||
if (a == 0){
|
||||
a = "";
|
||||
}
|
||||
if (b == 0){
|
||||
b = "";
|
||||
}
|
||||
|
||||
i32_4tech i;
|
||||
for (i = 0; b[i] != 0; ++i){
|
||||
if (a[i] != b[i]){
|
||||
return 0;
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
*len = i;
|
||||
return 1;
|
||||
return(1);
|
||||
}
|
||||
|
||||
CPP_NAME(match_part)
|
||||
|
@ -409,14 +416,17 @@ match_part_scl(String a, char *b, i32_4tech *len)/*
|
|||
DOC_PARAM(len, If this call returns non-zero this parameter is used to output the length of b.)
|
||||
DOC(This call is similar to a match call, except that it is permitted for a to be longer than b.
|
||||
In other words this call returns non-zero if b is a prefix of a.) */{
|
||||
if (b == 0){
|
||||
b = "";
|
||||
}
|
||||
i32_4tech i;
|
||||
for (i = 0; b[i] != 0; ++i){
|
||||
if (a.str[i] != b[i] || i == a.size){
|
||||
return 0;
|
||||
if (i == a.size || a.str[i] != b[i]){
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
*len = i;
|
||||
return 1;
|
||||
return(1);
|
||||
}
|
||||
|
||||
CPP_NAME(match_part)
|
||||
|
@ -457,14 +467,14 @@ match_part_ss(String a, String b)/*
|
|||
DOC(This call is similar to a match call, except that it is permitted for a to be longer than b.
|
||||
In other words this call returns non-zero if b is a prefix of a.) */{
|
||||
if (a.size < b.size){
|
||||
return 0;
|
||||
return(0);
|
||||
}
|
||||
for (i32_4tech i = 0; i < b.size; ++i){
|
||||
if (a.str[i] != b.str[i]){
|
||||
return 0;
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
return(1);
|
||||
}
|
||||
|
||||
CPP_NAME(match_insensitive)
|
||||
|
|
Loading…
Reference in New Issue