Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RakuAST: add Doc::Declarator.paragraphs method
This basically adds support for Markup to declarator docs. The reasons for adding a separate .paragraphs method are: - wanting to be able to have markup extend over a multiple lines - making leading / trailing to be markup aware is a bit troublesome because they can each be added per-line (and trailing declarator docs are added that way in the Raku grammar). This meant that either any addition would need to re-stringify what it got already, add the new line, and then look for markup again. Yuck. The alternative would be to run the check for markup at CHECK time. However, it turns out that the CHECK time logic can actually be called multiple times when a separate .AST step is taken (once for the .AST, and once for the subsequent .EVAL on it). So it felt better to keep the current leading / trailing semantics and create an opt-in method 'paragraphs' that returns a 2-element list with the leading (first element) and trailing (second element) declarator doc parsed through the markup logic. And since this is completely opt-in, if not used, will not cause any extra CPU to be used. The elements are either a string (if no markup was found) or a RakuAST::Doc::Paragraph object. Producing the AST for all declarator docs from a given AST is: $ast.map: { .WHY andthen .paragraphs if $_ ~~ RakuAST::Doc::DeclaratorTarget }
- Loading branch information