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
");
-
- i32 i = 1;
- for (Document_Item *toc_item = item->parent->section.first_child;
- toc_item != 0;
- toc_item = toc_item->next){
- if (toc_item->type == Doc_Section){
- if (toc_item->section.id.size > 0){
- append_sc(out, "- §");
+ if (head){
+ append(out, "
Table of Contents
");
+
+ i32 i = 1;
+ for (Document_Item *toc_item = item->parent->section.first_child;
+ toc_item != 0;
+ toc_item = toc_item->next){
+ if (toc_item->type == Doc_Section){
+ if (toc_item->section.id.size > 0){
+ append(out, "- §");
+ }
+ else{
+ append(out, "
- §");
+ }
+ append_int_to_str (out, i);
+ append_s_char (out, ' ');
+ append (out, toc_item->section.name);
+ append (out, "
");
+ ++i;
}
- else{
- append_sc(out, "- §");
- }
- append_int_to_str (out, i);
- append_s_char (out, ' ');
- append_ss (out, toc_item->section.name);
- append_sc (out, "
");
- ++i;
}
+
+ append(out, "
");
}
-
- append_sc(out, "");
}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));