printDecs :: DocConfig -> FilePath -> [FilePath] -> Imports -> IO ()
printDecs cfg dir files imports = do
  let direct_imports = map (normalise . dropExtension) files
      (file_htmls, _warnings) =
        renderFiles direct_imports $
          filter (not . ignored) imports
  mapM_ (write . fmap renderHtml) file_htmls
  write ("style.css", cssFile)
  where
    write :: (String, T.Text) -> IO ()
    write (name, content) = do
      let file = dir </> makeRelative "/" name
      when (docVerbose cfg) $
        hPutStrLn stderr $ "Writing " <> file
      createDirectoryIfMissing True $ takeDirectory file
      T.writeFile file content

    -- Some files are not worth documenting; typically because
    -- they contain tests.  The current crude mechanism is to
    -- recognise them by a file comment containing "ignore".
    ignored (_, fm) =
      case progDoc (fileProg fm) of
        Just (DocComment s _) -> trim s == "ignore"
        _ -> False
printDecs :: DocConfig -> FilePath -> [FilePath] -> Imports -> IO ()
printDecs cfg dir files imports = do
  let direct_imports = map (normalise . dropExtension) files
      (file_htmls, _warnings) =
        renderFiles direct_imports $
          filter (not . ignored) imports
  mapM_ (write . fmap renderHtml) file_htmls
  write ("style.css", cssFile)
  where
    write :: (String, T.Text) -> IO ()
    write (name, content) = do
      let file = dir </> makeRelative "/" name
      when (docVerbose cfg) $
        hPutStrLn stderr $ "Writing " <> file
      createDirectoryIfMissing True $ takeDirectory file
      T.writeFile file content

    -- Some files are not worth documenting; typically because
    -- they contain tests.  The current crude mechanism is to
    -- recognise them by a file comment containing "ignore".
    ignored (_, fm) =
      case progDoc (fileProg fm) of
        Just (DocComment s _) -> trim s == "ignore"
        _ -> False
printDecs cfg dir files imports = do
  let direct_imports = map (normalise . dropExtension) files
      (file_htmls, _warnings) =
        renderFiles direct_imports $
          filter (not . ignored) imports
  mapM_ (write . fmap renderHtml) file_htmls
  write ("style.css", cssFile)
  where
    write :: (String, T.Text) -> IO ()
    write (name, content) = do
      let file = dir </> makeRelative "/" name
      when (docVerbose cfg) $
        hPutStrLn stderr $ "Writing " <> file
      createDirectoryIfMissing True $ takeDirectory file
      T.writeFile file content

    -- Some files are not worth documenting; typically because
    -- they contain tests.  The current crude mechanism is to
    -- recognise them by a file comment containing "ignore".
    ignored (_, fm) =
      case progDoc (fileProg fm) of
        Just (DocComment s _) -> trim s == "ignore"
        _ -> False