Class: Mdtoc::Node::DirNode
- Inherits:
-
Node
- Object
- Node
- Mdtoc::Node::DirNode
- Defined in:
- lib/mdtoc/node.rb
Instance Method Summary collapse
Instance Method Details
#headers ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/mdtoc/node.rb', line 52 def headers readme_path = T.let(nil, T.nilable(Pathname)) children = @path.children.reject do |child| if child.basename.to_s.casecmp?('readme.md') readme_path = child true else false end end child_headers = children.sort.flat_map do |child| Node.for_path(child.to_s, @depth + 1).headers end return child_headers unless readme_path # Include the headers from the README at the beginning. readme_headers = FileNode.new(T.must(readme_path), @depth).headers readme_headers + child_headers end |