diff --git a/4coder_jump_parsing.cpp b/4coder_jump_parsing.cpp
index fa5dfb1c..7f092b7b 100644
--- a/4coder_jump_parsing.cpp
+++ b/4coder_jump_parsing.cpp
@@ -113,7 +113,7 @@ parse_jump_location(String line, Name_Based_Jump_Location *location,
int32_t colon_pos2 = find_s_char(line, colon_pos1+1, ':');
int32_t colon_pos3 = find_s_char(line, colon_pos2+1, ':');
- if (colon_pos3+1 < line.size && line.str[colon_pos3+1] == ' '){
+ if (colon_pos3+1 <= line.size){
String filename = substr(line, 0, colon_pos1);
String line_number = substr(line, colon_pos1+1, colon_pos2 - colon_pos1 - 1);
String column_number = substr(line, colon_pos2+1, colon_pos3 - colon_pos2 - 1);
@@ -129,16 +129,7 @@ parse_jump_location(String line, Name_Based_Jump_Location *location,
}
}
else{
- colon_pos1 = find_s_char(line, 0, ':');
- if (line.size > colon_pos1+1){
- if (char_is_slash(line.str[colon_pos1+1])){
- colon_pos1 = find_s_char(line, colon_pos1+1, ':');
- }
- }
-
- colon_pos2 = find_s_char(line, colon_pos1+1, ':');
-
- if (colon_pos2+1 < line.size && line.str[colon_pos2+1] == ' '){
+ if (colon_pos2+1 <= line.size){
String filename = substr(line, 0, colon_pos1);
String line_number = substr(line, colon_pos1+1, colon_pos2 - colon_pos1 - 1);
diff --git a/TODO.txt b/TODO.txt
index a51e2dc4..95a9afc4 100644
--- a/TODO.txt
+++ b/TODO.txt
@@ -76,6 +76,7 @@
; [X] killing compilation panel changes active panel
; [X] make panel resizing not whacky with child panels
; [X] visual studio file saves aren't picked up by the file track system
+; [X] findstr format not quite working
;
; [] indication on failure to save
; [] history is broken, revist the entire system
@@ -85,6 +86,8 @@
; [] view fails to follow cursor when the view is shrunk
; [] view fails to follow cursor after deleting long line
;
+; [] over left-shifting the view?
+;
; BEFORE I SHIP
;
diff --git a/site/4ed_site.ctm b/site/4ed_site.ctm
index f0a30ff6..8dc172d0 100644
Binary files a/site/4ed_site.ctm and b/site/4ed_site.ctm differ
diff --git a/site/abstract_document.cpp b/site/abstract_document.cpp
index 832eed5e..5c37103d 100644
--- a/site/abstract_document.cpp
+++ b/site/abstract_document.cpp
@@ -47,6 +47,21 @@ enum{
Doc_Table_Of_Contents
};
+typedef struct Alternate_Name{
+ String macro;
+ String public_name;
+} Alternate_Name;
+
+typedef struct Alternate_Names_Array{
+ Alternate_Name *names;
+} Alternate_Names_Array;
+
+enum{
+ AltName_Standard,
+ AltName_Macro,
+ AltName_Public_Name,
+};
+
struct Document_Item{
Document_Item *next;
Document_Item *parent;
@@ -61,6 +76,8 @@ struct Document_Item{
struct{
Meta_Unit *unit;
+ Alternate_Names_Array *alt_names;
+ int32_t alt_name_type;
} unit_elements;
struct{
@@ -174,6 +191,19 @@ add_element_list(Abstract_Document *doc, Meta_Unit *unit){
append_child(parent, item);
}
+static void
+add_element_list(Abstract_Document *doc, Meta_Unit *unit, Alternate_Names_Array *alt_names, int32_t alt_name_type){
+ Document_Item *parent = doc->section_stack[doc->section_top];
+ Document_Item *item = push_struct(doc->part, Document_Item);
+ *item = null_document_item;
+ item->type = Doc_Element_List;
+ item->unit_elements.unit = unit;
+ item->unit_elements.alt_names = alt_names;
+ item->unit_elements.alt_name_type = alt_name_type;
+
+ append_child(parent, item);
+}
+
static void
add_full_elements(Abstract_Document *doc, Meta_Unit *unit){
Document_Item *parent = doc->section_stack[doc->section_top];
@@ -185,6 +215,19 @@ add_full_elements(Abstract_Document *doc, Meta_Unit *unit){
append_child(parent, item);
}
+static void
+add_full_elements(Abstract_Document *doc, Meta_Unit *unit, Alternate_Names_Array *alt_names, int32_t alt_name_type){
+ Document_Item *parent = doc->section_stack[doc->section_top];
+ Document_Item *item = push_struct(doc->part, Document_Item);
+ *item = null_document_item;
+ item->type = Doc_Full_Elements;
+ item->unit_elements.unit = unit;
+ item->unit_elements.alt_names = alt_names;
+ item->unit_elements.alt_name_type = alt_name_type;
+
+ append_child(parent, item);
+}
+
static void
add_table_of_contents(Abstract_Document *doc){
Document_Item *parent = doc->section_stack[doc->section_top];
@@ -253,15 +296,69 @@ struct Section_Counter{
};
static void
-append_section_number(String *out, Section_Counter section_counter){
- for (int32_t i = 1; i <= section_counter.nest_level; ++i){
+append_section_number_reduced(String *out, Section_Counter section_counter, int32_t reduce){
+ int32_t level = section_counter.nest_level-reduce;
+ for (int32_t i = 1; i <= level; ++i){
append_int_to_str(out, section_counter.counter[i]);
- if (i != section_counter.nest_level){
+ if (i != level){
append_sc(out, ".");
}
}
}
+static void
+append_section_number(String *out, Section_Counter section_counter){
+ append_section_number_reduced(out, section_counter, 0);
+}
+
+static int32_t
+extract_command_body(String *out, String l, int32_t *i_in_out, int32_t *body_start_out, int32_t *body_end_out, String command_name){
+ int32_t result = 0;
+
+ int32_t i = *i_in_out;
+
+ for (; i < l.size; ++i){
+ if (!char_is_whitespace(l.str[i])){
+ break;
+ }
+ }
+
+ int32_t found_command_body = 0;
+ int32_t body_start = 0, body_end = 0;
+ if (l.str[i] == '{'){
+ body_start = i+1;
+
+ for (++i; i < l.size; ++i){
+ if (l.str[i] == '}'){
+ found_command_body = 1;
+ body_end = i;
+ ++i;
+ break;
+ }
+ }
+ }
+
+ if (found_command_body){
+ result = 1;
+ }
+ else{
+#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);
+#undef STR
+
+ fprintf(stderr, "error: missing body for %.*s\n", command_name.size, command_name.str);
+ }
+
+ *i_in_out = i;
+ *body_start_out = body_start;
+ *body_end_out = body_end;
+
+ return(result);
+}
+
static void
write_enriched_text_html(String *out, Enriched_Text *text){
String source = text->source;
@@ -300,22 +397,48 @@ write_enriched_text_html(String *out, Enriched_Text *text){
make_lit_string("\\"),
make_lit_string("VERSION"),
make_lit_string("CODE_STYLE"),
+ make_lit_string("DOC_LINK"),
};
+ i = command_end;
+
int32_t match_index = 0;
if (string_set_match(enriched_commands, ArrayCount(enriched_commands), command_string, &match_index)){
switch (match_index){
case 0: append_sc(out, "\\"); break;
case 1: append_sc(out, VERSION); break;
- case 2: append_sc(out, " TEST "); break;
+ case 2:
+ {
+ int32_t body_start = 0, body_end = 0;
+ int32_t has_body = extract_command_body(out, l, &i, &body_start, &body_end, command_string);
+ if (has_body){
+ String body_text = substr(l, body_start, body_end - body_start);
+ append_sc(out, "");
+ append_ss(out, body_text);
+ append_sc(out, "");
+ }
+ }break;
+
+ case 3:
+ {
+ int32_t body_start = 0, body_end = 0;
+ int32_t has_body = extract_command_body(out, l, &i, &body_start, &body_end, command_string);
+ if (has_body){
+ String body_text = substr(l, body_start, body_end - body_start);
+ append_sc(out, "");
+ append_ss(out, body_text);
+ append_sc(out, "");
+ }
+ }break;
}
}
else{
- append_sc(out,"! Doc generator error: unrecognized command !");
- fprintf(stderr, "error: Unrecognized command %.*s\n", command_string.size, command_string.str);
+ append_sc(out, "! Doc generator error: unrecognized command !");
+ fprintf(stderr, "error: unrecognized command %.*s\n", command_string.size, command_string.str);
}
- i = command_end;
start = i;
}
}
@@ -329,9 +452,615 @@ write_enriched_text_html(String *out, Enriched_Text *text){
append_sc(out, "");
}
-
+
+ static void
+ print_item_in_list(String *out, String name, char *id_postfix){
+ append_sc(out, "
");
+ append_ss(out, name);
+ append_sc(out, "");
+ }
+
+ static void
+ init_used_links(Partition *part, Used_Links *used, int32_t count){
+ used->strs = push_array(part, String, count);
+ used->count = 0;
+ used->max = count;
+ }
+
+ static int32_t
+ try_to_use(Used_Links *used, String str){
+ int32_t result = 1;
+ int32_t index = 0;
+
+ if (string_set_match(used->strs, used->count, str, &index)){
+ result = 0;
+ }
+ else{
+ used->strs[used->count++] = str;
+ }
+
+ return(result);
+ }
+
+ static void
+ print_struct_html(String *out, Item_Node *member, int32_t hide_children){
+ String name = member->name;
+ String type = member->type;
+ 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")) ||
+ match_ss(type, make_lit_string("union"))){
+
+ if (hide_children){
+ append_sc(out, " { /* non-public internals */ } ;");
+ }
+ else{
+ append_sc(out, " {
");
+
+ for (Item_Node *member_iter = member->first_child;
+ member_iter != 0;
+ member_iter = member_iter->next_sibling){
+ print_struct_html(out, member_iter, hide_children);
+ }
+
+ append_sc(out, "
};
");
+ }
+ }
+ else{
+ append_sc(out, ";
");
+ }
+ }
+
+ static 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_s_char (out, ' ');
+ append_sc (out, function_call_head);
+ append_ss (out, name);
+
+ if (breakdown.count == 0){
+ append_sc(out, "()");
+ }
+ else if (breakdown.count == 1){
+ append_sc(out, "(");
+ append_ss(out, breakdown.args[0].param_string);
+ append_sc(out, ")");
+ }
+ else{
+ append_sc(out, "(");
+
+ for (int32_t j = 0; j < breakdown.count; ++j){
+ append_ss(out, breakdown.args[j].param_string);
+ if (j < breakdown.count - 1){
+ append_s_char(out, ',');
+ }
+ append_sc(out, "
");
+ }
+
+ append_sc(out, "
)");
+ }
+ }
+
+ static void
+ print_macro_html(String *out, String name, Argument_Breakdown breakdown){
+
+ append_sc (out, "#define ");
+ append_ss (out, name);
+
+ if (breakdown.count == 0){
+ append_sc(out, "()");
+ }
+ else if (breakdown.count == 1){
+ append_s_char (out, '(');
+ append_ss (out, breakdown.args[0].param_string);
+ append_s_char (out, ')');
+ }
+ else{
+ append_sc (out, "(");
+
+ for (int32_t j = 0; j < breakdown.count; ++j){
+ append_ss(out, breakdown.args[j].param_string);
+ if (j < breakdown.count - 1){
+ append_s_char(out, ',');
+ }
+ append_sc(out, "
");
+ }
+
+ append_sc(out, ")
)");
+ }
+ }
+
+ enum Doc_Chunk_Type{
+ DocChunk_PlainText,
+ DocChunk_CodeExample,
+
+ DocChunk_Count
+ };
+
+ static String doc_chunk_headers[] = {
+ make_lit_string(""),
+ make_lit_string("CODE_EXAMPLE"),
+ };
+
+ static String
+ get_next_doc_chunk(String source, String prev_chunk, Doc_Chunk_Type *type){
+ String chunk = {0};
+ String word = {0};
+ int32_t pos = source.size;
+ int32_t word_index = 0;
+ Doc_Chunk_Type t = DocChunk_PlainText;
+
+ int32_t start_pos = (int32_t)(prev_chunk.str - source.str) + prev_chunk.size;
+ String source_tail = substr_tail(source, start_pos);
+
+ Assert(DocChunk_Count == ArrayCount(doc_chunk_headers));
+
+ for (word = get_first_word(source_tail);
+ word.str;
+ word = get_next_word(source_tail, word), ++word_index){
+
+ for (int32_t i = 1; i < DocChunk_Count; ++i){
+ if (match_ss(word, doc_chunk_headers[i])){
+ pos = (int32_t)(word.str - source.str);
+ t = (Doc_Chunk_Type)i;
+ goto doublebreak;
+ }
+ }
+ }
+ doublebreak:;
+
+ *type = DocChunk_PlainText;
+ if (word_index == 0){
+ *type = t;
+
+ int32_t nest_level = 1;
+ int32_t i = find_s_char(source, pos, '(');
+ for (++i; i < source.size; ++i){
+ if (source.str[i] == '('){
+ ++nest_level;
+ }
+ else if (source.str[i] == ')'){
+ --nest_level;
+ if (nest_level == 0){
+ break;
+ }
+ }
+ }
+
+ pos = i+1;
+ }
+
+ chunk = substr(source, start_pos, pos - start_pos);
+
+ int32_t is_all_white = 1;
+ for (int32_t i = 0; i < chunk.size; ++i){
+ if (!char_is_whitespace(chunk.str[i])){
+ is_all_white = 0;
+ break;
+ }
+ }
+
+ if (is_all_white){
+ chunk = null_string;
+ }
+
+ return(chunk);
+ }
+
+ static String
+ get_first_doc_chunk(String source, Doc_Chunk_Type *type){
+ String start_str = make_string(source.str, 0);
+ String chunk = get_next_doc_chunk(source, start_str, type);
+ return(chunk);
+ }
+
+ static void
+ print_doc_description(String *out, Partition *part, String src){
+ Doc_Chunk_Type type;
+
+ for (String chunk = get_first_doc_chunk(src, &type);
+ chunk.str;
+ chunk = get_next_doc_chunk(src, chunk, &type)){
+
+ switch (type){
+ case DocChunk_PlainText:
+ {
+ for (String line = get_first_double_line(chunk);
+ line.str;
+ line = get_next_double_line(chunk, line)){
+ append_ss(out, line);
+ append_sc(out, "
");
+ }
+ }break;
+
+ case DocChunk_CodeExample:
+ {
+ int32_t start = 0;
+ int32_t end = chunk.size-1;
+ while (start < end && chunk.str[start] != '(') ++start;
+ start += 1;
+ while (end > start && chunk.str[end] != ')') --end;
+
+
+ append_sc(out, HTML_EXAMPLE_CODE_OPEN);
+
+ if (start < end){
+ String code_example = substr(chunk, start, end - start);
+ int32_t first_line = 1;
+
+ for (String line = get_first_line(code_example);
+ line.str;
+ line = get_next_line(code_example, line)){
+
+ if (!(first_line && line.size == 0)){
+ int32_t space_i = 0;
+ for (; space_i < line.size; ++space_i){
+ if (line.str[space_i] == ' '){
+ append_sc(out, " ");
+ }
+ else{
+ break;
+ }
+ }
+
+ String line_tail = substr_tail(line, space_i);
+ append_ss(out, line_tail);
+ append_sc(out, "
");
+ }
+ first_line = 0;
+ }
+ }
+
+ append_sc(out, HTML_EXAMPLE_CODE_CLOSE);
+ }break;
+ }
+ }
+ }
+
+ static void
+ print_struct_docs(String *out, Partition *part, Item_Node *member){
+ for (Item_Node *member_iter = member->first_child;
+ member_iter != 0;
+ member_iter = member_iter->next_sibling){
+ String type = member_iter->type;
+ if (match_ss(type, make_lit_string("struct")) ||
+ match_ss(type, make_lit_string("union"))){
+ print_struct_docs(out, part, member_iter);
+ }
+ else{
+ Documentation doc = {0};
+ perform_doc_parse(part, member_iter->doc_string, &doc);
+
+ append_sc(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_sc(out, "
"HTML_DOC_ITEM_OPEN);
+ print_doc_description(out, part, doc.main_doc);
+ append_sc(out, HTML_DOC_ITEM_CLOSE"
");
+
+ append_sc(out, "
");
+ }
+ }
+ }
+
+ 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, HTML_DOC_HEAD_OPEN"See Also"HTML_DOC_HEAD_CLOSE);
+
+ for (int32_t 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);
+ }
+ }
+ }
+
+ static void
+ print_function_docs(String *out, Partition *part, String name, String doc_string){
+ if (doc_string.size == 0){
+ append_sc(out, "No documentation generated for this function.");
+ fprintf(stderr, "warning: no documentation string for %.*s\n", name.size, name.str);
+ }
+
+ Temp_Memory temp = begin_temp_memory(part);
+
+ Documentation doc = {0};
+
+ perform_doc_parse(part, doc_string, &doc);
+
+ int32_t doc_param_count = doc.param_count;
+ if (doc_param_count > 0){
+ append_sc(out, HTML_DOC_HEAD_OPEN"Parameters"HTML_DOC_HEAD_CLOSE);
+
+ for (int32_t 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!
+
+ 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"
");
+ }
+ }
+
+ 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);
+ }
+
+ 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);
+ print_doc_description(out, part, main_doc);
+ append_sc(out, HTML_DOC_ITEM_CLOSE);
+ }
+
+ print_see_also(out, &doc);
+
+ end_temp_memory(temp);
+ }
+
+ static void
+ print_item_html(String *out, Partition *part, Used_Links *used, Item_Node *item, char *id_postfix, char *section, int32_t I, Alternate_Name *alt_name, int32_t alt_name_type){
+ Temp_Memory temp = begin_temp_memory(part);
+
+ 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;
+ }
+
+ /* NOTE(allen):
+ Open a div for the whole item.
+ Put a heading in it with the name and section.
+ Open a "descriptive" box for the display of the code interface.
+ */
+ append_sc(out, "");
+
+ int32_t has_cpp_name = 0;
+ if (item->cpp_name.str != 0){
+ if (try_to_use(used, item->cpp_name)){
+ append_sc(out, "
");
+ has_cpp_name = 1;
+ }
+ }
+
+ append_sc (out, "
§");
+ append_sc (out, section);
+ append_s_char (out, '.');
+ append_int_to_str (out, I);
+ append_sc (out, ": ");
+ append_ss (out, name);
+ append_sc (out, "
");
+
+ append_sc(out, "
");
+
+ switch (item->t){
+ case Item_Function:
+ {
+ // NOTE(allen): Code box
+ print_function_html(out, used, item->cpp_name, item->ret, "", name, item->breakdown);
+
+ // NOTE(allen): Close the code box
+ append_sc(out, "
");
+
+ // NOTE(allen): Descriptive section
+ print_function_docs(out, part, name, item->doc_string);
+ }break;
+
+ case Item_Macro:
+ {
+ // NOTE(allen): Code box
+ print_macro_html(out, name, item->breakdown);
+
+ // NOTE(allen): Close the code box
+ append_sc(out, "
");
+
+ // NOTE(allen): Descriptive section
+ print_function_docs(out, part, name, item->doc_string);
+ }break;
+
+ case Item_Typedef:
+ {
+ String type = item->type;
+
+ // NOTE(allen): Code box
+ append_sc (out, "typedef ");
+ append_ss (out, type);
+ append_s_char (out, ' ');
+ append_ss (out, name);
+ append_s_char (out, ';');
+
+ // NOTE(allen): Close the code box
+ append_sc(out, "
");
+
+ // NOTE(allen): Descriptive section
+ String doc_string = item->doc_string;
+ Documentation doc = {0};
+ perform_doc_parse(part, doc_string, &doc);
+
+ String main_doc = doc.main_doc;
+ if (main_doc.size != 0){
+ append_sc(out, HTML_DOC_HEAD_OPEN"Description"HTML_DOC_HEAD_CLOSE);
+
+ append_sc(out, HTML_DOC_ITEM_OPEN);
+ print_doc_description(out, part, main_doc);
+ append_sc(out, HTML_DOC_ITEM_CLOSE);
+ }
+ else{
+ fprintf(stderr, "warning: no documentation string for %.*s\n", name.size, name.str);
+ }
+
+ print_see_also(out, &doc);
+
+ }break;
+
+ case Item_Enum:
+ {
+ // NOTE(allen): Code box
+ append_sc (out, "enum ");
+ append_ss (out, name);
+ append_s_char (out, ';');
+
+ // NOTE(allen): Close the code box
+ append_sc(out, "");
+
+ // NOTE(allen): Descriptive section
+ String doc_string = item->doc_string;
+ Documentation doc = {0};
+ perform_doc_parse(part, doc_string, &doc);
+
+ String main_doc = doc.main_doc;
+ if (main_doc.size != 0){
+ append_sc(out, HTML_DOC_HEAD_OPEN"Description"HTML_DOC_HEAD_CLOSE);
+
+ append_sc(out, HTML_DOC_ITEM_OPEN);
+ print_doc_description(out, part, main_doc);
+ append_sc(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);
+
+ for (Item_Node *member = item->first_child;
+ member;
+ member = member->next_sibling){
+ Documentation doc = {0};
+ perform_doc_parse(part, member->doc_string, &doc);
+
+ append_sc(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);
+
+ if (member->value.str){
+ append_sc(out, " = ");
+ append_ss(out, member->value);
+ }
+
+ append_sc(out, "
");
+
+ append_sc(out, "
"HTML_DOC_ITEM_OPEN);
+ print_doc_description(out, part, doc.main_doc);
+ append_sc(out, HTML_DOC_ITEM_CLOSE"
");
+
+ append_sc(out, "
");
+ }
+ }
+
+ print_see_also(out, &doc);
+
+ }break;
+
+ case Item_Struct: case Item_Union:
+ {
+ String doc_string = item->doc_string;
+
+ int32_t hide_members = 0;
+
+ if (doc_string.size == 0){
+ hide_members = 1;
+ }
+ else{
+ for (String word = get_first_word(doc_string);
+ word.str;
+ word = get_next_word(doc_string, word)){
+ if (match_ss(word, make_lit_string("HIDE_MEMBERS"))){
+ hide_members = 1;
+ break;
+ }
+ }
+ }
+
+ // NOTE(allen): Code box
+ print_struct_html(out, item, hide_members);
+
+ // NOTE(allen): Close the code box
+ append_sc(out, "");
+
+ // NOTE(allen): Descriptive section
+ {
+ Documentation doc = {0};
+ perform_doc_parse(part, doc_string, &doc);
+
+ String main_doc = doc.main_doc;
+ if (main_doc.size != 0){
+ append_sc(out, HTML_DOC_HEAD_OPEN"Description"HTML_DOC_HEAD_CLOSE);
+
+ append_sc(out, HTML_DOC_ITEM_OPEN);
+ print_doc_description(out, part, main_doc);
+ append_sc(out, HTML_DOC_ITEM_CLOSE);
+ }
+ else{
+ fprintf(stderr, "warning: no documentation string for %.*s\n", name.size, name.str);
+ }
+
+ if (!hide_members){
+ if (item->first_child){
+ append_sc(out, HTML_DOC_HEAD_OPEN"Fields"HTML_DOC_HEAD_CLOSE);
+ print_struct_docs(out, part, item);
+ }
+ }
+
+ print_see_also(out, &doc);
+ }
+ }break;
+ }
+
+ if (has_cpp_name){
+ append_sc(out, "");
+ }
+
+ // NOTE(allen): Close the item box
+ append_sc(out, "
");
+
+ end_temp_memory(temp);
+ }
+
static void
-doc_item_head_html(String *out, Document_Item *item, Section_Counter section_counter){
+ doc_item_head_html(String *out, Partition *part, Used_Links *used_links, Document_Item *item, Section_Counter section_counter){
switch (item->type){
case Doc_Root:
{
@@ -432,11 +1161,75 @@ doc_item_head_html(String *out, Document_Item *item, Section_Counter section_cou
}
}break;
+ case Doc_Todo:
+ {
+ append_sc(out, "Coming Soon");
+ }break;
+
case Doc_Enriched_Text:
{
write_enriched_text_html(out, item->text.text);
}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;
+ int32_t count = unit->set.count;
+
+ switch (item->unit_elements.alt_name_type){
+ case AltName_Standard:
+ {
+ for (int32_t i = 0; i < count; ++i){
+ print_item_in_list(out, unit->set.items[i].name, "_doc");
+ }
+ }break;
+
+ case AltName_Macro:
+ {
+ for (int32_t i = 0; i < count; ++i){
+ print_item_in_list(out, alt_names->names[i].macro, "_doc");
+ }
+ }break;
+
+ case AltName_Public_Name:
+ {
+ for (int32_t i = 0; i < count; ++i){
+ print_item_in_list(out, alt_names->names[i].public_name, "_doc");
+ }
+ }break;
+ }
+
+ 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;
+ int32_t 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){
+ int32_t I = 1;
+ for (int32_t i = 0; i < count; ++i, ++I){
+ print_item_html(out, part, used_links, &unit->set.items[i], "_doc", section_str.str, I, &alt_names->names[i], item->unit_elements.alt_name_type);
+ }
+ }
+ else{
+ int32_t I = 1;
+ for (int32_t i = 0; i < count; ++i, ++I){
+ print_item_html(out, part, 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
");
@@ -468,7 +1261,7 @@ doc_item_head_html(String *out, Document_Item *item, Section_Counter section_cou
}
static void
-doc_item_foot_html(String *out, Document_Item *item, Section_Counter section_counter){
+doc_item_foot_html(String *out, Partition *part, Used_Links *used_links, Document_Item *item, Section_Counter section_counter){
switch (item->type){
case Doc_Root:
{
@@ -482,9 +1275,9 @@ doc_item_foot_html(String *out, Document_Item *item, Section_Counter section_cou
}
static void
-generate_item_html(String *out, Document_Item *item, Section_Counter *section_counter){
+generate_item_html(String *out, Partition *part, Used_Links *used_links, Document_Item *item, Section_Counter *section_counter){
Section_Counter sc = *section_counter;
- doc_item_head_html(out, item, sc);
+ doc_item_head_html(out, part, used_links, item, sc);
if (item->type == Doc_Root || item->type == Doc_Section){
int32_t level = ++section_counter->nest_level;
@@ -492,20 +1285,23 @@ generate_item_html(String *out, Document_Item *item, Section_Counter *section_co
for (Document_Item *m = item->section.first_child;
m != 0;
m = m->next){
- generate_item_html(out, m, section_counter);
+ generate_item_html(out, part, used_links, m, section_counter);
}
--section_counter->nest_level;
++section_counter->counter[section_counter->nest_level];
}
- doc_item_foot_html(out, item, sc);
+ doc_item_foot_html(out, part, used_links, item, sc);
}
static void
-generate_document_html(String *out, Abstract_Document *doc){
+generate_document_html(String *out, Partition *part, Abstract_Document *doc){
+ Used_Links used_links = {0};
+ init_used_links(part, &used_links, 4000);
+
Section_Counter section_counter = {0};
section_counter.counter[section_counter.nest_level] = 1;
- generate_item_html(out, doc->root_item, §ion_counter);
+ generate_item_html(out, part, &used_links, doc->root_item, §ion_counter);
}
#endif
diff --git a/site/sitegen.cpp b/site/sitegen.cpp
index 935963a1..5ba7744b 100644
--- a/site/sitegen.cpp
+++ b/site/sitegen.cpp
@@ -33,122 +33,6 @@
// Meta Parse Rules
//
-static void
-init_used_links(Partition *part, Used_Links *used, int32_t count){
- used->strs = push_array(part, String, count);
- used->count = 0;
- used->max = count;
-}
-
-static int32_t
-try_to_use(Used_Links *used, String str){
- int32_t result = 1;
- int32_t index = 0;
-
- if (string_set_match(used->strs, used->count, str, &index)){
- result = 0;
- }
- else{
- used->strs[used->count++] = str;
- }
-
- return(result);
-}
-
-static void
-print_struct_html(String *out, Item_Node *member, int32_t hide_children){
- String name = member->name;
- String type = member->type;
- 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")) ||
- match_ss(type, make_lit_string("union"))){
-
- if (hide_children){
- append_sc(out, " { /* non-public internals */ } ;");
- }
- else{
- append_sc(out, " {
");
-
- for (Item_Node *member_iter = member->first_child;
- member_iter != 0;
- member_iter = member_iter->next_sibling){
- print_struct_html(out, member_iter, hide_children);
- }
-
- append_sc(out, "
};
");
- }
- }
- else{
- append_sc(out, ";
");
- }
-}
-
-static 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_s_char (out, ' ');
- append_sc (out, function_call_head);
- append_ss (out, name);
-
- if (breakdown.count == 0){
- append_sc(out, "()");
-}
-else if (breakdown.count == 1){
- append_sc(out, "(");
- append_ss(out, breakdown.args[0].param_string);
- append_sc(out, ")");
-}
-else{
- append_sc(out, "(");
-
- for (int32_t j = 0; j < breakdown.count; ++j){
- append_ss(out, breakdown.args[j].param_string);
- if (j < breakdown.count - 1){
- append_s_char(out, ',');
- }
- append_sc(out, "
");
- }
-
- append_sc(out, "
)");
-}
-}
-
-static void
-print_macro_html(String *out, String name, Argument_Breakdown breakdown){
-
- append_sc (out, "#define ");
- append_ss (out, name);
-
- if (breakdown.count == 0){
- append_sc(out, "()");
- }
- else if (breakdown.count == 1){
- append_s_char (out, '(');
- append_ss (out, breakdown.args[0].param_string);
- append_s_char (out, ')');
- }
- else{
- append_sc (out, "(");
-
- for (int32_t j = 0; j < breakdown.count; ++j){
- append_ss(out, breakdown.args[j].param_string);
- if (j < breakdown.count - 1){
- append_s_char(out, ',');
- }
- append_sc(out, "
");
- }
-
- append_sc(out, ")
)");
- }
-}
-
#define BACK_COLOR "#FAFAFA"
#define TEXT_COLOR "#0D0D0D"
#define CODE_BACK "#DFDFDF"
@@ -186,199 +70,6 @@ print_macro_html(String *out, String name, Argument_Breakdown breakdown){
#define EXAMPLE_CODE_OPEN ""
#define EXAMPLE_CODE_CLOSE "
"
-enum Doc_Chunk_Type{
- DocChunk_PlainText,
- DocChunk_CodeExample,
-
- DocChunk_Count
-};
-
-static String doc_chunk_headers[] = {
- make_lit_string(""),
- make_lit_string("CODE_EXAMPLE"),
-};
-
-static String
-get_next_doc_chunk(String source, String prev_chunk, Doc_Chunk_Type *type){
- String chunk = {0};
- String word = {0};
- int32_t pos = source.size;
- int32_t word_index = 0;
- Doc_Chunk_Type t = DocChunk_PlainText;
-
- int32_t start_pos = (int32_t)(prev_chunk.str - source.str) + prev_chunk.size;
- String source_tail = substr_tail(source, start_pos);
-
- Assert(DocChunk_Count == ArrayCount(doc_chunk_headers));
-
- for (word = get_first_word(source_tail);
- word.str;
- word = get_next_word(source_tail, word), ++word_index){
-
- for (int32_t i = 1; i < DocChunk_Count; ++i){
- if (match_ss(word, doc_chunk_headers[i])){
- pos = (int32_t)(word.str - source.str);
- t = (Doc_Chunk_Type)i;
- goto doublebreak;
- }
- }
- }
- doublebreak:;
-
- *type = DocChunk_PlainText;
- if (word_index == 0){
- *type = t;
-
- int32_t nest_level = 1;
- int32_t i = find_s_char(source, pos, '(');
- for (++i; i < source.size; ++i){
- if (source.str[i] == '('){
- ++nest_level;
- }
- else if (source.str[i] == ')'){
- --nest_level;
- if (nest_level == 0){
- break;
- }
- }
- }
-
- pos = i+1;
- }
-
- chunk = substr(source, start_pos, pos - start_pos);
-
- int32_t is_all_white = 1;
- for (int32_t i = 0; i < chunk.size; ++i){
- if (!char_is_whitespace(chunk.str[i])){
- is_all_white = 0;
- break;
- }
- }
-
- if (is_all_white){
- chunk = null_string;
- }
-
- return(chunk);
-}
-
-static String
-get_first_doc_chunk(String source, Doc_Chunk_Type *type){
- String start_str = make_string(source.str, 0);
- String chunk = get_next_doc_chunk(source, start_str, type);
- return(chunk);
-}
-
-static void
-print_doc_description(String *out, Partition *part, String src){
- Doc_Chunk_Type type;
-
- for (String chunk = get_first_doc_chunk(src, &type);
- chunk.str;
- chunk = get_next_doc_chunk(src, chunk, &type)){
-
- switch (type){
- case DocChunk_PlainText:
- {
- for (String line = get_first_double_line(chunk);
- line.str;
- line = get_next_double_line(chunk, line)){
- append_ss(out, line);
- append_sc(out, "
");
- }
- }break;
-
- case DocChunk_CodeExample:
- {
- int32_t start = 0;
- int32_t end = chunk.size-1;
- while (start < end && chunk.str[start] != '(') ++start;
- start += 1;
- while (end > start && chunk.str[end] != ')') --end;
-
-
- append_sc(out, EXAMPLE_CODE_OPEN);
-
- if (start < end){
- String code_example = substr(chunk, start, end - start);
- int32_t first_line = 1;
-
- for (String line = get_first_line(code_example);
- line.str;
- line = get_next_line(code_example, line)){
-
- if (!(first_line && line.size == 0)){
- int32_t space_i = 0;
- for (; space_i < line.size; ++space_i){
- if (line.str[space_i] == ' '){
- append_sc(out, " ");
- }
- else{
- break;
- }
- }
-
- String line_tail = substr_tail(line, space_i);
- append_ss(out, line_tail);
- append_sc(out, "
");
- }
- first_line = 0;
- }
- }
-
- append_sc(out, EXAMPLE_CODE_CLOSE);
- }break;
- }
- }
-}
-
-static void
-print_struct_docs(String *out, Partition *part, Item_Node *member){
- for (Item_Node *member_iter = member->first_child;
- member_iter != 0;
- member_iter = member_iter->next_sibling){
- String type = member_iter->type;
- if (match_ss(type, make_lit_string("struct")) ||
- match_ss(type, make_lit_string("union"))){
- print_struct_docs(out, part, member_iter);
- }
- else{
- Documentation doc = {0};
- perform_doc_parse(part, member_iter->doc_string, &doc);
-
- append_sc(out, "");
-
- append_sc(out, "
"DOC_ITEM_HEAD_INL_OPEN);
- append_ss(out, member_iter->name);
- append_sc(out, DOC_ITEM_HEAD_INL_CLOSE"
");
-
- append_sc(out, "
"DOC_ITEM_OPEN);
- print_doc_description(out, part, doc.main_doc);
- append_sc(out, DOC_ITEM_CLOSE"
");
-
- append_sc(out, "
");
- }
- }
-}
-
-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"");
- append_ss(out, see_also);
- append_sc(out, ""DOC_ITEM_CLOSE);
- }
- }
-}
-
static void
print_function_body_code(String *out, Parse_Context *context, int32_t start){
String pstr = {0}, lexeme = {0};
@@ -426,311 +117,15 @@ print_function_body_code(String *out, Parse_Context *context, int32_t start){
}
}
}
-
-static void
-print_function_docs(String *out, Partition *part, String name, String doc_string){
- if (doc_string.size == 0){
- append_sc(out, "No documentation generated for this function.");
- fprintf(stderr, "warning: no documentation string for %.*s\n", name.size, name.str);
- }
-
- Temp_Memory temp = begin_temp_memory(part);
-
- Documentation doc = {0};
-
- perform_doc_parse(part, doc_string, &doc);
-
- int32_t doc_param_count = doc.param_count;
- if (doc_param_count > 0){
- append_sc(out, DOC_HEAD_OPEN"Parameters"DOC_HEAD_CLOSE);
-
- for (int32_t 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!
-
- append_sc(out, ""DOC_ITEM_HEAD_OPEN);
- append_ss(out, param_name);
- append_sc(out, DOC_ITEM_HEAD_CLOSE"
"DOC_ITEM_OPEN);
- append_ss(out, param_docs);
- append_sc(out, DOC_ITEM_CLOSE"
");
- }
- }
-
- String ret_doc = doc.return_doc;
- if (ret_doc.size != 0){
- append_sc(out, DOC_HEAD_OPEN"Return"DOC_HEAD_CLOSE DOC_ITEM_OPEN);
- append_ss(out, ret_doc);
- append_sc(out, DOC_ITEM_CLOSE);
- }
-
- String main_doc = doc.main_doc;
- if (main_doc.size != 0){
- append_sc(out, DOC_HEAD_OPEN"Description"DOC_HEAD_CLOSE DOC_ITEM_OPEN);
- print_doc_description(out, part, main_doc);
- append_sc(out, DOC_ITEM_CLOSE);
- }
-
- print_see_also(out, &doc);
-
- end_temp_memory(temp);
-}
-
-static void
-print_item_in_list(String *out, String name, char *id_postfix){
- append_sc(out, "- ");
- append_ss(out, name);
- append_sc(out, "
");
-}
-
-static void
-print_item(String *out, Partition *part, Used_Links *used,
- 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;
- /* NOTE(allen):
- Open a div for the whole item.
- Put a heading in it with the name and section.
- Open a "descriptive" box for the display of the code interface.
- */
- append_sc(out, "");
-
- int32_t has_cpp_name = 0;
- if (item->cpp_name.str != 0){
- if (try_to_use(used, item->cpp_name)){
- append_sc(out, "
");
- has_cpp_name = 1;
- }
- }
-
- append_sc (out, "
§");
- append_sc (out, section);
- append_s_char (out, '.');
- append_int_to_str (out, I);
- append_sc (out, ": ");
- append_ss (out, name);
- append_sc (out, "
");
-
- append_sc(out, "
");
-
- switch (item->t){
- case Item_Function:
- {
- // NOTE(allen): Code box
- Assert(function_prefix != 0);
- print_function_html(out, used, item->cpp_name, item->ret, function_prefix, item->name, item->breakdown);
-
- // NOTE(allen): Close the code box
- append_sc(out, "
");
-
- // 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, "
");
-
- // NOTE(allen): Descriptive section
- print_function_docs(out, part, item->name, item->doc_string);
- }break;
-
- case Item_Typedef:
- {
- String type = item->type;
-
- // NOTE(allen): Code box
- append_sc (out, "typedef ");
- append_ss (out, type);
- append_s_char (out, ' ');
- append_ss (out, name);
- append_s_char (out, ';');
-
- // NOTE(allen): Close the code box
- append_sc(out, "
");
-
- // NOTE(allen): Descriptive section
- String doc_string = item->doc_string;
- Documentation doc = {0};
- perform_doc_parse(part, doc_string, &doc);
-
- String main_doc = doc.main_doc;
- if (main_doc.size != 0){
- append_sc(out, DOC_HEAD_OPEN"Description"DOC_HEAD_CLOSE);
-
- append_sc(out, DOC_ITEM_OPEN);
- print_doc_description(out, part, main_doc);
- append_sc(out, DOC_ITEM_CLOSE);
- }
- else{
- fprintf(stderr, "warning: no documentation string for %.*s\n", name.size, name.str);
- }
-
- print_see_also(out, &doc);
-
- }break;
-
- case Item_Enum:
- {
- // NOTE(allen): Code box
- append_sc (out, "enum ");
- append_ss (out, name);
- append_s_char (out, ';');
-
- // NOTE(allen): Close the code box
- append_sc(out, "
");
-
- // NOTE(allen): Descriptive section
- String doc_string = item->doc_string;
- Documentation doc = {0};
- perform_doc_parse(part, doc_string, &doc);
-
- String main_doc = doc.main_doc;
- if (main_doc.size != 0){
- append_sc(out, DOC_HEAD_OPEN"Description"DOC_HEAD_CLOSE);
-
- append_sc(out, DOC_ITEM_OPEN);
- print_doc_description(out, part, main_doc);
- append_sc(out, DOC_ITEM_CLOSE);
- }
- else{
- fprintf(stderr, "warning: no documentation string for %.*s\n", name.size, name.str);
- }
-
- if (item->first_child){
- append_sc(out, DOC_HEAD_OPEN"Values"DOC_HEAD_CLOSE);
-
- for (Item_Node *member = item->first_child;
- member;
- member = member->next_sibling){
- Documentation doc = {0};
- perform_doc_parse(part, member->doc_string, &doc);
-
- append_sc(out, "
");
-
- // NOTE(allen): Dafuq is this all?
- append_sc(out, "
"DOC_ITEM_HEAD_INL_OPEN);
- append_ss(out, member->name);
- append_sc(out, DOC_ITEM_HEAD_INL_CLOSE);
-
- if (member->value.str){
- append_sc(out, " = ");
- append_ss(out, member->value);
- }
-
- append_sc(out, "
");
-
- append_sc(out, "
"DOC_ITEM_OPEN);
- print_doc_description(out, part, doc.main_doc);
- append_sc(out, DOC_ITEM_CLOSE"
");
-
- append_sc(out, "
");
- }
- }
-
- print_see_also(out, &doc);
-
- }break;
-
- case Item_Struct: case Item_Union:
- {
- String doc_string = item->doc_string;
-
- int32_t hide_members = 0;
-
- if (doc_string.size == 0){
- hide_members = 1;
- }
- else{
- for (String word = get_first_word(doc_string);
- word.str;
- word = get_next_word(doc_string, word)){
- if (match_ss(word, make_lit_string("HIDE_MEMBERS"))){
- hide_members = 1;
- break;
- }
- }
- }
-
- // NOTE(allen): Code box
- print_struct_html(out, item, hide_members);
-
- // NOTE(allen): Close the code box
- append_sc(out, "
");
-
- // NOTE(allen): Descriptive section
- {
- Documentation doc = {0};
- perform_doc_parse(part, doc_string, &doc);
-
- String main_doc = doc.main_doc;
- if (main_doc.size != 0){
- append_sc(out, DOC_HEAD_OPEN"Description"DOC_HEAD_CLOSE);
-
- append_sc(out, DOC_ITEM_OPEN);
- print_doc_description(out, part, main_doc);
- append_sc(out, DOC_ITEM_CLOSE);
- }
- else{
- fprintf(stderr, "warning: no documentation string for %.*s\n", name.size, name.str);
- }
-
- if (!hide_members){
- if (item->first_child){
- append_sc(out, DOC_HEAD_OPEN"Fields"DOC_HEAD_CLOSE);
- print_struct_docs(out, part, item);
- }
- }
-
- print_see_also(out, &doc);
- }
- }break;
- }
-
- if (has_cpp_name){
- append_sc(out, "");
- }
-
- // NOTE(allen): Close the item box
- append_sc(out, "
");
-
- end_temp_memory(temp);
-}
-
-typedef struct App_API_Name{
- String macro;
- String public_name;
-} App_API_Name;
-
-typedef struct App_API{
- App_API_Name *names;
-} App_API;
-
-static App_API
+
+static Alternate_Names_Array
allocate_app_api(Partition *part, int32_t count){
- App_API app_api = {0};
- app_api.names = push_array(part, App_API_Name, count);
- memset(app_api.names, 0, sizeof(App_API_Name)*count);
+ Alternate_Names_Array app_api = {0};
+ app_api.names = push_array(part, Alternate_Name, count);
+ memset(app_api.names, 0, sizeof(Alternate_Name)*count);
return(app_api);
}
-
+
static void
assert_files_are_equal(char *directory, char *filename1, char *filename2){
char space[256];
@@ -739,17 +134,17 @@ assert_files_are_equal(char *directory, char *filename1, char *filename2){
append_sc(&name, "\\");
append_sc(&name, filename1);
terminate_with_null(&name);
-
+
String file1 = file_dump(name.str);
-
+
name.size = 0;
append_sc(&name, directory);
append_sc(&name, "\\");
append_sc(&name, filename2);
terminate_with_null(&name);
-
+
String file2 = file_dump(name.str);
-
+
if (!match_ss(file1, file2)){
fprintf(stderr, "Failed transitional test: %s != %s\n", filename1, filename2);
}
@@ -757,18 +152,18 @@ assert_files_are_equal(char *directory, char *filename1, char *filename2){
fprintf(stderr, "Passed transitional test: %s == %s\n", filename1, filename2);
}
}
-
+
static void
generate_site(char *code_directory, char *src_directory, char *dst_directory){
#define API_DOC "4coder_API.html"
-
+
int32_t size = (512 << 20);
void *mem = malloc(size);
memset(mem, 0, size);
-
+
Partition part_ = make_part(mem, size);
Partition *part = &part_;
-
+
static Meta_Keywords meta_keywords[] = {
{make_lit_string("API_EXPORT") , Item_Function } ,
{make_lit_string("API_EXPORT_INLINE") , Item_Function } ,
@@ -779,79 +174,80 @@ generate_site(char *code_directory, char *src_directory, char *dst_directory){
{make_lit_string("UNION") , Item_Union } ,
{make_lit_string("ENUM") , Item_Enum } ,
};
-
+
#define ExpandArray(a) (a), (ArrayCount(a))
-
+
// NOTE(allen): Parse the important code.
Meta_Unit custom_types_unit = compile_meta_unit(part, code_directory, "4coder_types.h", ExpandArray(meta_keywords));
-
+
Meta_Unit lexer_funcs_unit = compile_meta_unit(part, code_directory, "4cpp_lexer.h", ExpandArray(meta_keywords));
-
+
Meta_Unit lexer_types_unit = compile_meta_unit(part, code_directory, "4cpp_lexer_types.h", ExpandArray(meta_keywords));
-
+
Meta_Unit string_unit = compile_meta_unit(part, code_directory, "internal_4coder_string.cpp", ExpandArray(meta_keywords));
-
+
static char *functions_files[] = {
"4ed_api_implementation.cpp",
"win32_api_impl.cpp",
0
};
-
+
Meta_Unit custom_funcs_unit = compile_meta_unit(part, code_directory, functions_files, ExpandArray(meta_keywords));
-
-
+
+
// NOTE(allen): Compute and store variations of the custom function names
- App_API func_4ed_names = allocate_app_api(part, custom_funcs_unit.set.count);
-
+ Alternate_Names_Array custom_func_names = allocate_app_api(part, custom_funcs_unit.set.count);
+
for (int32_t i = 0; i < custom_funcs_unit.set.count; ++i){
String name_string = custom_funcs_unit.set.items[i].name;
- String *macro = &func_4ed_names.names[i].macro;
- String *public_name = &func_4ed_names.names[i].public_name;
-
+ String *macro = &custom_func_names.names[i].macro;
+ String *public_name = &custom_func_names.names[i].public_name;
+
*macro = str_alloc(part, name_string.size+4);
to_upper_ss(macro, name_string);
append_ss(macro, make_lit_string("_SIG"));
-
+
*public_name = str_alloc(part, name_string.size);
to_lower_ss(public_name, name_string);
-
+
partition_align(part, 4);
}
-
+
// NOTE(allen): Load enriched text materials
Enriched_Text introduction = load_enriched_text(part, src_directory, "introduction.txt");
-
+ Enriched_Text lexer_introduction = load_enriched_text(part, src_directory, "lexer_introduction.txt");
+
// NOTE(allen): Put together the abstract document
Abstract_Document doc = {0};
begin_document_description(&doc, part, "4coder API Docs");
-
+
add_table_of_contents(&doc);
-
+
begin_section(&doc, "Introduction", "introduction");
add_enriched_text(&doc, &introduction);
end_section(&doc);
-
+
begin_section(&doc, "4coder Systems", "4coder_systems");
add_todo(&doc);
end_section(&doc);
-
+
begin_section(&doc, "Types and Functions", "types_and_functions");
{
begin_section(&doc, "Function List", 0);
- add_element_list(&doc, &custom_funcs_unit);
+ add_element_list(&doc, &custom_funcs_unit, &custom_func_names, AltName_Public_Name);
end_section(&doc);
begin_section(&doc, "Type List", 0);
add_element_list(&doc, &custom_types_unit);
end_section(&doc);
begin_section(&doc, "Function Descriptions", 0);
- add_full_elements(&doc, &custom_funcs_unit);
+ add_full_elements(&doc, &custom_funcs_unit, &custom_func_names, AltName_Public_Name);
end_section(&doc);
begin_section(&doc, "Type Descriptions", 0);
add_full_elements(&doc, &custom_types_unit);
end_section(&doc);
}
end_section(&doc);
-
+
begin_section(&doc, "String Library", "string_library");
{
begin_section(&doc, "String Library Intro", 0);
@@ -865,11 +261,11 @@ generate_site(char *code_directory, char *src_directory, char *dst_directory){
end_section(&doc);
}
end_section(&doc);
-
+
begin_section(&doc, "Lexer Library", "lexer_library");
{
begin_section(&doc, "Lexer Intro", 0);
- add_todo(&doc);
+ add_enriched_text(&doc, &lexer_introduction);
end_section(&doc);
begin_section(&doc, "Lexer Function List", 0);
add_element_list(&doc, &lexer_funcs_unit);
@@ -885,17 +281,17 @@ generate_site(char *code_directory, char *src_directory, char *dst_directory){
end_section(&doc);
}
end_section(&doc);
-
+
end_document_description(&doc);
-
+
// NOTE(allen): Output
String out = str_alloc(part, 10 << 20);
Out_Context context = {0};
set_context_directory(&context, dst_directory);
-
+
// Output Docs - General Document Generator
if (begin_file_out(&context, "gen-test.html", &out)){
- generate_document_html(&out, &doc);
+ generate_document_html(&out, part, &doc);
end_file_out(context);
}
else{
@@ -1015,7 +411,7 @@ generate_site(char *code_directory, char *src_directory, char *dst_directory){
"editor@4coder.net or "
"to get help from community members you can post on the "
"4coder forums hosted on handmade.network at "
- "4coder.handmade.network"
+ "4coder.handmade.network."
"");
#endif
@@ -1029,7 +425,7 @@ generate_site(char *code_directory, char *src_directory, char *dst_directory){
"editor@4coder.net or "
"to get help from members of the 4coder and handmade network community you "
"can post on the 4coder forums hosted at "
- "4coder.handmade.network"
+ "4coder.handmade.network."
"");
#undef MAJOR_SECTION
@@ -1060,7 +456,7 @@ generate_site(char *code_directory, char *src_directory, char *dst_directory){
append_sc(&out, "§"SECTION" Function List
");
for (int32_t i = 0; i < custom_funcs_unit.set.count; ++i){
- print_item_in_list(&out, func_4ed_names.names[i].public_name, "_doc");
+ print_item_in_list(&out, custom_func_names.names[i].public_name, "_doc");
}
append_sc(&out, "
");
@@ -1079,11 +475,12 @@ generate_site(char *code_directory, char *src_directory, char *dst_directory){
append_sc(&out, "§"SECTION" Function Descriptions
");
for (int32_t i = 0; i < custom_funcs_unit.set.count; ++i){
Item_Node *item = &custom_funcs_unit.set.items[i];
- String name = func_4ed_names.names[i].public_name;
+ String name = custom_func_names.names[i].public_name;
append_sc (&out, "§"SECTION".");
+ append_sc (&out, "_doc' style='margin-bottom: 1cm;'>");
+ append_sc (&out, "§"SECTION".");
append_int_to_str(&out, i+1);
append_sc (&out, ": ");
append_ss (&out, name);
@@ -1104,7 +501,7 @@ generate_site(char *code_directory, char *src_directory, char *dst_directory){
int32_t I = 1;
for (int32_t i = 0; i < custom_types_unit.set.count; ++i, ++I){
- print_item(&out, part, &used_links, custom_types_unit.set.items + i, "_doc", 0, SECTION, I);
+ print_item_html(&out, part, &used_links, custom_types_unit.set.items + i, "_doc", SECTION, I, 0, 0);
}
#undef MAJOR_SECTION
@@ -1120,7 +517,7 @@ generate_site(char *code_directory, char *src_directory, char *dst_directory){
#undef SECTION
#define SECTION MAJOR_SECTION".1"
- append_sc(&out, "§"SECTION" String Intro
");
+ append_sc(&out, "§"SECTION" String Library Intro
");
append_sc(&out, "Coming Soon");
@@ -1141,7 +538,7 @@ generate_site(char *code_directory, char *src_directory, char *dst_directory){
append_sc(&out, "
§"SECTION" String Function Descriptions
");
for (int32_t i = 0; i < string_unit.set.count; ++i){
- print_item(&out, part, &used_links, string_unit.set.items+i, "_doc", "", SECTION, i+1);
+ print_item_html(&out, part, &used_links, string_unit.set.items+i, "_doc", SECTION, i+1, 0, 0);
}
#undef MAJOR_SECTION
@@ -1161,23 +558,23 @@ generate_site(char *code_directory, char *src_directory, char *dst_directory){
append_sc(&out,
"
"
- "The 4cpp lexer system provides a polished, fast, flexible system that "
+ "
The 4cpp lexer system provides a polished, fast, flexible system that "
"takes in C/C++ and outputs a tokenization of the text data. There are "
"two API levels. One level is setup to let you easily get a tokenization "
"of the file. This level manages memory for you with malloc to make it "
"as fast as possible to start getting your tokens. The second level "
"enables deep integration by allowing control over allocation, data "
- "chunking, and output rate control.
"
- "To use the quick setup API you simply include 4cpp_lexer.h and read the "
- "documentation at cpp_lex_file.
"
- "To use the the fancier API include 4cpp_lexer.h and read the "
+ "chunking, and output rate control.
"
+ "
To use the quick setup API you simply include 4cpp_lexer.h and read the "
+ "documentation at cpp_lex_file.
"
+ "
To use the the fancier API include 4cpp_lexer.h and read the "
"documentation at cpp_lex_step. "
"If you want to be absolutely sure you are not including malloc into "
"your program you can define FCPP_FORBID_MALLOC before the include and "
- "the \"step\" API will continue to work.
"
- "There are a few more features in 4cpp that are not documented yet. "
+ "the \"step\" API will continue to work.
"
+ "
There are a few more features in 4cpp that are not documented yet. "
"You are free to try to use these, but I am not totally sure they are "
- "ready yet, and when they are they will be documented."
+ "ready yet, and when they are they will be documented.
"
"
");
#undef SECTION
@@ -1194,7 +591,7 @@ generate_site(char *code_directory, char *src_directory, char *dst_directory){
#undef SECTION
#define SECTION MAJOR_SECTION".3"
- append_sc(&out, "
§"SECTION" Lexer Types List
");
+ append_sc(&out, "
§"SECTION" Lexer Type List
");
append_sc(&out, "
");
for (int32_t i = 0; i < lexer_types_unit.set.count; ++i){
@@ -1207,7 +604,7 @@ generate_site(char *code_directory, char *src_directory, char *dst_directory){
append_sc(&out, "§"SECTION" Lexer Function Descriptions
");
for (int32_t i = 0; i < lexer_funcs_unit.set.count; ++i){
- print_item(&out, part, &used_links, lexer_funcs_unit.set.items+i, "_doc", "", SECTION, i+1);
+ print_item_html(&out, part, &used_links, lexer_funcs_unit.set.items+i, "_doc", SECTION, i+1, 0, 0);
}
#undef SECTION
@@ -1215,7 +612,7 @@ generate_site(char *code_directory, char *src_directory, char *dst_directory){
append_sc(&out, "§"SECTION" Lexer Type Descriptions
");
for (int32_t i = 0; i < lexer_types_unit.set.count; ++i){
- print_item(&out, part, &used_links, lexer_types_unit.set.items+i, "_doc", "", SECTION, i+1);
+ print_item_html(&out, part, &used_links, lexer_types_unit.set.items+i, "_doc", SECTION, i+1, 0, 0);
}
append_sc(&out, "