comparison scripts/help/help.m @ 8630:540165304f00

Allow displaying 'Contents.m' files.
author Soren Hauberg <hauberg@gmail.com>
date Sun, 25 Jan 2009 17:25:15 +0100
parents f134925a1cfa
children 52956d669506
comparison
equal deleted inserted replaced
8629:f07730ed5613 8630:540165304f00
59 case "texinfo" 59 case "texinfo"
60 [text, status] = makeinfo (text, "plain text"); 60 [text, status] = makeinfo (text, "plain text");
61 case "html" 61 case "html"
62 [text, status] = strip_html_tags (text); 62 [text, status] = strip_html_tags (text);
63 case "not found" 63 case "not found"
64 error ("help: `%s' not found\n", name); 64 [text, status] = do_contents (name);
65 if (status != 0)
66 error ("help: `%s' not found\n", name);
67 endif
65 otherwise 68 otherwise
66 error ("help: internal error: unsupported help text format: '%s'\n", format); 69 error ("help: internal error: unsupported help text format: '%s'\n", format);
67 endswitch 70 endswitch
68 71
69 ## Print text 72 ## Print text
78 else 81 else
79 error ("help: invalid input\n"); 82 error ("help: invalid input\n");
80 endif 83 endif
81 endfunction 84 endfunction
82 85
86 function [text, status] = do_contents (name)
87 text = "";
88 status = 1;
89
90 d = find_dir_in_path (name);
91 if (!isempty (d))
92 p = path ();
93 unwind_protect
94 ## Only include 'd' in the path, and then get the help text of 'Contents'
95 path (d);
96 [text, format] = get_help_text ("Contents");
97
98 ## Take action depending on help text format
99 switch (lower (format))
100 case "plain text"
101 status = 0;
102 case "texinfo"
103 [text, status] = makeinfo (text, "plain text");
104 case "html"
105 [text, status] = strip_html_tags (text);
106 endswitch
107 unwind_protect_cleanup
108 ## Restore path
109 path (p);
110 end_unwind_protect
111 endif
112 endfunction
113