Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
curry-frontend
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
62
Issues
62
List
Boards
Labels
Service Desk
Milestones
Merge Requests
3
Merge Requests
3
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
curry
curry-frontend
Commits
faa9abc7
Commit
faa9abc7
authored
Jan 21, 2015
by
Björn Peemöller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adapted HTML generation to hierarchial module names
parent
15bc07e8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
51 deletions
+48
-51
CHANGELOG.md
CHANGELOG.md
+6
-0
src/CurryBuilder.hs
src/CurryBuilder.hs
+2
-2
src/Html/CurryHtml.hs
src/Html/CurryHtml.hs
+40
-49
No files found.
CHANGELOG.md
View file @
faa9abc7
...
...
@@ -4,6 +4,12 @@ Change log for curry-frontend
Under development
=================
*
HTML generation now places HTML files for hierarchical modules into
files named
`<Module>_curry.html`
, i.e., no sub-folders reflecting
the the module name hierarchy are generated. In addition, if the option
`--html-dir`
is not given, the current directory is used as the output
directory.
*
Removed record type extensions
*
Enabled declaration of (mutually) recursive record types
...
...
src/CurryBuilder.hs
View file @
faa9abc7
...
...
@@ -3,7 +3,7 @@
Description : Build tool for compiling multiple Curry modules
Copyright : (c) 2005 Martin Engelke
2007 Sebastian Fischer
2011 - 201
4
Björn Peemöller
2011 - 201
5
Björn Peemöller
License : OtherLicense
Maintainer : bjp@informatik.uni-kiel.de
...
...
@@ -13,7 +13,7 @@
This module contains functions to generate Curry representations for a
Curry source file including all imported modules.
-}
module
CurryBuilder
(
buildCurry
)
where
module
CurryBuilder
(
buildCurry
,
findCurry
)
where
import
Control.Monad
(
foldM
,
liftM
)
import
Data.Char
(
isSpace
)
...
...
src/Html/CurryHtml.hs
View file @
faa9abc7
{- |
Module : $Header$
Description : Generating HTML documentation
Copyright : (c) 2011 - 201
4
, Björn Peemöller
Copyright : (c) 2011 - 201
5
, Björn Peemöller
License : OtherLicense
Maintainer : bjp@informatik.uni-kiel.de
...
...
@@ -11,75 +11,68 @@
This module defines a function for generating HTML documentation pages
for Curry source modules.
-}
{-# LANGUAGE CPP #-}
module
Html.CurryHtml
(
source2html
)
where
#
if
__GLASGOW_HASKELL__
>=
710
import
Control.Applicative
((
<$>
))
#
else
import
Control.Applicative
((
<$>
),
(
<*>
))
#
endif
import
Control.Monad.Writer
import
Data.List
(
mapAccumL
)
import
Data.Maybe
(
fromMaybe
,
isJust
)
import
Network.URI
(
escapeURIString
,
isUnreserved
)
import
System.Directory
(
copyFile
,
doesFileExist
)
import
System.FilePath
((
</>
)
,
dropFileName
,
joinPath
,
takeBaseName
)
import
System.FilePath
((
</>
))
import
Curry.Base.Ident
(
ModuleIdent
(
..
),
QualIdent
(
..
),
unqualify
)
import
Curry.Base.Monad
import
Curry.Base.Pretty
(
text
)
import
Curry.Files.Filenames
(
moduleNameToFile
)
import
Curry.Files.PathUtils
(
readModule
,
lookupCurryFile
)
import
Curry.Base.Monad
(
CYIO
,
liftCYM
,
failMessages
)
import
Curry.Base.Pretty
((
<+>
),
text
,
vcat
)
import
Curry.Files.PathUtils
(
readModule
)
import
Curry.Syntax
(
Module
(
..
),
lexSource
)
import
Html.SyntaxColoring
import
Base.Messages
import
Base.Messages
(
warn
,
message
)
import
CompilerOpts
(
Options
(
..
),
WarnOpts
(
..
))
import
CurryBuilder
(
buildCurry
)
import
CurryBuilder
(
buildCurry
,
findCurry
)
import
Modules
(
loadAndCheckModule
)
import
Transformations
(
qual
)
import
Paths_curry_frontend
(
getDataFileName
)
-- |'FilePath' of the CSS style file to be added to the documentation.
cssFile
::
FilePath
cssFile
=
"currysource.css"
-- translate source file into HTML file with syntaxcoloring
-- @param sourcefilename
source2html
::
Options
->
FilePath
->
CYIO
()
source2html
opts
f
=
do
let
baseName
=
takeBaseName
f
outDir
=
fromMaybe
(
dropFileName
f
)
$
optHtmlDir
opts
outFile
=
outDir
</>
baseName
++
"_curry.html"
srcFile
<-
liftIO
$
lookupCurryFile
(
"."
:
optImportPaths
opts
)
f
(
m
,
program
)
<-
filename2program
opts
(
fromMaybe
f
srcFile
)
liftIO
$
writeFile
outFile
(
program2html
m
program
)
liftIO
$
updateCSSFile
outDir
updateCSSFile
::
FilePath
->
IO
()
updateCSSFile
dir
=
do
src
<-
getDataFileName
cssFile
-- |Translate source file into HTML file with syntaxcoloring
source2html
::
Options
->
String
->
CYIO
()
source2html
opts
s
=
do
srcFile
<-
findCurry
opts
s
(
mid
,
doc
)
<-
docModule
opts
srcFile
let
outDir
=
fromMaybe
"."
$
optHtmlDir
opts
outFile
=
outDir
</>
htmlFile
mid
liftIO
$
writeFile
outFile
doc
updateCSSFile
opts
outDir
-- |Update the CSS file
updateCSSFile
::
Options
->
FilePath
->
CYIO
()
updateCSSFile
opts
dir
=
do
src
<-
liftIO
$
getDataFileName
cssFile
let
target
=
dir
</>
cssFile
exists
<-
doesFileExist
target
if
not
exists
then
copyFile
src
target
else
do
same
<-
(
==
)
<$>
readFile
src
<*>
readFile
targe
t
unless
same
$
copyFile
src
target
-- @param importpaths
-- @param filename
--
@return program
filename2program
::
Options
->
String
->
CYIO
(
ModuleIdent
,
[
Code
]
)
filename2program
opts
f
=
do
srcExists
<-
liftIO
$
doesFileExist
src
if
srcExists
then
liftIO
$
copyFile
src
target
else
warn
(
optWarnOpts
opts
)
[
message
$
missingStyleFile
src
]
where
missingStyleFile
f
=
vca
t
[
text
"Could not copy CSS style file:"
,
text
"File"
<+>
text
(
"`"
++
f
++
"'"
)
<+>
text
"does not exist"
]
--
|Create the documentation for the module
docModule
::
Options
->
String
->
CYIO
(
ModuleIdent
,
String
)
docModule
opts
f
=
do
mbModule
<-
liftIO
$
readModule
f
case
mbModule
of
Nothing
->
failMessages
[
message
$
text
$
"Missing file: "
++
f
]
Just
src
->
do
toks
<-
liftCYM
$
lexSource
f
src
typed
@
(
Module
_
m
_
_
_
)
<-
fullParse
opts
f
src
return
(
m
,
genProgram
typed
toks
)
return
(
m
,
program2html
m
$
genProgram
typed
toks
)
-- |Return the syntax tree of the source program 'src' (type 'Module'; see
-- Module "CurrySyntax").after inferring the types of identifiers.
...
...
@@ -107,7 +100,7 @@ program2html m codes = unlines
,
"<html>"
,
"<head>"
,
"<meta http-equiv=
\"
Content-Type
\"
content=
\"
text/html;charset=utf-8
\"
/>"
,
"<title>"
++
titleHtml
++
"</title>"
,
"<link rel=
\"
stylesheet
\"
type=
\"
text/css
\"
href=
\"
"
++
styleLink
++
"
\"
/>"
,
"<link rel=
\"
stylesheet
\"
type=
\"
text/css
\"
href=
\"
"
++
cssFile
++
"
\"
/>"
,
"</head>"
,
"<body>"
,
"<table><tbody><tr>"
...
...
@@ -119,7 +112,6 @@ program2html m codes = unlines
]
where
titleHtml
=
"Module "
++
show
m
styleLink
=
makeTopPath
m
</>
cssFile
lineHtml
=
unlines
$
map
show
[
1
..
length
(
lines
codeHtml
)]
codeHtml
=
concat
$
snd
$
mapAccumL
(
code2html
m
)
[]
codes
...
...
@@ -177,12 +169,11 @@ addHtmlLink m str qid =
(
mmid
,
ident
)
=
(
qidModule
qid
,
qidIdent
qid
)
makeRelativePath
::
ModuleIdent
->
ModuleIdent
->
String
makeRelativePath
cur
new
|
cur
==
new
=
""
|
otherwise
=
makeTopPath
cur
</>
moduleNameToFile
new
++
"_curry.html"
makeRelativePath
cur
new
|
cur
==
new
=
""
|
otherwise
=
htmlFile
new
makeTopPath
::
ModuleIdent
->
String
makeTopPath
m
=
joinPath
$
replicate
(
length
(
midQualifiers
m
)
-
1
)
"..
"
htmlFile
::
ModuleIdent
->
String
htmlFile
m
=
show
m
++
"_curry.html
"
isCall
::
Code
->
Bool
isCall
(
TypeCons
TypeExport
_
)
=
True
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment