1
0
forked from GitHub/gf-core

improved absfuns.html generation, added links, improved comments in source files to give better documentation

This commit is contained in:
aarne
2015-10-14 09:05:37 +00:00
parent d277fe88e1
commit bb289d9297
11 changed files with 883 additions and 826 deletions

View File

@@ -16,11 +16,13 @@ main = do
deps <- readFile "../src/uddeps.labels" >>= return . lines
let depmap = M.fromList [(fun,deps) | fun:deps <- map words deps]
let rows = sort $ filter (flip S.notMember hiddenModules . last) $ map (mkRow depmap) (map words funs)
let entries = map sepFields rows
putStrLn $ "GF RGL Functions"
putStrLn $ "generated by lib/src/doc/AbsFunFoc.hs"
putStrLn $ ""
putStrLn $ sepFields ["Function","Type","Example","Dependencies","Module"]
let entries = map (sepFields . addLink) rows
putStrLnIf $ "GF RGL Functions"
putStrLnIf $ "generated by lib/src/doc/AbsFunFoc.hs"
putStrLnIf $ "%%date"
putStrLnIf $ ""
putStrLnIf $ "Functions in this table have links, e.g. http://www.grammaticalframework.org/lib/doc/absfuns.html#PredVP"
putStrLn $ sepFields ["**Function**","**Type**","**Example**","**Dependencies**","**Module**"]
putStrLn $ unlines entries
@@ -29,14 +31,27 @@ hiddenModules = S.fromList
"Documentation","Lexicon","NumeralTransfer","Terminology","Transfer","MarkHTML","Markup","ERROR"] ----
mkRow depmap ws = case ws of
file:fun:":":typecomment -> fun : getTypeComment typecomment ++ [getDep fun, getModule file]
file:fun:":":typecomment -> named fun : getTypeComment typecomment ++ [getDep fun, getModule file]
_ -> ["ERROR"]
where
getModule = reverse . takeWhile (/='/') . tail . dropWhile (/='.') . reverse -- ../src/abstract/Adverb.gf: --> Adverb
getTypeComment ws = case span (/= ";") ws of
(ty,rest) -> [unwords ty, unwords (drop 2 rest)] -- PredVP : NP -> VP -> Cl ; -- John walks
(ty,rest) -> [unwords ty, italics (unwords (drop 2 rest))] -- PredVP : NP -> VP -> Cl ; -- John walks
getDep fun = maybe "-" (unwords . takeWhile (/="--")) $ M.lookup fun depmap
-- sepFields = concat . intersperse "\t"
-- for html (via txt2tags) generation
sepFields fs = "| " ++ concat (intersperse " | " fs) ++ " |"
named f = f ++ "''<a name=\"" ++ f ++ "\"></a>''"
italics e = "//" ++ map (\c -> case c of '[' -> '(' ; ']'->')'; _ -> c) e ++ "//"
putStrLnIf = putStrLn
addLink fs =
let m = last fs ; abstract = case m of "Extensions" -> "translator/" ; _ -> "abstract/"
in init fs ++ ["[" ++ m ++ " ../src/" ++ abstract ++ m ++ ".gf]"]
-- for tab separated generation
-- sepFields = concat . intersperse "\t"
-- named f = f
-- italics e = e
-- putStrLnIf = return ()
-- addLink fs = fs