Mercurial > octave
diff libinterp/parse-tree/pt-classdef.h @ 32892:80d3a6abfc4d stable
improve capture of classdef and classdef method doc strings
* lex.h, lex.ll (lexical_feedback::m_classdef_help_text): New data member.
(lexical_feedback::lexical_feedback): Initialize it.
(lexical_feedback::reset): Reset it to the empty string.
* parse.h, oct-parse.yy (function): Also capture comments that appear
just before the function body.
(base_parser::make_function): New argument ot accept these comments.
Maybe capture comments inside a classdef ctor or method as help text.
(CLASSDEF): Transfer lexer.m_help_text to lexer.m_classdef_help.
(classdef): Also capture comments that appear just before the class
body and use the first block of them as classdef help if it is not
already set.
(base_parser::make_classdef): Pass m_lexer.m_classdef_help_text to
tree_classdef ctor then set m_lexer.m_classdef_help_text the empty string.
(properties_beg, methods_beg, events_beg, enumeration_beg):
Set lexer.m_help_text to the empty string.
* pt-classdef.h (tree_classdef::m_help_text): New data member.
(tree_classdef::tree_classdef): Initialize it.
(tree_classdef::doc_string): Return it instead of
m_element_list->doc_string ().
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 31 Jan 2024 23:19:10 -0500 |
parents | 2e484f9f1f18 |
children | 0b5f3219b650 |
line wrap: on
line diff
--- a/libinterp/parse-tree/pt-classdef.h Wed Jan 31 17:28:04 2024 -0500 +++ b/libinterp/parse-tree/pt-classdef.h Wed Jan 31 23:19:10 2024 -0500 @@ -679,13 +679,14 @@ { public: - tree_classdef (const symbol_scope& scope, + tree_classdef (const symbol_scope& scope, const std::string& help_text, tree_classdef_attribute_list *a, tree_identifier *i, tree_classdef_superclass_list *sc, tree_classdef_body *b, comment_list *lc, comment_list *tc, const std::string& pn = "", const std::string& fn = "", int l = -1, int c = -1) - : tree_command (l, c), m_scope (scope), m_attr_list (a), m_id (i), + : tree_command (l, c), m_scope (scope), m_help_text (help_text), + m_attr_list (a), m_id (i), m_supclass_list (sc), m_element_list (b), m_lead_comm (lc), m_trail_comm (tc), m_pack_name (pn), m_file_name (fn) { } @@ -726,7 +727,7 @@ std::string doc_string () const { - return m_element_list ? m_element_list->doc_string () : ""; + return m_help_text; } void accept (tree_walker& tw) @@ -742,6 +743,8 @@ symbol_scope m_scope; + std::string m_help_text; + tree_classdef_attribute_list *m_attr_list; tree_identifier *m_id;