class MarkdownExec::MDoc

def collect_recursively_required_code(anyname:, block_source:, label_body: true, label_format_above: nil,

Returns:
  • (Array) - An array of strings containing the collected code blocks.

Parameters:
  • name (String) -- The name of the code block to start the collection from.
def collect_recursively_required_code(anyname:, block_source:, label_body: true, label_format_above: nil,
                                      label_format_below: nil)
  block_search = collect_block_dependencies(anyname: anyname)
  if block_search[:blocks]
    blocks = collect_wrapped_blocks(block_search[:blocks])
    # &bc 'blocks.count:',blocks.count
    block_search.merge(
      { block_names: blocks.map { |block| block[:nickname] || block[:oname] },
        code: blocks.map do |fcb|
          if fcb[:cann]
            collect_block_code_cann(fcb)
          elsif fcb[:stdout]
            collect_block_code_stdout(fcb)
          elsif [BlockType::LINK, BlockType::OPTS,
                 BlockType::VARS].include? fcb[:shell]
            nil
          elsif fcb[:shell] == BlockType::PORT
            collect_block_code_shell(fcb)
          elsif label_body
            block_name_for_bash_comment = (fcb[:nickname] || fcb[:oname]).gsub(/\s+/, '_')
            [label_format_above && format(label_format_above,
                                          block_source.merge({ block_name: block_name_for_bash_comment }))] +
             fcb[:body] +
             [label_format_below && format(label_format_below,
                                           block_source.merge({ block_name: block_name_for_bash_comment }))]
          else # raw body
            fcb[:body]
          end
        end.compact.flatten(1).compact }
    )
  else
    block_search.merge({ block_names: [], code: [] })
  end
rescue StandardError
  error_handler('collect_recursively_required_code')
end