forked from GitHub/gf-rgl
Use Pandoc and introduce HTML template for synopsis
- Remove isLatex flag - Plan to convert to Markdown and simply format
This commit is contained in:
5
doc/.gitignore
vendored
Normal file
5
doc/.gitignore
vendored
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
api-examples-*.txt
|
||||||
|
api-examples.gfs
|
||||||
|
categories-imagemap.html
|
||||||
|
synopsis.txt
|
||||||
|
synopsis.html
|
||||||
16
doc/Makefile
16
doc/Makefile
@@ -24,9 +24,23 @@ SRC_FILES=$(S)/abstract/Common.gf $(S)/abstract/Cat.gf $(S)/api/Constructors.gf
|
|||||||
EXAMPLES_OUT=$(patsubst %,api-examples-%.txt,$(LANGS))
|
EXAMPLES_OUT=$(patsubst %,api-examples-%.txt,$(LANGS))
|
||||||
INCLUDES=synopsis-intro.txt categories-intro.txt categories-imagemap.html synopsis-additional.txt synopsis-browse.txt synopsis-example.txt
|
INCLUDES=synopsis-intro.txt categories-intro.txt categories-imagemap.html synopsis-additional.txt synopsis-browse.txt synopsis-example.txt
|
||||||
|
|
||||||
synopsis.html: MkSynopsis.hs MkExxTable.hs $(INCLUDES) $(EXAMPLES_OUT) $(SRC_FILES)
|
synopsis.txt: MkSynopsis.hs MkExxTable.hs $(INCLUDES) $(EXAMPLES_OUT) $(SRC_FILES)
|
||||||
runghc -i.. MkSynopsis.hs
|
runghc -i.. MkSynopsis.hs
|
||||||
|
|
||||||
|
TMP=tmp.html
|
||||||
|
synopsis.html: synopsis.txt
|
||||||
|
txt2tags --target=html --no-headers --quiet --toc --outfile=$@ --infile=$^
|
||||||
|
pandoc \
|
||||||
|
--from=html \
|
||||||
|
--to=html5 \
|
||||||
|
--standalone \
|
||||||
|
--template=_template.html \
|
||||||
|
--metadata='title:"GF Resource Grammar Library: Synopsis"' \
|
||||||
|
--variable='rel-root:../..' \
|
||||||
|
--output=$(TMP) \
|
||||||
|
$@
|
||||||
|
mv $(TMP) $@
|
||||||
|
|
||||||
categories.png: categories.dot
|
categories.png: categories.dot
|
||||||
dot -Tpng $^ > $@
|
dot -Tpng $^ > $@
|
||||||
|
|
||||||
|
|||||||
@@ -29,17 +29,13 @@ apiExxFiles = do
|
|||||||
, langSynopsis lang
|
, langSynopsis lang
|
||||||
]
|
]
|
||||||
|
|
||||||
|
-- | This function puts together a txt2tags file which is then converted to HTML by the Makefile
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
main = do
|
main = do
|
||||||
xx <- getArgs
|
|
||||||
let isLatex = case xx of
|
|
||||||
"-tex":_ -> True
|
|
||||||
_ -> False
|
|
||||||
cs1 <- getCats commonAPI
|
cs1 <- getCats commonAPI
|
||||||
cs2 <- getCats catAPI
|
cs2 <- getCats catAPI
|
||||||
let cs = sortCats (cs1 ++ cs2)
|
let cs = sortCats (cs1 ++ cs2)
|
||||||
writeFile synopsis "GF Resource Grammar Library: Synopsis"
|
writeFile synopsis "GF Resource Grammar Library: Synopsis"
|
||||||
-- append "B. Bringert, T. Hallgren, and A. Ranta"
|
|
||||||
space
|
space
|
||||||
append "%!Encoding:utf-8"
|
append "%!Encoding:utf-8"
|
||||||
append "%!style(html): ./revealpopup.css"
|
append "%!style(html): ./revealpopup.css"
|
||||||
@@ -56,7 +52,7 @@ main = do
|
|||||||
append "%!postproc(html): '#quicklinks' '<script src=\"quicklinks.js\"></script>'"
|
append "%!postproc(html): '#quicklinks' '<script src=\"quicklinks.js\"></script>'"
|
||||||
append "%!postproc(tex): '#quicklinks' ''"
|
append "%!postproc(tex): '#quicklinks' ''"
|
||||||
delimit $ addToolTips cs
|
delimit $ addToolTips cs
|
||||||
include "synopsis-intro.txt"
|
include "synopsis-intro.txt" -- TODO dynamic language list
|
||||||
title "Categories"
|
title "Categories"
|
||||||
space
|
space
|
||||||
link "Source 1:" commonAPI
|
link "Source 1:" commonAPI
|
||||||
@@ -66,7 +62,7 @@ main = do
|
|||||||
append "==A hierarchic view==\n"
|
append "==A hierarchic view==\n"
|
||||||
include "categories-intro.txt"
|
include "categories-intro.txt"
|
||||||
append "==Explanations==\n"
|
append "==Explanations==\n"
|
||||||
delimit $ mkCatTable isLatex cs
|
delimit $ mkCatTable cs
|
||||||
space
|
space
|
||||||
title "Syntax Rules and Structural Words"
|
title "Syntax Rules and Structural Words"
|
||||||
space
|
space
|
||||||
@@ -81,17 +77,17 @@ main = do
|
|||||||
rs2 <- getRules apiExx structuralAPI
|
rs2 <- getRules apiExx structuralAPI
|
||||||
let rss = rs ++ rs2
|
let rss = rs ++ rs2
|
||||||
--- mapM_ putStrLn [f ++ " " ++ e | (f,_,e) <- rss]
|
--- mapM_ putStrLn [f ++ " " ++ e | (f,_,e) <- rss]
|
||||||
delimit $ mkSplitTables True isLatex apiExx cs rss
|
delimit $ mkSplitTables True apiExx cs rss
|
||||||
space
|
space
|
||||||
-- title "Structural Words"
|
-- title "Structural Words"
|
||||||
-- space
|
-- space
|
||||||
-- link "Source:" structuralAPI
|
-- link "Source:" structuralAPI
|
||||||
-- space
|
-- space
|
||||||
-- rs <- rulesTable False isLatex cs structuralAPI
|
-- rs <- rulesTable False cs structuralAPI
|
||||||
-- delimit rs
|
-- delimit rs
|
||||||
space
|
space
|
||||||
title "Lexical Paradigms"
|
title "Lexical Paradigms"
|
||||||
paradigmFiles >>= mapM_ (putParadigms isLatex cs)
|
paradigmFiles >>= mapM_ (putParadigms cs)
|
||||||
space
|
space
|
||||||
include "synopsis-additional.txt"
|
include "synopsis-additional.txt"
|
||||||
space
|
space
|
||||||
@@ -107,9 +103,6 @@ main = do
|
|||||||
space
|
space
|
||||||
append "#quicklinks"
|
append "#quicklinks"
|
||||||
space
|
space
|
||||||
let format = if isLatex then "tex" else "html"
|
|
||||||
system $ "txt2tags -t" ++ format ++ " " ++ " --toc " ++ synopsis
|
|
||||||
if isLatex then (system $ "pdflatex synopsis.tex") >> return () else return ()
|
|
||||||
|
|
||||||
addToolTips :: Cats -> [String]
|
addToolTips :: Cats -> [String]
|
||||||
addToolTips = map f
|
addToolTips = map f
|
||||||
@@ -130,10 +123,10 @@ getCats file = do
|
|||||||
(expl,ex) = span (/="e.g.") exp
|
(expl,ex) = span (/="e.g.") exp
|
||||||
_ -> getrs rs ss2
|
_ -> getrs rs ss2
|
||||||
|
|
||||||
rulesTable :: ApiExx -> Bool -> Bool -> Cats -> FilePath -> IO [String]
|
rulesTable :: ApiExx -> Bool -> Cats -> FilePath -> IO [String]
|
||||||
rulesTable aexx hasEx isLatex cs file = do
|
rulesTable aexx hasEx cs file = do
|
||||||
rs <- getRules aexx file
|
rs <- getRules aexx file
|
||||||
return $ mkTable hasEx isLatex aexx cs rs
|
return $ mkTable hasEx aexx cs rs
|
||||||
|
|
||||||
|
|
||||||
getRules :: ApiExx -> FilePath -> IO Rules
|
getRules :: ApiExx -> FilePath -> IO Rules
|
||||||
@@ -161,14 +154,14 @@ getRules aexx file = do
|
|||||||
n:ws | last n == '.' && not (null (init n)) && all isDigit (init n) -> ws
|
n:ws | last n == '.' && not (null (init n)) && all isDigit (init n) -> ws
|
||||||
_ -> e
|
_ -> e
|
||||||
|
|
||||||
putParadigms :: Bool -> Cats -> (String, FilePath) -> IO ()
|
putParadigms :: Cats -> (String, FilePath) -> IO ()
|
||||||
putParadigms isLatex cs (lang,file) = do
|
putParadigms cs (lang,file) = do
|
||||||
stitle ("Paradigms for " ++ lang)
|
stitle ("Paradigms for " ++ lang)
|
||||||
append "#LParadigms"
|
append "#LParadigms"
|
||||||
space
|
space
|
||||||
link "source" file
|
link "source" file
|
||||||
space
|
space
|
||||||
rs <- rulesTable M.empty False isLatex cs file
|
rs <- rulesTable M.empty False cs file
|
||||||
space
|
space
|
||||||
delimit rs
|
delimit rs
|
||||||
space
|
space
|
||||||
@@ -180,23 +173,23 @@ inChunks i f = concat . intersperse ["\n\n"] . map f . chunks i where
|
|||||||
|
|
||||||
-- Makes one table per result category.
|
-- Makes one table per result category.
|
||||||
-- Adds a subsection header for each table.
|
-- Adds a subsection header for each table.
|
||||||
mkSplitTables :: Bool -> Bool -> ApiExx -> Cats -> Rules -> [String]
|
mkSplitTables :: Bool -> ApiExx -> Cats -> Rules -> [String]
|
||||||
mkSplitTables hasEx isLatex aexx cs = concatMap t . addLexicalCats cs . sortRules
|
mkSplitTables hasEx aexx cs = concatMap t . addLexicalCats cs . sortRules
|
||||||
where t (c, xs) = [subtitle c expl] ++ tableOrLink
|
where t (c, xs) = [subtitle c expl] ++ tableOrLink
|
||||||
where
|
where
|
||||||
expl = case [e | (n,e,_) <- cs, n == c] of
|
expl = case [e | (n,e,_) <- cs, n == c] of
|
||||||
[] -> ""
|
[] -> ""
|
||||||
e:_ -> e
|
e:_ -> e
|
||||||
tableOrLink = if null xs then parad else mkTable hasEx isLatex aexx cs xs
|
tableOrLink = if null xs then parad else mkTable hasEx aexx cs xs
|
||||||
parad = [
|
parad = [
|
||||||
"Lexical category, constructors given in",
|
"Lexical category, constructors given in",
|
||||||
"[lexical paradigms #RParadigms]."
|
"[lexical paradigms #RParadigms]."
|
||||||
]
|
]
|
||||||
|
|
||||||
mkTable :: Bool -> Bool -> ApiExx -> Cats -> Rules -> [String]
|
mkTable :: Bool -> ApiExx -> Cats -> Rules -> [String]
|
||||||
mkTable hasEx isLatex aexx cs = inChunks chsize (\rs -> header : map (unwords . row) rs)
|
mkTable hasEx aexx cs = inChunks chsize (\rs -> header : map (unwords . row) rs)
|
||||||
where
|
where
|
||||||
chsize = if isLatex then 40 else 1000
|
chsize = 1000
|
||||||
header = if hasEx then "|| Function | Type | Example ||"
|
header = if hasEx then "|| Function | Type | Example ||"
|
||||||
else "|| Function | Type | Explanation ||"
|
else "|| Function | Type | Explanation ||"
|
||||||
row (name,typ,ex) =
|
row (name,typ,ex) =
|
||||||
@@ -235,11 +228,11 @@ mkIdent = concatMap unspec where
|
|||||||
':' -> "-"
|
':' -> "-"
|
||||||
_ -> [c]
|
_ -> [c]
|
||||||
|
|
||||||
mkCatTable :: Bool -> Cats -> [String]
|
mkCatTable :: Cats -> [String]
|
||||||
mkCatTable isLatex cs = inChunks chsize (\rs -> header ++ map mk1 rs) cs
|
mkCatTable cs = inChunks chsize (\rs -> header ++ map mk1 rs) cs
|
||||||
where
|
where
|
||||||
header = ["|| Category | Explanation | Example ||"]
|
header = ["|| Category | Explanation | Example ||"]
|
||||||
chsize = if isLatex then 40 else 1000
|
chsize = 1000
|
||||||
mk1 (name,expl,ex) = unwords ["|", showCat cs name, "|", expl, "|", typo ex, "|"]
|
mk1 (name,expl,ex) = unwords ["|", showCat cs name, "|", expl, "|", typo ex, "|"]
|
||||||
typo ex = if take 1 ex == "\"" then itf (init (tail ex)) else ex
|
typo ex = if take 1 ex == "\"" then itf (init (tail ex)) else ex
|
||||||
|
|
||||||
|
|||||||
116
doc/_template.html
Normal file
116
doc/_template.html
Normal file
@@ -0,0 +1,116 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html xmlns="http://www.w3.org/1999/xhtml" lang="$lang$" xml:lang="$lang$"$if(dir)$ dir="$dir$"$endif$>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<meta name="generator" content="pandoc" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
|
||||||
|
$for(author-meta)$
|
||||||
|
<meta name="author" content="$author-meta$" />
|
||||||
|
$endfor$
|
||||||
|
$if(date-meta)$
|
||||||
|
<meta name="dcterms.date" content="$date-meta$" />
|
||||||
|
$endif$
|
||||||
|
$if(keywords)$
|
||||||
|
<meta name="keywords" content="$for(keywords)$$keywords$$sep$, $endfor$" />
|
||||||
|
$endif$
|
||||||
|
<title>$if(title-prefix)$$title-prefix$ – $endif$$pagetitle$</title>
|
||||||
|
$for(css)$
|
||||||
|
<link rel="stylesheet" href="$css$" />
|
||||||
|
$endfor$
|
||||||
|
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
|
||||||
|
$if(math)$
|
||||||
|
$math$
|
||||||
|
$endif$
|
||||||
|
<!--[if lt IE 9]>
|
||||||
|
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
|
||||||
|
<![endif]-->
|
||||||
|
$for(header-includes)$
|
||||||
|
$header-includes$
|
||||||
|
$endfor$
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="container my-5">
|
||||||
|
|
||||||
|
$if(title)$
|
||||||
|
<header id="title-block-header">
|
||||||
|
<a href="$rel-root$" title="Home">
|
||||||
|
<img src="$rel-root$/doc/Logos/gf1.svg" height="200px" class="float-md-right mb-3 bg-white" alt="GF Logo">
|
||||||
|
</a>
|
||||||
|
<h1 class="title">$title$</h1>
|
||||||
|
$if(subtitle)$
|
||||||
|
<p class="subtitle">$subtitle$</p>
|
||||||
|
$endif$
|
||||||
|
$for(author)$
|
||||||
|
<p class="author">$author$</p>
|
||||||
|
$endfor$
|
||||||
|
$if(date)$
|
||||||
|
<p class="date">$date$</p>
|
||||||
|
$endif$
|
||||||
|
</header>
|
||||||
|
$endif$
|
||||||
|
$if(toc)$
|
||||||
|
<nav id="$idprefix$TOC">
|
||||||
|
$table-of-contents$
|
||||||
|
</nav>
|
||||||
|
$endif$
|
||||||
|
$body$
|
||||||
|
</div><!-- .container -->
|
||||||
|
|
||||||
|
<footer class="bg-light mt-5 py-5">
|
||||||
|
<div class="container">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-3">
|
||||||
|
<a href="$rel-root$">
|
||||||
|
<i class="fas fa-home"></i>
|
||||||
|
Home
|
||||||
|
</a>
|
||||||
|
<h6 class="text-muted mt-3">Use</h6>
|
||||||
|
<ul class="list-unstyled">
|
||||||
|
<li><a href="$rel-root$/demos">Demos</a></li>
|
||||||
|
<li><a href="$rel-root$/download">Download GF</a></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<div class="col-3">
|
||||||
|
<h6 class="text-muted">Documentation</h6>
|
||||||
|
<ul class="list-unstyled">
|
||||||
|
<li><a href="$rel-root$/doc/gf-shell-reference.html">GF Shell Reference</a></li>
|
||||||
|
<li><a href="$rel-root$/lib/doc/synopsis.html">RGL Library Synopsis</a></li>
|
||||||
|
<li><a href="$rel-root$/gf-book">The GF Book</a></li>
|
||||||
|
<li><a href="$rel-root$/doc/gf-refman.html">Reference Manual</a></li>
|
||||||
|
<li><a href="$rel-root$/doc/tutorial/gf-tutorial.html">Tutorial</a></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<div class="col-3">
|
||||||
|
<h6 class="text-muted">Reference</h6>
|
||||||
|
<ul class="list-unstyled">
|
||||||
|
<li><a href="http://hackage.haskell.org/package/gf/docs/PGF.html">PGF library API (Haskell runtime)</a></li>
|
||||||
|
<li><a href="$rel-root$/doc/runtime-api.html">PGF library API (C runtime)</a></li>
|
||||||
|
<li><a href="http://hackage.haskell.org/package/gf/docs/GF.html">GF compiler API</a></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<div class="col-3">
|
||||||
|
<h6 class="text-muted">
|
||||||
|
Repositories
|
||||||
|
<i class="fab fa-github"></i>
|
||||||
|
</h6>
|
||||||
|
<ul class="list-unstyled">
|
||||||
|
<li><a href="https://github.com/GrammaticalFramework/gf-core">GF Core</a></li>
|
||||||
|
<li><a href="https://github.com/GrammaticalFramework/gf-rgl">RGL</a></li>
|
||||||
|
<li><a href="https://github.com/GrammaticalFramework/gf-contrib">Contrib</a></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<div>
|
||||||
|
</footer>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
|
||||||
|
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
|
||||||
|
</script>
|
||||||
|
<script type="text/javascript">
|
||||||
|
try {
|
||||||
|
var pageTracker = _gat._getTracker("UA-7811807-3");
|
||||||
|
pageTracker._trackPageview();
|
||||||
|
} catch(err) {}</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Reference in New Issue
Block a user