Class: Mdtoc::Node::DirNode
- Inherits:
-
Mdtoc::Node
- Object
- Mdtoc::Node
- Mdtoc::Node::DirNode
- Defined in:
- lib/mdtoc/node.rb
Instance Method Summary collapse
Methods inherited from Mdtoc::Node
for_path, #initialize, #label, render
Constructor Details
This class inherits a constructor from Mdtoc::Node
Instance Method Details
#headers ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 |
# 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 |