Mercurial > hg > octave-lyh
comparison src/help.cc @ 9806:8e345f2fe4d6
improved support for Contents.m files
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 11 Nov 2009 15:11:14 -0500 |
parents | 2cc47338e427 |
children | 2cd940306a06 |
comparison
equal
deleted
inserted
replaced
9805:bb70d16cca3b | 9806:8e345f2fe4d6 |
---|---|
703 | 703 |
704 return h; | 704 return h; |
705 } | 705 } |
706 | 706 |
707 static void | 707 static void |
708 do_get_help_text (const std::string name, std::string& text, | 708 do_get_help_text (const std::string& name, std::string& text, |
709 std::string& format) | 709 std::string& format) |
710 { | 710 { |
711 bool symbol_found = false; | 711 bool symbol_found = false; |
712 text = raw_help (name, symbol_found); | 712 text = raw_help (name, symbol_found); |
713 | 713 |
772 print_usage (); | 772 print_usage (); |
773 | 773 |
774 return retval; | 774 return retval; |
775 } | 775 } |
776 | 776 |
777 static void | |
778 do_get_help_text_from_file (const std::string& fname, std::string& text, | |
779 std::string& format) | |
780 { | |
781 bool symbol_found = false; | |
782 | |
783 std::string f; | |
784 | |
785 raw_help_from_file (fname, text, f, symbol_found); | |
786 | |
787 format = "Not found"; | |
788 if (symbol_found) | |
789 { | |
790 size_t idx = -1; | |
791 if (text.empty ()) | |
792 { | |
793 format = "Not documented"; | |
794 } | |
795 else if (looks_like_texinfo (text, idx)) | |
796 { | |
797 format = "texinfo"; | |
798 text.erase (0, idx); | |
799 } | |
800 else if (looks_like_html (text)) | |
801 { | |
802 format = "html"; | |
803 } | |
804 else | |
805 { | |
806 format = "plain text"; | |
807 } | |
808 } | |
809 } | |
810 | |
811 DEFUN (get_help_text_from_file, args, , | |
812 "-*- texinfo -*-\n\ | |
813 @deftypefn {Loadable Function} {[@var{text}, @var{format}] =} get_help_text_from_file (@var{fname})\n\ | |
814 Returns the help text from the given file.\n\ | |
815 \n\ | |
816 This function returns the raw help text @var{text} and an indication of\n\ | |
817 its format for the function @var{name}. The format indication @var{format}\n\ | |
818 is a string that can be either @t{\"texinfo\"}, @t{\"html\"}, or\n\ | |
819 @t{\"plain text\"}.\n\ | |
820 \n\ | |
821 To convert the help text to other formats, use the @code{makeinfo} function.\n\ | |
822 \n\ | |
823 @seealso{makeinfo}\n\ | |
824 @end deftypefn") | |
825 { | |
826 octave_value_list retval; | |
827 | |
828 if (args.length () == 1) | |
829 { | |
830 const std::string fname = args(0).string_value (); | |
831 | |
832 if (! error_state) | |
833 { | |
834 std::string text; | |
835 std::string format; | |
836 | |
837 do_get_help_text_from_file (fname, text, format); | |
838 | |
839 retval(1) = format; | |
840 retval(0) = text; | |
841 } | |
842 else | |
843 error ("get_help_text_from_file: invalid input"); | |
844 } | |
845 else | |
846 print_usage (); | |
847 | |
848 return retval; | |
849 } | |
850 | |
777 // Return a cell array of strings containing the names of all | 851 // Return a cell array of strings containing the names of all |
778 // operators. | 852 // operators. |
779 | 853 |
780 DEFUN (__operators__, , , | 854 DEFUN (__operators__, , , |
781 "-*- texinfo -*-\n\ | 855 "-*- texinfo -*-\n\ |