diff --git a/4ed_api_parser.cpp b/4ed_api_parser.cpp index f9e4bd08..87128fc1 100644 --- a/4ed_api_parser.cpp +++ b/4ed_api_parser.cpp @@ -220,6 +220,7 @@ api_parse_source__structure(Arena *arena, String_Const_u8 source_name, String_Co String_Const_u8 name = {}; List_String_Const_u8 member_list = {}; Token *token = api_parse__token_pos(token_it); + (void)token; if (api_parse__match_identifier(token_it, source, &name)){ if (api_parse__match(token_it, TokenCppKind_Semicolon)){ result = true; @@ -254,6 +255,7 @@ api_parse_source__structure(Arena *arena, String_Const_u8 source_name, String_Co } if (result){ Token *token_end = api_parse__token_pos(token_it); + (void)token_end; // TODO(allen): String_Const_u8 definition = {}; String_Const_u8 location = api_parse_location(arena, source_name, source, name.str); diff --git a/site/4ed_site_render_main.cpp b/site/4ed_site_render_main.cpp index fe4a5181..0371b0ad 100644 --- a/site/4ed_site_render_main.cpp +++ b/site/4ed_site_render_main.cpp @@ -38,6 +38,7 @@ char html_header[] = R"HTMLFOO( + %.*s @@ -426,6 +442,9 @@ render_doc_cluster_to_html(Arena *scratch, Doc_Cluster *cluster, fprintf(file_index, "
\n"); fprintf(file_index, "

%.*s Index

\n", string_expand(cluster->title)); fprintf(file_index, "
\n"); + fprintf(file_index, ""); + fprintf(file_index, "
\n"); Doc_Page **ptrs = push_array(scratch, Doc_Page*, cluster->page_count); i32 counter = 0; @@ -438,14 +457,17 @@ render_doc_cluster_to_html(Arena *scratch, Doc_Cluster *cluster, sort_doc_page_array(ptrs, 0, counter); + fprintf(file_index, "
"); + + fprintf(file_index, "\n"); + fprintf(file_index, "
\n"); fprintf(file_index, html_footer); } diff --git a/site/search.js b/site/search.js new file mode 100644 index 00000000..60cefa52 --- /dev/null +++ b/site/search.js @@ -0,0 +1,71 @@ +const menu_id = "docs_menu"; +const filter_id = "search_input"; + +function StringMatch4coderFuzzy(a, b) +{ + let match = true; + let b_upper = b.toUpperCase(); + let a_substrings = a.toUpperCase().split(/[ _*]+/); + let minimum_index = 0; + + for(let i = 0; i < a_substrings.length; ++i) + { + if(a_substrings[i].length > 0) + { + let index_of_substring = b_upper.indexOf(a_substrings[i], minimum_index); + if(index_of_substring < 0 || index_of_substring < minimum_index) + { + match = false; + break; + } + minimum_index = index_of_substring + a_substrings[i].length - 1; + } + } + + return match; +} + +function SearchKeyDown(event) +{ + if(event.keyCode == 13) + { + let ul = document.getElementById(menu_id); + let li = ul.getElementsByTagName("li"); + + for (let i = 0; i < li.length; i++) + { + if(li[i].style.display == "") + { + window.location.href = li[i].getElementsByTagName("a")[0]; + break; + } + } + } +} + +function SearchKeyUp(event) +{ + let ul = document.getElementById(menu_id); + let li = ul.getElementsByTagName("li"); + let input = document.getElementById(filter_id); + let filter = input.value.toUpperCase(); + for(let i = 0; i < li.length; i++) + { + if(filter.length > 0) + { + let a = li[i].getElementsByTagName("a")[0]; + if(StringMatch4coderFuzzy(filter, a.innerHTML)) + { + li[i].style.display = ""; + } + else + { + li[i].style.display = "none"; + } + } + else + { + li[i].style.display = ""; + } + } +} \ No newline at end of file