Mercurial > octave
comparison libinterp/corefcn/help.cc @ 28514:fab862fedf85 stable
allow help to find docstrings for classdef classes and methods (bug #43047)
* help.cc (help_system::raw_help_from_symbol_table): Also find
docstrings from classdef meta objects (both classes and methods).
* cdef-class.h, cdef-class.cc (cdef_class::cdef_class_rep,
cdef_class): Store docstring for class and provide access.
* ov-classdef.h, ov-classdef.cc (octave_classdef_meta::doc_string):
New function to provide access to doc strings for classdef objects
and methods.
* ov-fcn.h (octave_function::doc_string): Now virtual. New argument
for method name.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 29 May 2020 10:57:04 -0400 |
parents | 71c34141cc2d |
children | 70d155283f33 68e6e6f083f3 |
comparison
equal
deleted
inserted
replaced
28513:59c6625e0180 | 28514:fab862fedf85 |
---|---|
521 | 521 |
522 bool help_system::raw_help_from_symbol_table (const std::string& nm, | 522 bool help_system::raw_help_from_symbol_table (const std::string& nm, |
523 std::string& h, std::string& w, | 523 std::string& h, std::string& w, |
524 bool& symbol_found) const | 524 bool& symbol_found) const |
525 { | 525 { |
526 bool retval = false; | 526 std::string meth_nm; |
527 | 527 |
528 symbol_table& symtab = m_interpreter.get_symbol_table (); | 528 symbol_table& symtab = m_interpreter.get_symbol_table (); |
529 | 529 |
530 octave_value val = symtab.find_function (nm); | 530 octave_value val = symtab.find_function (nm); |
531 | |
532 if (! val.is_defined ()) | |
533 { | |
534 size_t pos = nm.rfind ('.'); | |
535 | |
536 if (pos != std::string::npos) | |
537 { | |
538 meth_nm = nm.substr (pos+1); | |
539 | |
540 val = symtab.find_function (nm.substr (0, pos)); | |
541 } | |
542 } | |
531 | 543 |
532 if (val.is_defined ()) | 544 if (val.is_defined ()) |
533 { | 545 { |
534 octave_function *fcn = val.function_value (); | 546 octave_function *fcn = val.function_value (); |
535 | 547 |
536 if (fcn) | 548 if (fcn) |
537 { | 549 { |
550 // FCN may actually be a classdef_meta object. | |
551 | |
538 symbol_found = true; | 552 symbol_found = true; |
539 | 553 |
540 h = fcn->doc_string (); | 554 h = fcn->doc_string (meth_nm); |
541 | |
542 retval = true; | |
543 | 555 |
544 w = fcn->fcn_file_name (); | 556 w = fcn->fcn_file_name (); |
545 | 557 |
546 if (w.empty ()) | 558 if (w.empty ()) |
547 w = fcn->is_user_function () ? "command-line function" | 559 w = fcn->is_user_function () ? "command-line function" |
548 : "built-in function"; | 560 : "built-in function"; |
561 | |
562 return true; | |
549 } | 563 } |
550 } | 564 } |
551 | 565 |
552 return retval; | 566 return false; |
553 } | 567 } |
554 | 568 |
555 bool help_system::raw_help_from_file (const std::string& nm, | 569 bool help_system::raw_help_from_file (const std::string& nm, |
556 std::string& h, std::string& file, | 570 std::string& h, std::string& file, |
557 bool& symbol_found) const | 571 bool& symbol_found) const |