{= include("docs.util"); start_docs_page(docs.technical_manual.page_titles.search); volatile.search_matches = 0; volatile.search_results = ""; # This searches a node's value for a particular phrase. # A page matches if it contains any of the words in the phrase. subroutine(search_node(string text, string phrase, string pagelink, string pagetype), ( #echo("text: " . text); string remainder = phrase; string keyword; while (matches_regular_expression(remainder, '^ *([^ ]+)(.*)$')) ( keyword = $1; remainder = $2; if (contains(lowercase(text), lowercase(keyword))) then ( volatile.search_results .= "" . pagetype . "  " . pagelink . "\n"; volatile.search_matches++; return; ); ); )); # search_node() string search_phrase = volatile.searchdocstext; # Search the technical manual node docs_chapter_node; foreach docs_chapter_node "docs.technical_manual" ( if (matches_regular_expression(docs_chapter_node, "^docs\..*\.technical_manual\.page_titles")) then next; string chaptername = node_name(docs_chapter_node); debug_message("chaptername: " . chaptername . "\n"); string preexpand_chaptertest = $(docs_chapter_node); string chaptertext = expand(preexpand_chaptertest); search_node(chaptertext, search_phrase, docs_chapter_link(chaptername), docs.variables.search.page_type.chapter); ); # for tech manual node # Search the user guide node docs_user_chapter_node; foreach docs_user_chapter_node "docs.user_guide" ( if (matches_regular_expression(docs_user_chapter_node, "^docs\..*\.user_guide\.page_titles")) then next; string chaptername = node_name(docs_user_chapter_node); debug_message("chaptername: " . chaptername . "\n"); string preexpand_chaptertest = $(docs_user_chapter_node); string chaptertext = expand(preexpand_chaptertest); search_node(chaptertext, search_phrase, docs_user_chapter_link(chaptername), docs.variables.search.page_type.u_chapter); ); # for user guide node # Search the FAQ node faqnode; foreach faqnode "docs.faq.db" ( string faqname = node_name(faqnode); debug_message("faqname: " . faqname . "\n"); string faqtext = node_value(subnode_by_name(faqnode, "label")) . "\n" . expand(node_value(subnode_by_name(faqnode, "question"))) . "\n" . expand(node_value(subnode_by_name(faqnode, "short_answer"))) . "\n" . expand(node_value(subnode_by_name(faqnode, "long_answer"))) . "\n"; search_node(faqtext, search_phrase, docs_faq_link(faqname), docs.variables.search.page_type.faq); debug_message("done with " . faqname . "\n"); ); subroutine(search_options(string thisnode, string search_phrase), ( debug_message("thisnode: " . thisnode . "\n"); # Search all the subnodes string option_info_name; foreach option_info_name thisnode ( # Get the name without options_info. string trimmed_option_name = remove_prefix(option_info_name, "option_info."); debug_message("trimmed_option_name: " . trimmed_option_name . "\n"); # If this is a group, display it recursively if (!?("lang_options." . trimmed_option_name . ".label") or ?("lang_options." . trimmed_option_name . ".option_group")) then ( debug_message("searching option_info_name=" . option_info_name . "\n"); search_options(option_info_name, search_phrase); ) # Otherwise, display this option else ( debug_message("thisnode option: " . thisnode . "\n"); # Compute the command line option name and the full option name string full_option_name = trimmed_option_name; string command_line_option_name = full_option_name; if (starts_with(full_option_name, "profile.")) then ( command_line_option_name = remove_prefix(full_option_name, "profile."); full_option_name = "default_profile." . command_line_option_name; ); string label_node = "lang_options." . trimmed_option_name . ".label"; debug_message("label_node: " . label_node . "\n"); string label = expand($(label_node)); string short_description_node = "lang_options." . trimmed_option_name . ".short_description"; string short_description = expand($(short_description_node)); string long_description_node = "lang_options." . trimmed_option_name . ".long_description"; string long_description = expand($(long_description_node)); string optiontext = label . "\n" . short_description . "\n" . long_description; # If there is shortcut, search that too if (option_info_name?{"shortcut"}) then ( optiontext .= "\n" . @option_info_name{"shortcut"}; ); search_node(optiontext, search_phrase, docs_option_link(full_option_name), docs.variables.search.page_type.option); ); # if not group ); # for options )); # search_options() # Search the options search_options("option_info.command_line", search_phrase); search_options("option_info.preferences", search_phrase); search_options("option_info.profile", search_phrase); # If there were results, display them if (length(volatile.search_results) > 0) then ( "

$docs.variables.search.pages_matched

\n"; "\n"; volatile.search_results; "
\n"; ) else ( "

$docs.variables.search.no_pages_matched

\n"; ); end_docs_page(); volatile.docs_page_title = docs.technical_manual.page_titles.search; =}