mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-22 03:09:33 -06:00
added a copy of uddeps.labels; script for generating a table of abstract RGL functions and information on them; an instance of running the script, absfuns.html, to be used as documentation
This commit is contained in:
42
lib/doc/AbsFunDoc.hs
Normal file
42
lib/doc/AbsFunDoc.hs
Normal file
@@ -0,0 +1,42 @@
|
||||
import System.Process(system)
|
||||
import qualified Data.Map as M
|
||||
import qualified Data.Set as S
|
||||
import Data.List
|
||||
|
||||
|
||||
-- building a table of RGL functions and their types, examples, and documentation
|
||||
-- to run:
|
||||
-- $ runghc AbsFunDoc.hs >absfuns.txt
|
||||
-- $ txt2tags -thtml absfuns.txt
|
||||
-- this creates the file absfuns.html
|
||||
|
||||
main = do
|
||||
system "grep \" : \" ../src/abstract/*.gf ../src/translator/Extensions.gf >absfuns.tmp"
|
||||
funs <- readFile "absfuns.tmp" >>= return . lines
|
||||
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"]
|
||||
putStrLn $ unlines entries
|
||||
|
||||
|
||||
hiddenModules = S.fromList
|
||||
["Backward","Structural","Extra","Construction","Compatibility",
|
||||
"Documentation","Lexicon","NumeralTransfer","Terminology","Transfer","MarkHTML","Markup","ERROR"] ----
|
||||
|
||||
mkRow depmap ws = case ws of
|
||||
file:fun:":":typecomment -> 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
|
||||
getDep fun = maybe "-" (unwords . takeWhile (/="--")) $ M.lookup fun depmap
|
||||
|
||||
-- sepFields = concat . intersperse "\t"
|
||||
sepFields fs = "| " ++ concat (intersperse " | " fs) ++ " |"
|
||||
|
||||
1789
lib/doc/absfuns.html
Normal file
1789
lib/doc/absfuns.html
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user