fix: include top-level modules in hierarchy and exclude non-html

main
tydeu 2022-07-23 22:00:48 -04:00
parent 5e78890ec0
commit 2cc851aaf1
1 changed files with 6 additions and 3 deletions

View File

@ -99,21 +99,24 @@ def baseDirBlackList : HashSet String :=
"style.css" "style.css"
] ]
partial def fromDirectoryAux (dir : System.FilePath) (previous : Name) : IO (Array Name) := do partial def fromDirectoryAux (dir : System.FilePath) (previous : Name) : IO (Array Name) := do
let mut children := #[] let mut children := #[]
for entry in ←System.FilePath.readDir dir do for entry in ←System.FilePath.readDir dir do
if (←entry.path.isDir) then if (←entry.path.isDir) then
children := children ++ (←fromDirectoryAux entry.path (.str previous entry.fileName)) children := children ++ (←fromDirectoryAux entry.path (.str previous entry.fileName))
else else if entry.path.extension = some "html" then
children := children.push <| .str previous (entry.fileName.dropRight ".html".length) children := children.push <| .str previous (entry.fileName.dropRight ".html".length)
pure children pure children
def fromDirectory (dir : System.FilePath) : IO Hierarchy := do def fromDirectory (dir : System.FilePath) : IO Hierarchy := do
let mut children := #[] let mut children := #[]
for entry in ←System.FilePath.readDir dir do for entry in ←System.FilePath.readDir dir do
if !baseDirBlackList.contains entry.fileName && (←entry.path.isDir) then if baseDirBlackList.contains entry.fileName then
continue
else if ←entry.path.isDir then
children := children ++ (←fromDirectoryAux entry.path (.mkSimple entry.fileName)) children := children ++ (←fromDirectoryAux entry.path (.mkSimple entry.fileName))
else if entry.path.extension = some "html" then
children := children.push <| .mkSimple (entry.fileName.dropRight ".html".length)
pure <| Hierarchy.fromArray children pure <| Hierarchy.fromArray children
end Hierarchy end Hierarchy