class Mdtoc::Node::DirNode
Public Instance Methods
headers()
click to toggle source
# File lib/mdtoc/node.rb, line 51 def headers readme_path = T.let(nil, T.nilable(String)) child_headers = Dir .each_child(@path) .reject { |path| readme_path = File.join(@path, path) if path.casecmp?('readme.md') } .sort! .flat_map { |path| Node.for_path(File.join(@path, path), @depth + 1).headers } return child_headers unless readme_path # Include the headers from the README at the beginning. readme_headers = FileNode.new(readme_path, @depth).headers readme_headers + child_headers end