Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ fix #1743 ] move README to doc/ directory #2184

Merged
merged 12 commits into from
Nov 5, 2023
3 changes: 2 additions & 1 deletion GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@ setup: Everything.agda

.PHONY: Everything.agda
Everything.agda:
cabal run GenerateEverything
cabal run GenerateEverything -- --out-dir doc
jamesmckinna marked this conversation as resolved.
Show resolved Hide resolved

.PHONY: listings
listings: Everything.agda
cd doc && $(AGDA) --html README.agda -v0

clean :
find . -type f -name '*.agdai' -delete
rm -f Everything.agda EverythingSafe.agda
37 changes: 30 additions & 7 deletions GenerateEverything.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{-# LANGUAGE PatternGuards #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE RecordWildCards #-}

import Control.Applicative
import Control.Monad
Expand Down Expand Up @@ -299,18 +300,37 @@ checkFilePaths cat fps = forM_ fps $ \ fp -> do
unless b $
die $ fp ++ " is listed as " ++ cat ++ " but does not exist."

data Options = Options
{ includeDeprecated :: Bool
, outputDirectory :: FilePath
}

initOptions :: Options
initOptions = Options
{ includeDeprecated = False
, outputDirectory = "."
}

parseOptions :: [String] -> Options -> Maybe Options
parseOptions [] opts = pure opts
parseOptions ("--include-deprecated" : rest) opts
= parseOptions rest (opts { includeDeprecated = True })
parseOptions ("--out-dir" : dir : rest) opts
= parseOptions rest (opts { outputDirectory = dir })
parseOptions _ _ = Nothing

---------------------------------------------------------------------------
-- Collecting all non-Core library files, analysing them and generating
-- 4 files:
-- 2 files:
-- Everything.agda all the modules
-- EverythingSafe.agda all the safe modules

main :: IO ()
main = do
args <- getArgs
includeDeprecated <- case args of
[] -> return False
["--include-deprecated"] -> return True
_ -> hPutStr stderr usage >> exitFailure
Options{..} <- case parseOptions args initOptions of
Just opts -> pure opts
Nothing -> hPutStr stderr usage >> exitFailure

checkFilePaths "unsafe" unsafeModules
checkFilePaths "using K" withKModules
Expand All @@ -325,14 +345,14 @@ main = do

let mkModule str = "module " ++ str ++ " where"

writeFileUTF8 (allOutputFile ++ ".agda") $
writeFileUTF8 (outputDirectory ++ "/" ++ allOutputFile ++ ".agda") $
unlines [ header
, "{-# OPTIONS --rewriting --guardedness --sized-types #-}\n"
, mkModule allOutputFile
, format libraryfiles
]

writeFileUTF8 (safeOutputFile ++ ".agda") $
writeFileUTF8 (outputDirectory ++ "/" ++ safeOutputFile ++ ".agda") $
unlines [ header
, "{-# OPTIONS --safe --guardedness #-}\n"
, mkModule safeOutputFile
Expand All @@ -353,6 +373,9 @@ usage = unlines
, "The program generates documentation for the library by extracting"
, "headers from library modules. The output is written to " ++ allOutputFile
, "with the file " ++ headerFile ++ " inserted verbatim at the beginning."
, ""
, "If the option --out-dir is used then the output is placed in the"
, "subdirectory thus selected."
]


Expand Down