built out the entire site

master
Allen Webster 2016-11-28 14:13:53 -05:00
parent 43c2df99d4
commit 87003907a7
8 changed files with 1011 additions and 834 deletions

View File

@ -525,7 +525,7 @@ init_build_line(Build_Line *line){
#define CL_INCLUDES "/I..\\foreign /I..\\foreign\\freetype2"
#define CL_SITE_INCLUDES "/I..\\..\\code"
#define CL_SITE_INCLUDES "/I..\\..\\foreign /I..\\..\\code"
#define CL_LIBS \
"user32.lib winmm.lib gdi32.lib opengl32.lib " \
@ -609,7 +609,7 @@ build_cl(uint32_t flags, char *code_path, char *code_file, char *out_path, char
#define GCC_INCLUDES "-I../foreign -I../code"
#define GCC_SITE_INCLUDES "-I../../code"
#define GCC_SITE_INCLUDES "-I../../foreign -I../../code"
#define GCC_LIBS \
"-L/usr/local/lib -lX11 -lpthread -lm -lrt " \
@ -931,9 +931,9 @@ site_build(char *cdir, uint32_t flags){
BEGIN_TIME_SECTION();
#if defined(IS_WINDOWS)
systemf("..\\build\\site\\sitegen . site\\source_material ..\\site");
systemf("..\\build\\site\\sitegen . ..\\foreign\\site-resources site\\source_material ..\\site");
#else
systemf("../build/site/sitegen . site/source_material ../site");
systemf("../build/site/sitegen . ../foreign/site-resources site/source_material ../site");
#endif
END_TIME_SECTION("run sitegen");

View File

@ -33,7 +33,7 @@ load_enriched_text(Partition *part, char *directory, char *filename){
result.source = file_dump(fname.str);
return(result);
}
}
// Document Declaration
@ -72,6 +72,7 @@ struct Document_Item{
Document_Item *last_child;
String name;
String id;
int32_t show_title;
} section;
struct{
@ -83,31 +84,52 @@ struct Document_Item{
struct{
Enriched_Text *text;
} text;
};
};
};
static Document_Item null_document_item = {0};
struct Abstract_Document{
// Document value members
Document_Item *root_item;
enum{
ItemType_Document,
ItemType_Image,
// never below this
ItemType_COUNT,
};
struct Abstract_Item{
int32_t item_type;
char *name;
// Document value members
Document_Item *root_item;
// TODO(allen): make these external
// Document building members
Partition *part;
Document_Item *section_stack[16];
int32_t section_top;
};
static Abstract_Document null_abstract_document = {0};
struct Document_Node{
Abstract_Document doc;
Document_Node *next;
// Image value members
char *source_file;
char *out_file;
float w_h_ratio;
float h_w_ratio;
};
static Abstract_Item null_abstract_item = {0};
struct Basic_Node{
Basic_Node *next;
};
#define NodeGetData(node, T) ((T*) ((node)+1))
struct Basic_List{
Basic_Node *head;
Basic_Node *tail;
};
struct Document_System{
Document_Node *head;
Document_Node *tail;
Basic_List doc_list;
Basic_List img_list;
Partition *part;
};
@ -118,48 +140,37 @@ create_document_system(Partition *part){
return(system);
}
static Abstract_Document*
create_document(Document_System *system, char *name){
int32_t is_new_name = 1;
static void*
push_item_on_list(Partition *part, Basic_List *list, int32_t item_size){
int32_t mem_size = item_size + sizeof(Basic_Node);
void *mem = push_block(part, mem_size);
assert(mem != 0);
memset(mem, 0, mem_size);
for (Document_Node *node = system->head;
node != 0;
node = node->next){
if (match_cc(node->doc.name, name)){
is_new_name = 0;
}
}
Abstract_Document *result = 0;
if (is_new_name){
Document_Node *node = push_struct(system->part, Document_Node);
memset(node, 0, sizeof(*node));
assert(node != 0);
result = &node->doc;
node->next = 0;
if (system->head == 0){
system->head = node;
system->tail = node;
Basic_Node *node = (Basic_Node*)mem;
if (list->head == 0){
list->head = node;
list->tail = node;
}
else{
system->tail->next = node;
system->tail = node;
}
list->tail->next = node;
list->tail = node;
}
void *result = (node+1);
return(result);
}
static Abstract_Document*
get_document_by_name(Document_System *system, String name){
Abstract_Document *result = 0;
static Abstract_Item*
get_item_by_name(Basic_List list, String name){
Abstract_Item *result = 0;
for (Document_Node *node = system->head;
for (Basic_Node *node = list.head;
node != 0;
node = node->next){
if (match_cs(node->doc.name, name)){
result = &node->doc;
Abstract_Item *item = NodeGetData(node, Abstract_Item);
if (match(item->name, name)){
result = item;
break;
}
}
@ -167,12 +178,44 @@ get_document_by_name(Document_System *system, String name){
return(result);
}
static Abstract_Item*
get_item_by_name(Basic_List list, char *name){
Abstract_Item *result = 0;
for (Basic_Node *node = list.head;
node != 0;
node = node->next){
Abstract_Item *item = NodeGetData(node, Abstract_Item);
if (match(item->name, name)){
result = item;
break;
}
}
return(result);
}
static Abstract_Item*
create_item(Partition *part, Basic_List *list, char *name){
int32_t is_new_name = 1;
Abstract_Item *lookup = get_item_by_name(*list, name);
Abstract_Item *result = 0;
if (is_new_name){
result = (Abstract_Item*)push_item_on_list(part, list, sizeof(Abstract_Item));
}
return(result);
}
static void
set_section_name(Partition *part, Document_Item *item, char *name){
set_section_name(Partition *part, Document_Item *item, char *name, int32_t show_title){
int32_t name_len = str_size(name);
item->section.name = make_string_cap(push_array(part, char, name_len+1), 0, name_len+1);
partition_align(part, 8);
append_sc(&item->section.name, name);
item->section.show_title = show_title;
}
static void
@ -184,8 +227,9 @@ set_section_id(Partition *part, Document_Item *item, char *id){
}
static void
begin_document_description(Abstract_Document *doc, Partition *part, char *title){
*doc = null_abstract_document;
begin_document_description(Abstract_Item *doc, Partition *part, char *title, int32_t show_title){
*doc = null_abstract_item;
doc->item_type = ItemType_Document;
doc->part = part;
doc->root_item = push_struct(doc->part, Document_Item);
@ -193,27 +237,47 @@ begin_document_description(Abstract_Document *doc, Partition *part, char *title)
doc->section_stack[doc->section_top] = doc->root_item;
doc->root_item->type = Doc_Root;
set_section_name(doc->part, doc->root_item, title);
set_section_name(doc->part, doc->root_item, title, show_title);
}
static void
set_document_name(Abstract_Document *doc, char *name){
doc->name = name;
}
static Abstract_Item*
add_image_description(Document_System *system, char *asset_directory, char *source_file, char *out_file, char *name){
Abstract_Item *item = create_item(system->part, &system->img_list, name);
if (item){
item->item_type = ItemType_Image;
item->source_file = source_file;
item->out_file = out_file;
item->name = name;
static Abstract_Document*
begin_document_description(Document_System *system, char *title, char *name){
Abstract_Document *doc = create_document(system, name);
if (doc){
begin_document_description(doc, system->part, title);
char str[256];
String s = make_fixed_width_string(str);
append_sc(&s, asset_directory);
append_sc(&s, "/");
append_sc(&s, source_file);
terminate_with_null(&s);
int32_t w = 0, h = 0, comp = 0;
int32_t stbi_r = stbi_info(str, &w, &h, &comp);
assert(stbi_r);
item->w_h_ratio = ((float)w/(float)h);
item->h_w_ratio = ((float)h/(float)w);
}
set_document_name(doc, name);
return(doc);
return(item);
}
static Abstract_Item*
begin_document_description(Document_System *system, char *title, char *name, int32_t show_title){
Abstract_Item *item = create_item(system->part, &system->doc_list, name);
if (item){
begin_document_description(item, system->part, title, show_title);
item->name = name;
}
return(item);
}
static void
end_document_description(Abstract_Document *doc){
Assert(doc->section_top == 0);
end_document_description(Abstract_Item *item){
Assert(item->section_top == 0);
}
static void
@ -230,32 +294,32 @@ append_child(Document_Item *parent, Document_Item *item){
}
static void
begin_section(Abstract_Document *doc, char *title, char *id){
Assert(doc->section_top+1 < ArrayCount(doc->section_stack));
begin_section(Abstract_Item *item, char *title, char *id){
Assert(item->section_top+1 < ArrayCount(item->section_stack));
Document_Item *parent = doc->section_stack[doc->section_top];
Document_Item *section = push_struct(doc->part, Document_Item);
Document_Item *parent = item->section_stack[item->section_top];
Document_Item *section = push_struct(item->part, Document_Item);
*section = null_document_item;
doc->section_stack[++doc->section_top] = section;
item->section_stack[++item->section_top] = section;
section->type = Doc_Section;
set_section_name(doc->part, section, title);
set_section_name(item->part, section, title, 1);
if (id){
set_section_id(doc->part, section, id);
set_section_id(item->part, section, id);
}
append_child(parent, section);
}
}
static void
end_section(Abstract_Document *doc){
end_section(Abstract_Item *doc){
Assert(doc->section_top > 0);
--doc->section_top;
}
static void
add_todo(Abstract_Document *doc){
add_todo(Abstract_Item *doc){
Document_Item *parent = doc->section_stack[doc->section_top];
Document_Item *item = push_struct(doc->part, Document_Item);
*item = null_document_item;
@ -265,7 +329,7 @@ add_todo(Abstract_Document *doc){
}
static void
add_element_list(Abstract_Document *doc, Meta_Unit *unit){
add_element_list(Abstract_Item *doc, Meta_Unit *unit){
Document_Item *parent = doc->section_stack[doc->section_top];
Document_Item *item = push_struct(doc->part, Document_Item);
*item = null_document_item;
@ -276,7 +340,7 @@ add_element_list(Abstract_Document *doc, Meta_Unit *unit){
}
static void
add_element_list(Abstract_Document *doc, Meta_Unit *unit, Alternate_Names_Array *alt_names, int32_t alt_name_type){
add_element_list(Abstract_Item *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;
@ -289,7 +353,7 @@ add_element_list(Abstract_Document *doc, Meta_Unit *unit, Alternate_Names_Array
}
static void
add_full_elements(Abstract_Document *doc, Meta_Unit *unit){
add_full_elements(Abstract_Item *doc, Meta_Unit *unit){
Document_Item *parent = doc->section_stack[doc->section_top];
Document_Item *item = push_struct(doc->part, Document_Item);
*item = null_document_item;
@ -300,7 +364,7 @@ add_full_elements(Abstract_Document *doc, Meta_Unit *unit){
}
static void
add_full_elements(Abstract_Document *doc, Meta_Unit *unit, Alternate_Names_Array *alt_names, int32_t alt_name_type){
add_full_elements(Abstract_Item *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;
@ -313,7 +377,7 @@ add_full_elements(Abstract_Document *doc, Meta_Unit *unit, Alternate_Names_Array
}
static void
add_table_of_contents(Abstract_Document *doc){
add_table_of_contents(Abstract_Item *doc){
Document_Item *parent = doc->section_stack[doc->section_top];
Document_Item *item = push_struct(doc->part, Document_Item);
*item = null_document_item;
@ -323,7 +387,7 @@ add_table_of_contents(Abstract_Document *doc){
}
static void
add_enriched_text(Abstract_Document *doc, Enriched_Text *text){
add_enriched_text(Abstract_Item *doc, Enriched_Text *text){
Assert(doc->section_top+1 < ArrayCount(doc->section_stack));
Document_Item *parent = doc->section_stack[doc->section_top];
@ -380,7 +444,7 @@ struct Section_Counter{
};
static int32_t
doc_get_link_string(Abstract_Document *doc, char *space, int32_t capacity){
doc_get_link_string(Abstract_Item *doc, char *space, int32_t capacity){
String str = make_string_cap(space, 0, capacity);
append_sc(&str, doc->name);
append_sc(&str, ".html");
@ -388,6 +452,14 @@ doc_get_link_string(Abstract_Document *doc, char *space, int32_t capacity){
return(result);
}
static int32_t
img_get_link_string(Abstract_Item *img, char *space, int32_t capacity){
String str = make_string_cap(space, 0, capacity);
append_sc(&str, img->out_file);
int32_t result = terminate_with_null(&str);
return(result);
}
static void
append_section_number_reduced(String *out, Section_Counter *section_counter, int32_t reduce){
int32_t level = section_counter->nest_level-reduce;
@ -436,7 +508,7 @@ extract_command_body(String *out, String l, int32_t *i_in_out, int32_t *body_sta
}
else{
#define STR_START "<span style='color:#F00'>! Doc generator error: missing body for "
#define STR_SLOW " !</span>"
#define STR_SLOW " !</span>"
append_sc(out, STR_START);
append_ss(out, command_name);
append_sc(out, STR_SLOW);
@ -484,6 +556,8 @@ html_render_section_header(String *out, String section_name, String section_id,
}
}
#define HTML_WIDTH 800
static void
write_enriched_text_html(String *out, Enriched_Text *text, Document_System *doc_system, Section_Counter *section_counter){
String source = text->source;
@ -523,7 +597,8 @@ write_enriched_text_html(String *out, Enriched_Text *text, Document_System *doc_
enum Command_Types{
Cmd_BackSlash,
Cmd_Version,
Cmd_CodeStyle,
Cmd_BeginStyle,
Cmd_EndStyle,
Cmd_DocLink,
Cmd_BeginList,
Cmd_EndList,
@ -533,6 +608,7 @@ write_enriched_text_html(String *out, Enriched_Text *text, Document_System *doc_
Cmd_Section,
Cmd_BeginLink,
Cmd_EndLink,
Cmd_Image,
// never below this
Cmd_COUNT,
};
@ -541,7 +617,8 @@ write_enriched_text_html(String *out, Enriched_Text *text, Document_System *doc_
enriched_commands[Cmd_BackSlash] = make_lit_string("\\");
enriched_commands[Cmd_Version] = make_lit_string("VERSION");
enriched_commands[Cmd_CodeStyle] = make_lit_string("CODE_STYLE");
enriched_commands[Cmd_BeginStyle] = make_lit_string("BEGIN_STYLE");
enriched_commands[Cmd_EndStyle] = make_lit_string("END_STYLE");
enriched_commands[Cmd_DocLink] = make_lit_string("DOC_LINK");
enriched_commands[Cmd_BeginList] = make_lit_string("BEGIN_LIST");
enriched_commands[Cmd_EndList] = make_lit_string("END_LIST");
@ -551,6 +628,7 @@ write_enriched_text_html(String *out, Enriched_Text *text, Document_System *doc_
enriched_commands[Cmd_Section] = make_lit_string("SECTION");
enriched_commands[Cmd_BeginLink] = make_lit_string("BEGIN_LINK");
enriched_commands[Cmd_EndLink] = make_lit_string("END_LINK");
enriched_commands[Cmd_Image] = make_lit_string("IMAGE");
i = command_end;
@ -559,24 +637,33 @@ write_enriched_text_html(String *out, Enriched_Text *text, Document_System *doc_
switch (match_index){
case Cmd_BackSlash: append_sc(out, "\\"); break;
case Cmd_Version: append_sc(out, VERSION); break;
case Cmd_CodeStyle:
case Cmd_BeginStyle:
{
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);
body_text = skip_chop_whitespace(body_text);
if (match_sc(body_text, "code")){
append_sc(out, "<span style='"HTML_CODE_STYLE"'>");
append_ss(out, body_text);
append_sc(out, "</span>");
}
}
}break;
case Cmd_EndStyle:
{
append_sc(out, "</span>");
}break;
// TODO(allen): upgrade this bs
case Cmd_DocLink:
{
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);
body_text = skip_chop_whitespace(body_text);
append_sc(out, "<a href='#");
append_ss(out, body_text);
append_sc(out, "_doc'>");
@ -619,6 +706,7 @@ write_enriched_text_html(String *out, Enriched_Text *text, Document_System *doc_
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);
body_text = skip_chop_whitespace(body_text);
html_render_section_header(out, body_text, null_string, section_counter);
++section_counter->counter[section_counter->nest_level];
@ -632,12 +720,18 @@ write_enriched_text_html(String *out, Enriched_Text *text, Document_System *doc_
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);
body_text = skip_chop_whitespace(body_text);
append_sc(out, "<a target='_blank'href='");
append_sc(out, "<a ");
if (body_text.str[0] == '!'){
append_sc(out, "target='_blank' ");
body_text.str++;
body_text.size--;
}
append_sc(out, "href='");
if (match_part_sc(body_text, "document:")){
String doc_name = substr_tail(body_text, sizeof("document:")-1);
Abstract_Document *doc_lookup = get_document_by_name(doc_system, doc_name);
Abstract_Item *doc_lookup = get_item_by_name(doc_system->doc_list, doc_name);
if (doc_lookup){
char space[256];
if (doc_get_link_string(doc_lookup, space, sizeof(space))){
@ -652,6 +746,7 @@ write_enriched_text_html(String *out, Enriched_Text *text, Document_System *doc_
append_ss(out, body_text);
}
append_sc(out, "'>");
}
}break;
@ -659,6 +754,45 @@ write_enriched_text_html(String *out, Enriched_Text *text, Document_System *doc_
{
append_sc(out, "</a>");
}break;
case Cmd_Image:
{
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);
body_text = skip_chop_whitespace(body_text);
int32_t pixel_height = 10;
int32_t pixel_width = HTML_WIDTH / 4;
Abstract_Item *img_lookup = 0;
if (match_part_sc(body_text, "image:")){
String img_name = substr_tail(body_text, sizeof("image:")-1);
img_lookup = get_item_by_name(doc_system->img_list, img_name);
if (img_lookup){
pixel_height = CEIL32(pixel_width*img_lookup->h_w_ratio);
append_sc(out, "<img src='");
char space[256];
if (img_get_link_string(img_lookup, space, sizeof(space))){
append_sc(out, space);
}
else{
NotImplemented;
}
append_sc(out, "' style='width: ");
append_int_to_str(out, pixel_width);
append_sc(out, "px; height: ");
append_int_to_str(out, pixel_height);
append_sc(out, "px;'>");
}
}
}
}break;
}
}
else{
@ -678,27 +812,27 @@ write_enriched_text_html(String *out, Enriched_Text *text, Document_System *doc_
}
append_sc(out, "</div>");
}
}
static void
print_item_in_list(String *out, String name, char *id_postfix){
static void
print_item_in_list(String *out, String name, char *id_postfix){
append_sc(out, "<li><a href='#");
append_ss(out, name);
append_sc(out, id_postfix);
append_sc(out, "'>");
append_ss(out, name);
append_sc(out, "</a></li>");
}
}
static void
init_used_links(Partition *part, Used_Links *used, int32_t count){
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){
static int32_t
try_to_use(Used_Links *used, String str){
int32_t result = 1;
int32_t index = 0;
@ -710,10 +844,10 @@ write_enriched_text_html(String *out, Enriched_Text *text, Document_System *doc_
}
return(result);
}
}
static void
print_struct_html(String *out, Item_Node *member, int32_t hide_children){
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;
@ -744,10 +878,10 @@ write_enriched_text_html(String *out, Enriched_Text *text, Document_System *doc_
else{
append_sc(out, ";<br>");
}
}
}
static void
print_function_html(String *out, Used_Links *used, String cpp_name, String ret, char *function_call_head, String name, Argument_Breakdown breakdown){
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, ' ');
@ -775,10 +909,10 @@ write_enriched_text_html(String *out, Enriched_Text *text, Document_System *doc_
append_sc(out, "</div>)");
}
}
}
static void
print_macro_html(String *out, String name, Argument_Breakdown breakdown){
static void
print_macro_html(String *out, String name, Argument_Breakdown breakdown){
append_sc (out, "#define ");
append_ss (out, name);
@ -804,22 +938,22 @@ write_enriched_text_html(String *out, Enriched_Text *text, Document_System *doc_
append_sc(out, ")</div>)");
}
}
}
enum Doc_Chunk_Type{
enum Doc_Chunk_Type{
DocChunk_PlainText,
DocChunk_CodeExample,
DocChunk_Count
};
};
static String doc_chunk_headers[] = {
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){
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;
@ -881,17 +1015,17 @@ write_enriched_text_html(String *out, Enriched_Text *text, Document_System *doc_
}
return(chunk);
}
}
static String
get_first_doc_chunk(String source, Doc_Chunk_Type *type){
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){
static void
print_doc_description(String *out, Partition *part, String src){
Doc_Chunk_Type type;
for (String chunk = get_first_doc_chunk(src, &type);
@ -951,10 +1085,10 @@ write_enriched_text_html(String *out, Enriched_Text *text, Document_System *doc_
}break;
}
}
}
}
static void
print_struct_docs(String *out, Partition *part, Item_Node *member){
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){
@ -980,10 +1114,10 @@ write_enriched_text_html(String *out, Enriched_Text *text, Document_System *doc_
append_sc(out, "</div>");
}
}
}
}
static void
print_see_also(String *out, Documentation *doc){
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);
@ -997,10 +1131,10 @@ write_enriched_text_html(String *out, Enriched_Text *text, Document_System *doc_
append_sc(out, "</a>"HTML_DOC_ITEM_CLOSE);
}
}
}
}
static void
print_function_docs(String *out, Partition *part, String name, String doc_string){
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);
@ -1048,10 +1182,10 @@ write_enriched_text_html(String *out, Enriched_Text *text, Document_System *doc_
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){
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;
@ -1284,10 +1418,10 @@ write_enriched_text_html(String *out, Enriched_Text *text, Document_System *doc_
append_sc(out, "</div><hr>");
end_temp_memory(temp);
}
}
static void
doc_item_head_html(String *out, Partition *part, Document_System *doc_system, Used_Links *used_links, Document_Item *item, Section_Counter *section_counter){
doc_item_head_html(String *out, Partition *part, Document_System *doc_system, Used_Links *used_links, Document_Item *item, Section_Counter *section_counter){
switch (item->type){
case Doc_Root:
{
@ -1348,12 +1482,15 @@ static void
"</head>\n"
"<body>"
"<div style='font-family:Arial; margin: 0 auto; "
"width: 800px; text-align: justify; line-height: 1.25;'>");
"width: ");
append_int_to_str(out, HTML_WIDTH);
append_sc(out, "px; text-align: justify; line-height: 1.25;'>");
if (item->section.show_title){
append_sc(out, "<h1 style='margin-top: 5mm; margin-bottom: 5mm;'>");
append_ss(out, item->section.name);
append_sc(out, "</h1>");
}
}break;
case Doc_Section:
@ -1494,7 +1631,9 @@ generate_item_html(String *out, Partition *part, Document_System *doc_system, Us
}
static void
generate_document_html(String *out, Partition *part, Document_System *doc_system, Abstract_Document *doc){
generate_document_html(String *out, Partition *part, Document_System *doc_system, Abstract_Item *doc){
assert(doc->root_item != 0);
Used_Links used_links = {0};
init_used_links(part, &used_links, 4000);

View File

@ -68,6 +68,52 @@ make_out_string(int32_t x){
return(str);
}
static void
do_file_copy(Partition *part, char *src_dir, char *src_file, char *dst_dir, char *dst_file){
char src[256];
char dst[256];
String str = {0};
int32_t success = 0;
str = make_fixed_width_string(src);
append_sc(&str, src_dir);
append_sc(&str, "/");
append_sc(&str, src_file);
terminate_with_null(&str);
str = make_fixed_width_string(dst);
append_sc(&str, dst_dir);
append_sc(&str, "/");
append_sc(&str, dst_file);
terminate_with_null(&str);
Temp_Memory temp = begin_temp_memory(part);
int32_t mem_size = partition_remaining(part);
void *mem = push_block(part, mem_size);
FILE *in = fopen(src, "rb");
if (in){
fseek(in, 0, SEEK_END);
int32_t file_size = ftell(in);
if (mem_size >= file_size){
fseek(in, 0, SEEK_SET);
fread(mem, 1, file_size, in);
FILE *out = fopen(dst, "wb");
if (out){
fwrite(mem, 1, file_size, out);
fclose(out);
success = 1;
}
}
fclose(in);
}
end_temp_memory(temp);
assert(success);
}
#endif
// BOTTOM

View File

@ -9,8 +9,12 @@
// TOP
#define STB_IMAGE_IMPLEMENTATION
#include "stb_image.h"
#include "4coder_version.h"
#include "internal_4coder_string.cpp"
#define FSTRING_IMPLEMENTATION
#include "4coder_string.h"
#include "4cpp_lexer.h"
#include <stdlib.h>
@ -19,6 +23,10 @@
#include <assert.h>
#include "4coder_mem.h"
#define CEIL32(x) ((int32_t) ( (x>0)?(x+1.f):(x) ))
#define FLOOR32(x) ((int32_t) ( (x>0)?(x):(x-1.f) ))
#include "meta_parser.cpp"
#include "out_context.cpp"
#include "abstract_document.cpp"
@ -31,43 +39,6 @@
// Meta Parse Rules
//
#define BACK_COLOR "#FAFAFA"
#define TEXT_COLOR "#0D0D0D"
#define CODE_BACK "#DFDFDF"
#define EXAMPLE_BACK "#EFEFDF"
#define POP_COLOR_1 "#309030"
#define POP_BACK_1 "#E0FFD0"
#define VISITED_LINK "#A0C050"
#define POP_COLOR_2 "#005000"
#define CODE_STYLE "font-family: \"Courier New\", Courier, monospace; text-align: left;"
#define CODE_BLOCK_STYLE(back) \
"margin-top: 3mm; margin-bottom: 3mm; font-size: .95em; " \
"background: "back"; padding: 0.25em;"
#define DESCRIPT_SECTION_STYLE CODE_BLOCK_STYLE(CODE_BACK)
#define EXAMPLE_CODE_STYLE CODE_BLOCK_STYLE(EXAMPLE_BACK)
#define DOC_HEAD_OPEN "<div style='margin-top: 3mm; margin-bottom: 3mm; color: "POP_COLOR_1";'><b><i>"
#define DOC_HEAD_CLOSE "</i></b></div>"
#define DOC_ITEM_HEAD_STYLE "font-weight: 600;"
#define DOC_ITEM_HEAD_INL_OPEN "<span style='"DOC_ITEM_HEAD_STYLE"'>"
#define DOC_ITEM_HEAD_INL_CLOSE "</span>"
#define DOC_ITEM_HEAD_OPEN "<div style='"DOC_ITEM_HEAD_STYLE"'>"
#define DOC_ITEM_HEAD_CLOSE "</div>"
#define DOC_ITEM_OPEN "<div style='margin-left: 5mm; margin-right: 5mm;'>"
#define DOC_ITEM_CLOSE "</div>"
#define EXAMPLE_CODE_OPEN "<div style='"CODE_STYLE EXAMPLE_CODE_STYLE"'>"
#define EXAMPLE_CODE_CLOSE "</div>"
static void
print_function_body_code(String *out, Parse_Context *context, int32_t start){
String pstr = {0}, lexeme = {0};
@ -152,10 +123,12 @@ assert_files_are_equal(char *directory, char *filename1, char *filename2){
}
static void
do_html_output(Document_System *doc_system, Partition *part, char *dst_directory, Abstract_Document *doc){
do_html_output(Document_System *doc_system, Partition *part, char *dst_directory, Abstract_Item *doc){
// NOTE(allen): Output
Temp_Memory temp = begin_temp_memory(part);
String out = str_alloc(part, 10 << 20);
assert(out.str);
Out_Context context = {0};
set_context_directory(&context, dst_directory);
@ -167,25 +140,27 @@ assert_files_are_equal(char *directory, char *filename1, char *filename2){
end_file_out(context);
}
else{
fprintf(stderr, "Failed to open %s", space);
fprintf(stderr, "Failed to open %s\n", space);
}
}
end_temp_memory(temp);
}
static Abstract_Document*
static Abstract_Item*
generate_homepage(Document_System *doc_system, Partition *part, char *src_directory){
Enriched_Text *home = push_struct(part, Enriched_Text);
*home = load_enriched_text(part, src_directory, "home.txt");
Abstract_Document *doc = begin_document_description(doc_system, "4coder Home", "home");
Abstract_Item *doc = begin_document_description(doc_system, "4coder Home", "home", 0);
add_enriched_text(doc, home);
end_document_description(doc);
return(doc);
}
static Abstract_Document*
// TODO(allen): replace the documentation declaration system with a straight up enriched text system
static Abstract_Item*
generate_4coder_docs(Document_System *doc_system, Partition *part, char *code_directory, char *src_directory){
static Meta_Keywords meta_keywords[] = {
{make_lit_string("API_EXPORT") , Item_Function } ,
@ -252,7 +227,7 @@ assert_files_are_equal(char *directory, char *filename1, char *filename2){
*lexer_introduction = load_enriched_text(part, src_directory, "lexer_introduction.txt");
// NOTE(allen): Put together the abstract document
Abstract_Document *doc = begin_document_description(doc_system, "4coder API Docs", "custom_docs");
Abstract_Item *doc = begin_document_description(doc_system, "4coder API Docs", "custom_docs", 1);
add_table_of_contents(doc);
@ -320,24 +295,24 @@ assert_files_are_equal(char *directory, char *filename1, char *filename2){
return(doc);
}
static Abstract_Document*
static Abstract_Item*
generate_feature_list(Document_System *doc_system, Partition *part, char *src_directory){
Enriched_Text *feature_list = push_struct(part, Enriched_Text);
*feature_list = load_enriched_text(part, src_directory, "feature_list.txt");
Abstract_Document *doc = begin_document_description(doc_system, "4coder Feature List", "features");
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_Document*
static Abstract_Item*
generate_roadmap(Document_System *doc_system, Partition *part, char *src_directory){
Enriched_Text *roadmap = push_struct(part, Enriched_Text);
*roadmap = load_enriched_text(part, src_directory, "roadmap.txt");
Abstract_Document *doc = begin_document_description(doc_system, "4coder Roadmap", "roadmap");
Abstract_Item *doc = begin_document_description(doc_system, "4coder Roadmap", "roadmap", 0);
add_enriched_text(doc, roadmap);
end_document_description(doc);
@ -345,7 +320,7 @@ assert_files_are_equal(char *directory, char *filename1, char *filename2){
}
static void
generate_site(char *code_directory, char *src_directory, char *dst_directory){
generate_site(char *code_directory, char *asset_directory, char *src_directory, char *dst_directory){
int32_t size = (512 << 20);
void *mem = malloc(size);
memset(mem, 0, size);
@ -354,22 +329,33 @@ generate_site(char *code_directory, char *src_directory, char *dst_directory){
Partition *part = &part_;
Document_System doc_system = create_document_system(part);
add_image_description(&doc_system, asset_directory, "4coder_green.png", "4coder_logo.png", "4coder_logo");
generate_homepage(&doc_system, part, src_directory);
generate_4coder_docs(&doc_system, part, code_directory, src_directory);
generate_feature_list(&doc_system, part, src_directory);
generate_roadmap(&doc_system, part, src_directory);
for (Document_Node *node = doc_system.head;
for (Basic_Node *node = doc_system.img_list.head;
node != 0;
node = node->next){
do_html_output(&doc_system, part, dst_directory, &node->doc);
Abstract_Item *img = NodeGetData(node, Abstract_Item);
assert(img->item_type == ItemType_Image);
do_file_copy(part, asset_directory, img->source_file, dst_directory, img->out_file);
}
for (Basic_Node *node = doc_system.doc_list.head;
node != 0;
node = node->next){
Abstract_Item *doc = NodeGetData(node, Abstract_Item);
assert(doc->item_type == ItemType_Document);
do_html_output(&doc_system, part, dst_directory, doc);
}
}
int main(int argc, char **argv){
if (argc == 4){
generate_site(argv[1], argv[2], argv[3]);
if (argc == 5){
generate_site(argv[1], argv[2], argv[3], argv[4]);
}
}

View File

@ -1,5 +1,7 @@
This page provides a list of 4coder features for anyone trying to determine whether 4coder is the right editor for them. If a feature is missing here you should check out the \BEGIN_LINK{document:roadmap} roadmap \END_LINK page to see what is coming in the future. If the feature you want is on neither, you should contact \CODE_STYLE{editor@4coder.net}. Some features that are already in 4coder might be missing from this list, if you want to be sure you should contact \CODE_STYLE{editor@4coder.net}.
\IMAGE{image:4coder_logo}
This page provides a list of 4coder features for anyone trying to determine whether 4coder is the right editor for them. If a feature is missing here you should check out the \BEGIN_LINK{document:roadmap} roadmap \END_LINK page to see what is coming in the future. If the feature you want is on neither, you should contact \BEGIN_STYLE{code} editor@4coder.net \END_STYLE. Some features that are already in 4coder might be missing from this list, if you want to be sure you should contact \BEGIN_STYLE{code} editor@4coder.net \END_STYLE.
\SECTION{Text Editing}
\BEGIN_LIST
@ -46,7 +48,7 @@ This page provides a list of 4coder features for anyone trying to determine whet
4coder's current setup and editing paradigm is modeled after emacs, so it is very natural to transition to 4coder from emacs for many users. 4coder customization is quite different from emacs though, so anyone who wants to keep their current keybinds will have to take the time to rewrite the keybinding code. Once the initial transition is done, any user who prefers C++ to Lisp will have a much better time in their 4coder configuration code.
\SECTION{Transition From Vim}
For vim users the built-in editing paradigm will not line up with editing habits. Thanks to the open customization model, a vim paradigm and default vim key bindings can be used in 4coder. The vim customization \BEGIN_LINK{https://github.com/Chronister/4vim} here \END_LINK is an early example of this with many basic vim systems up and running.
For vim users the built-in editing paradigm will not line up with editing habits. Thanks to the open customization model, a vim paradigm and default vim key bindings can be used in 4coder. The vim customization \BEGIN_LINK{!https://github.com/Chronister/4vim} here \END_LINK is an early example of this with many basic vim systems up and running.
Right now 4coder is admittedly not great for vim users, but the transition path exists so keep your eyes on 4coder as better vim emulation is still on the way.

View File

@ -1,7 +1,9 @@
\IMAGE{image:4coder_logo}
4coder is a code editor that first and foremost targets the needs C/C++ developers so that developers in that space can be as efficient as possible. Here you can learn about the features of 4coder, how to get started with 4coder, and how to get the absolute most out of 4cocer.
If you cannot find what you are looking for please contact \CODE_STYLE{editor@4coder.net} with questions.
If you cannot find what you are looking for please contact \BEGIN_STYLE{code} editor@4coder.net \END_STYLE with questions.
\BEGIN_LINK{document:features} The official 4coder feature list \END_LINK

View File

@ -1,4 +1,4 @@
This is the documentation for \VERSION. The documentation is still under construction so some of the links are linking to sections that have not been written yet. What is here should be correct and I suspect useful even without some of the other sections.
If you have questions or discover errors please contact \CODE_STYLE{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 \CODE_STYLE{4coder.handmade.network}.
If you have questions or discover errors please contact \BEGIN_STYLE{code} editor@4coder.net \END_STYLE or to get help from members of the 4coder and handmade network community you can post on the 4coder forums hosted at \BEGIN_STYLE{code} 4coder.handmade.network \END_STYLE.

View File

@ -1,5 +1,7 @@
This page provides an outline of planned 4coder features roughly sorted by priority. If a feature is missing here it may be on the \BEGIN_LINK{document:features} features \END_LINK page which means it is already in 4coder. If a feature is missing from both lists and you would like to recommend it for consideration, send your recommendation to \CODE_STYLE{editor@4coder.net}. If you believe the priority sorting of the items should be tweaked because certain items are more important than others, that recommendation can also be sent to the same 4coder email as any other recommendation.
\IMAGE{image:4coder_logo}
This page provides an outline of planned 4coder features roughly sorted by priority. If a feature is missing here it may be on the \BEGIN_LINK{document:features} features \END_LINK page which means it is already in 4coder. If a feature is missing from both lists and you would like to recommend it for consideration, send your recommendation to \BEGIN_STYLE{code} editor@4coder.net \END_STYLE. If you believe the priority sorting of the items should be tweaked because certain items are more important than others, that recommendation can also be sent to the same 4coder email as any other recommendation.
Each section represents one major type of todo item, within each section the items are roughly sorted by priority with respect to other items in that section. The sections are also sorted by a rough priority, but more than one section might receive attention at a time.