Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision

Target

Select target project
  • ghc/haddock
  • rae/haddock
  • sjakobi/haddock
  • RyanGlScott/haddock
  • mynguyenbmc/haddock
  • kcsongor/haddock
  • wz1000/haddock
  • dten/haddock
  • bgamari/haddock
  • abrar/haddock
  • obsidiansystems/haddock
  • inaki/haddock
  • hsyl20/haddock
  • JoshMeredith/haddock
  • matheus23/haddock
  • Gertjan423/haddock
  • ulysses4ever/haddock
  • facundominguez/haddock
  • SuedeHead/haddock
  • Haskell-mouse/haddock
  • fgaz/haddock
  • arybczak/haddock
  • coot/haddock
  • hithroc/haddock
  • ani/haddock
  • supersven/haddock
  • alt-romes/haddock
  • sspencer/haddock
  • Joald/haddock
  • raehik/haddock
  • lexi.lambda/haddock
  • torsten.schmits/haddock
  • Bodigrim/haddock
  • doyougnu/haddock
  • barci2/haddock
  • Jade/haddock
  • wavewave/haddock
  • soulomoon/haddock
  • tvh/haddock
  • trac-sjoerd_visscher/haddock
  • Kleidukos/haddock
  • mmzk1526/haddock
  • stephenjudkins/haddock
  • KommuSoft1/haddock
44 results
Select Git revision
Show changes
Showing
with 1903 additions and 470 deletions
File moved
File moved
* {
margin: 0;
padding: 0;
}
body {
background-color: #ffffff;
color: #000000;
font-size: 100%;
font-family: sans-serif;
padding: 8px;
}
a:link { color: #0000e0; text-decoration: none }
a:visited { color: #0000a0; text-decoration: none }
a:hover { background-color: #e0e0ff; text-decoration: none }
/* <tt> font is a little too small in MSIE */
tt { font-size: 100%; }
pre { font-size: 100%; }
.keyword { text-decoration: underline; }
.caption {
font-weight: bold;
margin: 0;
padding: 0;
}
h1 {
padding-top: 15px;
font-weight: bold;
font-size: 150%;
}
h2 {
padding-top: 10px;
font-weight: bold;
font-size: 130%
}
h3 {
padding-top: 5px;
font-weight: bold;
font-size: 110%
}
h4, h5 {
font-weight: bold;
font-size: 100%
}
h1, h2, h3, h4, h5 {
margin-top: 0.5em;
margin-bottom: 0.5em;
}
p {
padding-top: 2px;
padding-left: 10px;
}
ul, ol, dl {
padding-top: 2px;
padding-left: 10px;
margin-left: 2.5em;
}
pre {
padding-top: 2px;
padding-left: 20px;
}
* + p, * + pre {
margin-top: 1em;
}
.caption + p, .src + p {
margin-top: 0;
}
.def {
font-weight: bold;
}
ul.links {
list-style: none;
text-align: left;
float: right;
display: inline-table;
padding: 0;
}
ul.links li {
display: inline;
border-left-width: 1px;
border-left-color: #ffffff;
border-left-style: solid;
white-space: nowrap;
padding: 1px 5px;
}
.hide { display: none; }
.show { }
.collapser {
background: url(minus.gif) no-repeat 0 0.3em;
}
.expander {
background: url(plus.gif) no-repeat 0 0.3em;
}
.collapser, .expander {
padding-left: 14px;
cursor: pointer;
}
#package-header {
color: #ffffff;
padding: 5px 5px 5px 31px;
margin: 0 0 1px;
background: #000099 url(haskell_icon.gif) no-repeat 5px 6px;
position: relative;
}
#package-header .caption {
font-weight: normal;
font-style: normal;
}
#package-header a:link { color: #ffffff }
#package-header a:visited { color: #ffff00 }
#package-header a:hover { background-color: #6060ff; }
#package-header ul.links li:hover { background-color: #6060ff; }
div#style-menu-holder {
position: relative;
z-index: 2;
display: inline;
}
#style-menu {
position: absolute;
z-index: 1;
overflow: visible;
background-color: #000099;
margin: 0;
width: 6em;
text-align: center;
right: 0;
padding: 2px 2px 1px;
}
#style-menu li {
display: list-item;
border-style: none;
margin: 0;
padding: 3px;
color: #000;
list-style-type: none;
border-top: 1px solid #ffffff;
}
#module-header {
overflow: hidden; /* makes sure info float is properly contained */
display: inline-block; /* triggers hasLayout in IE*/
}
#module-header {
display: block; /* back to block */
background-color: #0077dd;
padding: 5px;
}
#module-header .caption {
font-size: 200%;
padding: .35em 0;
font-weight: normal;
font-style: normal;
}
table.info {
color: #ffffff;
display: block;
float: right;
max-width: 50%;
}
.info th, .info td {
text-align: left;
padding: 0 10px 0 0;
}
#table-of-contents {
margin-top: 1em;
margin-bottom: 2em;
}
#table-of-contents ul {
margin-top: 1em;
margin-bottom: 1em;
margin-left: 0;
list-style-type: none;
padding: 0;
}
#table-of-contents ul ul {
margin-left: 2.5em;
}
#description .caption,
#synopsis .caption,
#module-list .caption,
#index .caption {
padding-top: 15px;
font-weight: bold;
font-size: 150%
}
#synopsis {
margin-bottom: 2em;
}
#synopsis .expander,
#synopsis .collapser {
background: none;
padding-left: inherit;
}
#synopsis .hide {
display: inherit;
}
#synopsis ul {
margin: 0;
padding-top: 0;
padding-left: 20px;
list-style-type: none;
}
#synopsis li {
margin-top: 8px;
margin-bottom: 8px;
padding: 3px;
}
#synopsis li li {
padding: 0;
margin-top: 0;
margin-bottom: 0;
}
div.top {
margin-top: 1em;
clear: left;
margin-bottom: 1em;
}
div.top h5 {
margin-left: 10px;
}
.src {
padding: 3px;
background-color: #f0f0f0;
font-family: monospace;
margin-bottom: 0;
}
.src a.link {
float: right;
border-left-width: 1px;
border-left-color: #000099;
border-left-style: solid;
white-space: nowrap;
font-size: small;
padding: 0 8px 2px 5px;
margin-right: -3px;
background-color: #f0f0f0;
}
div.subs {
margin-left: 10px;
clear: both;
margin-top: 2px;
}
.subs dl {
margin-left: 0;
}
.subs dl dl {
padding-left: 0;
padding-top: 4px;
}
.subs dd
{
margin: 2px 0 9px 2em;
}
.subs dd.empty {
display: none;
}
.subs table {
margin-left: 10px;
border-spacing: 1px 1px;
margin-top: 4px;
margin-bottom: 4px;
}
.subs table table {
margin-left: 0;
}
.arguments .caption,
.fields .caption {
display: none;
}
/* need extra .subs in the selector to make it override the rules for .subs and .subs table */
.subs.arguments {
margin: 0;
}
.subs.arguments table {
border-spacing: 0;
margin-top: 0;
margin-bottom: 0;
}
.subs.arguments td.src {
white-space: nowrap;
}
.subs.arguments + p {
margin-top: 0;
}
.subs.associated-types,
.subs.methods {
margin-left: 20px;
}
.subs.associated-types .caption,
.subs.methods .caption {
margin-top: 0.5em;
margin-left: -10px;
}
.subs.associated-types .src + .src,
.subs.methods .src + .src {
margin-top: 8px;
}
p.arg {
margin-bottom: 0;
}
p.arg span {
background-color: #f0f0f0;
font-family: monospace;
white-space: nowrap;
float: none;
}
img.coll {
width : 0.75em; height: 0.75em; margin-bottom: 0; margin-right: 0.5em
}
td.arg {
padding: 3px;
background-color: #f0f0f0;
font-family: monospace;
margin-bottom: 0;
}
td.rdoc p {
margin-bottom: 0;
}
#footer {
background-color: #000099;
color: #ffffff;
padding: 4px
}
#footer p {
padding: 1px;
margin: 0;
}
#footer a:link {
color: #ffffff;
text-decoration: underline
}
#footer a:visited {
color: #ffff00
}
#footer a:hover {
background-color: #6060ff
}
#module-list ul {
list-style: none;
padding-bottom: 15px;
padding-left: 2px;
margin: 0;
}
#module-list ul ul {
padding-bottom: 0;
padding-left: 20px;
}
#module-list li .package {
float: right;
}
#mini #module-list .caption {
display: none;
}
#index .caption {
}
#alphabet ul {
list-style: none;
padding: 0;
margin: 0.5em 0 0;
}
#alphabet li {
display: inline;
margin: 0 0.2em;
}
#index .src {
background: none;
font-family: inherit;
}
#index td.alt {
padding-left: 2em;
}
#index td {
padding-top: 2px;
padding-bottom: 1px;
padding-right: 1em;
}
#mini h1 { font-size: 130%; }
#mini h2 { font-size: 110%; }
#mini h3 { font-size: 100%; }
#mini h1, #mini h2, #mini h3 {
margin-top: 0.5em;
margin-bottom: 0.25em;
padding: 0 0;
}
#mini h1 { border-bottom: 1px solid #ccc; }
#mini #module-header {
margin: 0;
padding: 0;
}
#mini #module-header .caption {
font-size: 130%;
background: #0077dd;
padding: 0.25em;
height: inherit;
margin: 0;
}
#mini #interface .top {
margin: 0;
padding: 0;
}
#mini #interface .src {
margin: 0;
padding: 0;
font-family: inherit;
background: inherit;
}
html/Ocean.std-theme/hslogo-16.png

1.64 KiB

html/Ocean.std-theme/minus.gif

56 B

/* @group Fundamentals */
* { margin: 0; padding: 0 }
/* Is this portable? */
html {
background-color: white;
width: 100%;
height: 100%;
}
body {
background: white;
color: black;
text-align: left;
min-height: 100%;
position: relative;
}
p {
margin: 0.8em 0;
}
ul, ol {
margin: 0.8em 0 0.8em 2em;
}
dl {
margin: 0.8em 0;
}
dt {
font-weight: bold;
}
dd {
margin-left: 2em;
}
a { text-decoration: none; }
a[href]:link { color: rgb(196,69,29); }
a[href]:visited { color: rgb(171,105,84); }
a[href]:hover { text-decoration:underline; }
/* @end */
/* @group Fonts & Sizes */
/* Basic technique & IE workarounds from YUI 3
For reasons, see:
http://yui.yahooapis.com/3.1.1/build/cssfonts/fonts.css
*/
body {
font:13px/1.4 sans-serif;
*font-size:small; /* for IE */
*font:x-small; /* for IE in quirks mode */
}
h1 { font-size: 146.5%; /* 19pt */ }
h2 { font-size: 131%; /* 17pt */ }
h3 { font-size: 116%; /* 15pt */ }
h4 { font-size: 100%; /* 13pt */ }
h5 { font-size: 100%; /* 13pt */ }
select, input, button, textarea {
font:99% sans-serif;
}
table {
font-size:inherit;
font:100%;
}
pre, code, kbd, samp, tt, .src {
font-family:monospace;
*font-size:108%;
line-height: 124%;
}
.links, .link {
font-size: 85%; /* 11pt */
}
#module-header .caption {
font-size: 182%; /* 24pt */
}
.info {
font-size: 85%; /* 11pt */
}
#table-of-contents, #synopsis {
/* font-size: 85%; /* 11pt */
}
/* @end */
/* @group Common */
.caption, h1, h2, h3, h4, h5, h6 {
font-weight: bold;
color: rgb(78,98,114);
margin: 0.8em 0 0.4em;
}
* + h1, * + h2, * + h3, * + h4, * + h5, * + h6 {
margin-top: 2em;
}
h1 + h2, h2 + h3, h3 + h4, h4 + h5, h5 + h6 {
margin-top: inherit;
}
ul.links {
list-style: none;
text-align: left;
float: right;
display: inline-table;
margin: 0 0 0 1em;
}
ul.links li {
display: inline;
border-left: 1px solid #d5d5d5;
white-space: nowrap;
padding: 0;
}
ul.links li a {
padding: 0.2em 0.5em;
}
.hide { display: none; }
.show { display: inherit; }
.clear { clear: both; }
.collapser {
background-image: url(minus.gif);
background-repeat: no-repeat;
}
.expander {
background-image: url(plus.gif);
background-repeat: no-repeat;
}
p.caption.collapser,
p.caption.expander {
background-position: 0 0.4em;
}
.collapser, .expander {
padding-left: 14px;
margin-left: -14px;
cursor: pointer;
}
pre {
padding: 0.25em;
margin: 0.8em 0;
background: rgb(229,237,244);
overflow: auto;
border-bottom: 0.25em solid white;
/* white border adds some space below the box to compensate
for visual extra space that paragraphs have between baseline
and the bounding box */
}
.src {
background: #f0f0f0;
padding: 0.2em 0.5em;
}
.keyword { font-weight: normal; }
.def { font-weight: bold; }
/* @end */
/* @group Page Structure */
#content {
margin: 0 auto;
padding: 0 2em 6em;
}
#package-header {
background: rgb(41,56,69);
border-top: 5px solid rgb(78,98,114);
color: #ddd;
padding: 0.2em;
position: relative;
text-align: left;
}
#package-header .caption {
background: url(hslogo-16.png) no-repeat 0em;
color: white;
margin: 0 2em;
font-weight: normal;
font-style: normal;
padding-left: 2em;
}
#package-header a:link, #package-header a:visited { color: white; }
#package-header a:hover { background: rgb(78,98,114); }
#module-header .caption {
color: rgb(78,98,114);
font-weight: bold;
border-bottom: 1px solid #ddd;
}
table.info {
float: right;
padding: 0.5em 1em;
border: 1px solid #ddd;
color: rgb(78,98,114);
background-color: #fff;
max-width: 40%;
border-spacing: 0;
position: relative;
top: -0.5em;
margin: 0 0 0 2em;
}
.info th {
padding: 0 1em 0 0;
}
div#style-menu-holder {
position: relative;
z-index: 2;
display: inline;
}
#style-menu {
position: absolute;
z-index: 1;
overflow: visible;
background: #374c5e;
margin: 0;
text-align: center;
right: 0;
padding: 0;
top: 1.25em;
}
#style-menu li {
display: list-item;
border-style: none;
margin: 0;
padding: 0;
color: #000;
list-style-type: none;
}
#style-menu li + li {
border-top: 1px solid #919191;
}
#style-menu a {
width: 6em;
padding: 3px;
display: block;
}
#footer {
background: #ddd;
border-top: 1px solid #aaa;
padding: 0.5em 0;
color: #666;
text-align: center;
position: absolute;
bottom: 0;
width: 100%;
height: 3em;
}
/* @end */
/* @group Front Matter */
#table-of-contents {
float: right;
clear: right;
background: #faf9dc;
border: 1px solid #d8d7ad;
padding: 0.5em 1em;
max-width: 20em;
margin: 0.5em 0 1em 1em;
}
#table-of-contents .caption {
text-align: center;
margin: 0;
}
#table-of-contents ul {
list-style: none;
margin: 0;
}
#table-of-contents ul ul {
margin-left: 2em;
}
#description .caption {
display: none;
}
#synopsis {
display: none;
}
.no-frame #synopsis {
display: block;
position: fixed;
right: 0;
height: 80%;
top: 10%;
padding: 0;
}
#synopsis .caption {
float: left;
width: 29px;
color: rgba(255,255,255,0);
height: 110px;
margin: 0;
font-size: 1px;
padding: 0;
}
#synopsis p.caption.collapser {
background: url(synopsis.png) no-repeat -64px -8px;
}
#synopsis p.caption.expander {
background: url(synopsis.png) no-repeat 0px -8px;
}
#synopsis ul {
height: 100%;
overflow: auto;
padding: 0.5em;
margin: 0;
}
#synopsis ul ul {
overflow: hidden;
}
#synopsis ul,
#synopsis ul li.src {
background-color: #faf9dc;
white-space: nowrap;
list-style: none;
margin-left: 0;
}
/* @end */
/* @group Main Content */
#interface div.top { margin: 2em 0; }
#interface h1 + div.top,
#interface h2 + div.top,
#interface h3 + div.top,
#interface h4 + div.top,
#interface h5 + div.top {
margin-top: 1em;
}
#interface p.src .link {
float: right;
color: #919191;
border-left: 1px solid #919191;
background: #f0f0f0;
padding: 0 0.5em 0.2em;
margin: 0 -0.5em 0 0.5em;
}
#interface table { border-spacing: 2px; }
#interface td {
vertical-align: top;
padding-left: 0.5em;
}
#interface td.src {
white-space: nowrap;
}
#interface td.doc p {
margin: 0;
}
#interface td.doc p + p {
margin-top: 0.8em;
}
.subs dl {
margin: 0;
}
.subs dt {
float: left;
clear: left;
display: block;
margin: 1px 0;
}
.subs dd {
float: right;
width: 90%;
display: block;
padding-left: 0.5em;
margin-bottom: 0.5em;
}
.subs dd.empty {
display: none;
}
.subs dd p {
margin: 0;
}
.top p.src {
border-top: 1px solid #ccc;
}
.subs, .doc {
/* use this selector for one level of indent */
padding-left: 2em;
}
.arguments {
margin-top: -0.4em;
}
.arguments .caption {
display: none;
}
.fields { padding-left: 1em; }
.fields .caption { display: none; }
.fields p { margin: 0 0; }
/* this seems bulky to me
.methods, .constructors {
background: #f8f8f8;
border: 1px solid #eee;
}
*/
/* @end */
/* @group Auxillary Pages */
#mini {
margin: 0 auto;
padding: 0 1em 1em;
}
#mini > * {
font-size: 93%; /* 12pt */
}
#mini #module-list .caption,
#mini #module-header .caption {
font-size: 125%; /* 15pt */
}
#mini #interface h1,
#mini #interface h2,
#mini #interface h3,
#mini #interface h4 {
font-size: 109%; /* 13pt */
margin: 1em 0 0;
}
#mini #interface .top,
#mini #interface .src {
margin: 0;
}
#mini #module-list ul {
list-style: none;
margin: 0;
}
#alphabet ul {
list-style: none;
padding: 0;
margin: 0.5em 0 0;
text-align: center;
}
#alphabet li {
display: inline;
margin: 0 0.25em;
}
#alphabet a {
font-weight: bold;
}
#index .caption,
#module-list .caption { font-size: 131%; /* 17pt */ }
#index table {
margin-left: 2em;
}
#index .src {
font-weight: bold;
}
#index .alt {
font-size: 77%; /* 10pt */
font-style: italic;
padding-left: 2em;
}
#index td + td {
padding-left: 1em;
}
#module-list ul {
list-style: none;
margin: 0 0 0 2em;
}
#module-list li {
clear: right;
}
#module-list span.collapser,
#module-list span.expander {
background-position: 0 0.3em;
}
#module-list .package {
float: right;
}
/* @end */
html/Ocean.std-theme/plus.gif

59 B

html/Ocean.std-theme/synopsis.png

11.1 KiB

<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script src="haddock-util.js" type="text/javascript"></script>
<script type="text/javascript"><!--
/*
The synopsis frame needs to be updated using javascript, so we hide
it by default and only show it if javascript is enabled.
TODO: provide some means to disable it.
*/
function load() {
var d = document.getElementById("inner-fs");
d.rows = "50%,50%";
postReframe();
}
--></script>
<frameset id="outer-fs" cols="25%,75%" onload="load()">
<frameset id="inner-fs" rows="100%,0%">
<frame src="index-frames.html" name="modules">
<frame src="" name="synopsis">
</frameset>
<frame src="index.html" name="main">
</frameset>
</html>
/* -------- Global things --------- */
BODY {
background-color: #ffffff;
color: #000000;
font-family: sans-serif;
}
A:link { color: #0000e0; text-decoration: none }
A:visited { color: #0000a0; text-decoration: none }
A:hover { background-color: #e0e0ff; text-decoration: none }
TABLE.vanilla {
width: 100%;
border-width: 0px;
background-color: #ffe0e0;
/* I can't seem to specify cellspacing or cellpadding properly using CSS... */
}
TD {
border-width: 0px;
}
TABLE.narrow {
border-width: 0px;
}
/* --------- Documentation elements ---------- */
TD.children {
padding-left: 25px;
}
TD.synopsis {
padding: 2px;
background-color: #f0f0f0;
font-family: monospace
}
TD.decl {
padding: 2px;
background-color: #f0f0f0;
font-family: monospace;
white-space: nowrap;
vertical-align: top;
}
TD.recfield { padding-left: 20px }
TD.doc {
padding-top: 2px;
padding-left: 10px;
background-color: #e0ffe0;
}
TD.ndoc {
padding: 2px;
background-color: #e0ffe0;
}
TD.rdoc {
padding: 2px;
padding-left: 10px;
background-color: #e0ffe0;
width: 100%;
}
TD.body {
padding-left: 10px
}
/* ------- Section Headings ------- */
TD.section1 {
padding-top: 15px;
font-weight: bold;
font-size: 150%
}
TD.section2 {
padding-top: 10px;
font-weight: bold;
font-size: 130%
}
TD.section3 {
padding-top: 5px;
font-weight: bold;
font-size: 110%
}
TD.section4 {
font-weight: bold;
font-size: 100%
}
/* -------------- The title bar at the top of the page */
TD.infohead {
color: #ffffff;
font-weight: bold;
padding-right: 10px;
text-align: left;
}
TD.infoval {
color: #ffffff;
padding-right: 10px;
text-align: left;
}
TD.topbar {
background-color: #000099;
padding: 5px;
}
TD.title {
color: #ffffff;
padding-left: 10px;
width: 100%
}
TD.topbut {
padding-left: 5px;
padding-right: 5px;
border-left-width: 1px;
border-left-color: #ffffff;
border-left-style: solid;
white-space: nowrap;
}
TD.topbut A:link {
color: #ffffff
}
TD.topbut A:visited {
color: #ffff00
}
TD.topbut A:hover {
background-color: #6060ff;
}
TD.topbut:hover {
background-color: #6060ff
}
TD.modulebar {
background-color: #0077dd;
padding: 5px;
border-top-width: 1px;
border-top-color: #ffffff;
border-top-style: solid;
}
/* --------- The page footer --------- */
TD.botbar {
background-color: #000099;
color: #ffffff;
padding: 5px
}
TD.botbar A:link {
color: #ffffff;
text-decoration: underline
}
TD.botbar A:visited {
color: #ffff00
}
TD.botbar A:hover {
background-color: #6060ff
}
// Haddock JavaScript utilities
var rspace = /\s\s+/g,
rtrim = /^\s+|\s+$/g;
function spaced(s) { return (" " + s + " ").replace(rspace, " "); }
function trim(s) { return s.replace(rtrim, ""); }
function hasClass(elem, value) {
var className = spaced(elem.className || "");
return className.indexOf( " " + value + " " ) >= 0;
}
function addClass(elem, value) {
var className = spaced(elem.className || "");
if ( className.indexOf( " " + value + " " ) < 0 ) {
elem.className = trim(className + " " + value);
}
}
function removeClass(elem, value) {
var className = spaced(elem.className || "");
className = className.replace(" " + value + " ", " ");
elem.className = trim(className);
}
function toggleClass(elem, valueOn, valueOff, bool) {
if (bool == null) { bool = ! hasClass(elem, valueOn); }
if (bool) {
removeClass(elem, valueOff);
addClass(elem, valueOn);
}
else {
removeClass(elem, valueOn);
addClass(elem, valueOff);
}
return bool;
}
function makeClassToggle(valueOn, valueOff)
{
return function(elem, bool) {
return toggleClass(elem, valueOn, valueOff, bool);
}
}
toggleShow = makeClassToggle("show", "hide");
toggleCollapser = makeClassToggle("collapser", "expander");
function toggleSection(id)
{
var b = toggleShow(document.getElementById("section." + id));
toggleCollapser(document.getElementById("control." + id), b);
rememberCollapsed(id, b);
return b;
}
var collapsed = {};
function rememberCollapsed(id, b)
{
if(b)
delete collapsed[id]
else
collapsed[id] = null;
var sections = [];
for(var i in collapsed)
{
if(collapsed.hasOwnProperty(i))
sections.push(i);
}
// cookie specific to this page; don't use setCookie which sets path=/
document.cookie = "collapsed=" + escape(sections.join('+'));
}
function restoreCollapsed()
{
var cookie = getCookie("collapsed");
if(!cookie)
return;
var ids = cookie.split('+');
for(var i in ids)
{
if(document.getElementById("section." + ids[i]))
toggleSection(ids[i]);
}
}
function setCookie(name, value) {
document.cookie = name + "=" + escape(value) + ";path=/;";
}
function clearCookie(name) {
document.cookie = name + "=;path=/;expires=Thu, 01-Jan-1970 00:00:01 GMT;";
}
function getCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) {
return unescape(c.substring(nameEQ.length,c.length));
}
}
return null;
}
var max_results = 75; // 50 is not enough to search for map in the base libraries
var shown_range = null;
var last_search = null;
function quick_search()
{
perform_search(false);
}
function full_search()
{
perform_search(true);
}
function perform_search(full)
{
var text = document.getElementById("searchbox").value.toLowerCase();
if (text == last_search && !full) return;
last_search = text;
var table = document.getElementById("indexlist");
var status = document.getElementById("searchmsg");
var children = table.firstChild.childNodes;
// first figure out the first node with the prefix
var first = bisect(-1);
var last = (first == -1 ? -1 : bisect(1));
if (first == -1)
{
table.className = "";
status.innerHTML = "No results found, displaying all";
}
else if (first == 0 && last == children.length - 1)
{
table.className = "";
status.innerHTML = "";
}
else if (last - first >= max_results && !full)
{
table.className = "";
status.innerHTML = "More than " + max_results + ", press Search to display";
}
else
{
// decide what you need to clear/show
if (shown_range)
setclass(shown_range[0], shown_range[1], "indexrow");
setclass(first, last, "indexshow");
shown_range = [first, last];
table.className = "indexsearch";
status.innerHTML = "";
}
function setclass(first, last, status)
{
for (var i = first; i <= last; i++)
{
children[i].className = status;
}
}
// do a binary search, treating 0 as ...
// return either -1 (no 0's found) or location of most far match
function bisect(dir)
{
var first = 0, finish = children.length - 1;
var mid, success = false;
while (finish - first > 3)
{
mid = Math.floor((finish + first) / 2);
var i = checkitem(mid);
if (i == 0) i = dir;
if (i == -1)
finish = mid;
else
first = mid;
}
var a = (dir == 1 ? first : finish);
var b = (dir == 1 ? finish : first);
for (var i = b; i != a - dir; i -= dir)
{
if (checkitem(i) == 0) return i;
}
return -1;
}
// from an index, decide what the result is
// 0 = match, -1 is lower, 1 is higher
function checkitem(i)
{
var s = getitem(i).toLowerCase().substr(0, text.length);
if (s == text) return 0;
else return (s > text ? -1 : 1);
}
// from an index, get its string
// this abstracts over alternates
function getitem(i)
{
for ( ; i >= 0; i--)
{
var s = children[i].firstChild.firstChild.data;
if (s.indexOf(' ') == -1)
return s;
}
return ""; // should never be reached
}
}
function setSynopsis(filename) {
if (parent.window.synopsis) {
if (parent.window.synopsis.location.replace) {
// In Firefox this avoids adding the change to the history.
parent.window.synopsis.location.replace(filename);
} else {
parent.window.synopsis.location = filename;
}
}
}
function addMenuItem(html) {
var menu = document.getElementById("page-menu");
if (menu) {
var btn = menu.firstChild.cloneNode(false);
btn.innerHTML = html;
menu.appendChild(btn);
}
}
function adjustForFrames() {
var bodyCls;
if (parent.location.href == window.location.href) {
// not in frames, so add Frames button
addMenuItem("<a href='#' onclick='reframe();return true;'>Frames</a>");
bodyCls = "no-frame";
}
else {
bodyCls = "in-frame";
}
addClass(document.body, bodyCls);
}
function reframe() {
setCookie("haddock-reframe", document.URL);
window.location = "frames.html";
}
function postReframe() {
var s = getCookie("haddock-reframe");
if (s) {
parent.window.main.location = s;
clearCookie("haddock-reframe");
}
}
function styles() {
var i, a, es = document.getElementsByTagName("link"), rs = [];
for (i = 0; a = es[i]; i++) {
if(a.rel.indexOf("style") != -1 && a.title) {
rs.push(a);
}
}
return rs;
}
function addStyleMenu() {
var as = styles();
var i, a, btns = "";
for(i=0; a = as[i]; i++) {
btns += "<li><a href='#' onclick=\"setActiveStyleSheet('"
+ a.title + "'); return false;\">"
+ a.title + "</a></li>"
}
if (as.length > 1) {
var h = "<div id='style-menu-holder'>"
+ "<a href='#' onclick='styleMenu(); return false;'>Style &#9662;</a>"
+ "<ul id='style-menu' class='hide'>" + btns + "</ul>"
+ "</div>";
addMenuItem(h);
}
}
function setActiveStyleSheet(title) {
var as = styles();
var i, a, found;
for(i=0; a = as[i]; i++) {
a.disabled = true;
// need to do this always, some browsers are edge triggered
if(a.title == title) {
found = a;
}
}
if (found) {
found.disabled = false;
setCookie("haddock-style", title);
}
else {
as[0].disabled = false;
clearCookie("haddock-style");
}
styleMenu(false);
}
function resetStyle() {
var s = getCookie("haddock-style");
if (s) setActiveStyleSheet(s);
}
function styleMenu(show) {
var m = document.getElementById('style-menu');
if (m) toggleShow(m, show);
}
function pageLoad() {
addStyleMenu();
adjustForFrames();
resetStyle();
restoreCollapsed();
}
/* -------- Global things --------- */
BODY {
background-color: #ffffff;
color: #000000;
font-family: sans-serif;
}
A:link { color: #0000e0; text-decoration: none }
A:visited { color: #0000a0; text-decoration: none }
A:hover { background-color: #e0e0ff; text-decoration: none }
TABLE.vanilla {
width: 100%;
border-width: 0px;
/* I can't seem to specify cellspacing or cellpadding properly using CSS... */
}
TABLE.vanilla2 {
border-width: 0px;
}
/* <TT> font is a little too small in MSIE */
TT { font-size: 100%; }
PRE { font-size: 100%; }
LI P { margin: 0pt }
TD {
border-width: 0px;
}
TABLE.narrow {
border-width: 0px;
}
TD.s8 { height: 8px; }
TD.s15 { height: 15px; }
SPAN.keyword { text-decoration: underline; }
/* Resize the buttom image to match the text size */
IMG.coll { width : 0.75em; height: 0.75em; margin-bottom: 0; margin-right: 0.5em }
/* --------- Contents page ---------- */
DIV.node {
padding-left: 3em;
}
DIV.cnode {
padding-left: 1.75em;
}
SPAN.pkg {
position: absolute;
left: 50em;
}
/* --------- Documentation elements ---------- */
TD.children {
padding-left: 25px;
}
TD.synopsis {
padding: 2px;
background-color: #f0f0f0;
font-family: monospace
}
TD.decl {
padding: 2px;
background-color: #f0f0f0;
font-family: monospace;
vertical-align: top;
}
TD.topdecl {
padding: 2px;
background-color: #f0f0f0;
font-family: monospace;
vertical-align: top;
}
TABLE.declbar {
border-spacing: 0px;
}
TD.declname {
width: 100%;
}
TD.declbut {
padding-left: 5px;
padding-right: 5px;
border-left-width: 1px;
border-left-color: #000099;
border-left-style: solid;
white-space: nowrap;
font-size: small;
}
/*
arg is just like decl, except that wrapping is not allowed. It is
used for function and constructor arguments which have a text box
to the right, where if wrapping is allowed the text box squashes up
the declaration by wrapping it.
*/
TD.arg {
padding: 2px;
background-color: #f0f0f0;
font-family: monospace;
vertical-align: top;
white-space: nowrap;
}
TD.recfield { padding-left: 20px }
TD.doc {
padding-top: 2px;
padding-left: 10px;
}
TD.ndoc {
padding: 2px;
}
TD.rdoc {
padding: 2px;
padding-left: 10px;
width: 100%;
}
TD.body {
padding-left: 10px
}
TD.pkg {
width: 100%;
padding-left: 10px
}
TD.indexentry {
vertical-align: top;
padding-right: 10px
}
TD.indexannot {
vertical-align: top;
padding-left: 20px;
white-space: nowrap
}
TD.indexlinks {
width: 100%
}
/* ------- Section Headings ------- */
TD.section1 {
padding-top: 15px;
font-weight: bold;
font-size: 150%
}
TD.section2 {
padding-top: 10px;
font-weight: bold;
font-size: 130%
}
TD.section3 {
padding-top: 5px;
font-weight: bold;
font-size: 110%
}
TD.section4 {
font-weight: bold;
font-size: 100%
}
/* -------------- The title bar at the top of the page */
TD.infohead {
color: #ffffff;
font-weight: bold;
padding-right: 10px;
text-align: left;
}
TD.infoval {
color: #ffffff;
padding-right: 10px;
text-align: left;
}
TD.topbar {
background-color: #000099;
padding: 5px;
}
TD.title {
color: #ffffff;
padding-left: 10px;
width: 100%
}
TD.topbut {
padding-left: 5px;
padding-right: 5px;
border-left-width: 1px;
border-left-color: #ffffff;
border-left-style: solid;
white-space: nowrap;
}
TD.topbut A:link {
color: #ffffff
}
TD.topbut A:visited {
color: #ffff00
}
TD.topbut A:hover {
background-color: #6060ff;
}
TD.topbut:hover {
background-color: #6060ff
}
TD.modulebar {
background-color: #0077dd;
padding: 5px;
border-top-width: 1px;
border-top-color: #ffffff;
border-top-style: solid;
}
/* --------- The page footer --------- */
TD.botbar {
background-color: #000099;
color: #ffffff;
padding: 5px
}
TD.botbar A:link {
color: #ffffff;
text-decoration: underline
}
TD.botbar A:visited {
color: #ffff00
}
TD.botbar A:hover {
background-color: #6060ff
}
// Haddock JavaScript utilities
function toggle(button,id)
{
var n = document.getElementById(id).style;
if (n.display == "none")
{
button.src = "minus.gif";
n.display = "block";
}
else
{
button.src = "plus.gif";
n.display = "none";
}
}
% Default Haddock style definitions. To use your own style, invoke
% Haddock with the option --latex-style=mystyle.
\usepackage{tabulary} % see below
% make hyperlinks in the PDF, and add an expandabale index
\usepackage[pdftex,bookmarks=true]{hyperref}
\newenvironment{haddocktitle}
{\begin{center}\bgroup\large\bfseries}
{\egroup\end{center}}
\newenvironment{haddockprologue}{\vspace{1in}}{}
\newcommand{\haddockmoduleheading}[1]{\chapter{\texttt{#1}}}
\newcommand{\haddockbeginheader}{\hrulefill}
\newcommand{\haddockendheader}{\noindent\hrulefill}
% a little gap before the ``Methods'' header
\newcommand{\haddockpremethods}{\vspace{2ex}}
% inserted before \\begin{verbatim}
\newcommand{\haddockverb}{\small}
% an identifier: add an index entry
\newcommand{\haddockid}[1]{\haddocktt{#1}\index{#1@\texttt{#1}}}
% The tabulary environment lets us have a column that takes up ``the
% rest of the space''. Unfortunately it doesn't allow
% the \end{tabulary} to be in the expansion of a macro, it must appear
% literally in the document text, so Haddock inserts
% the \end{tabulary} itself.
\newcommand{\haddockbeginconstrs}{\begin{tabulary}{\linewidth}{@{}llJ@{}}}
\newcommand{\haddockbeginargs}{\begin{tabulary}{\linewidth}{@{}llJ@{}}}
\newcommand{\haddocktt}[1]{{\small \texttt{#1}}}
\newcommand{\haddockdecltt}[1]{{\small\bfseries \texttt{#1}}}
\makeatletter
\newenvironment{haddockdesc}
{\list{}{\labelwidth\z@ \itemindent-\leftmargin
\let\makelabel\haddocklabel}}
{\endlist}
\newcommand*\haddocklabel[1]{\hspace\labelsep\haddockdecltt{#1}}
\makeatother
% after a declaration, start a new line for the documentation.
% Otherwise, the documentation starts right after the declaration,
% because we're using the list environment and the declaration is the
% ``label''. I tried making this newline part of the label, but
% couldn't get that to work reliably (the space seemed to stretch
% sometimes).
\newcommand{\haddockbegindoc}{\hfill\\[1ex]}
% spacing between paragraphs and no \parindent looks better
\parskip=10pt plus2pt minus2pt
\setlength{\parindent}{0cm}
# Put the Happy-generated .hs files in the right place in the source dist.
set -e
rm -f dist/haddock-*.tar.gz
rm -rf dist/haddock-*/
./Setup sdist
cd dist
tar xvzf haddock-*.tar.gz
cd haddock-*/
mkdir dist
mkdir dist/build
mv haddock dist/build
cd ..
tar cvzf haddock-*.tar.gz haddock-*/
# Steps for doing a release:
# * Update version number in .cabal, doc/haddock.xml, haddock.spec
# * Update CHANGES
# * Source:
# - do the above
# - upload the dist to haskell.org:haddock/dist/${version}
# - scp CHANGES haskell.org:haddock/CHANGES.txt
# * Binaries:
# - build the Windows binary zip (see build-windows-dist.sh)
# - scp haddock-<version>-Win32.zip haskell.org:haddock/dist
# * Documentation:
# - cd doc
# - make html
# - mv haddock haddock-html
# - tar cvzf haddock-doc-html-${version}.tar.gz haddock-html
# - scp haddock-doc-html-${version}.tar.gz www.haskell.org:../haskell/haddock/doc
# - ssh haskell.org
# - cd haddock/doc
# - tar xvzf haddock-doc-html-${version}.tar.gz
# - rm -rf html-OLD
# - mv html html-OLD && mv haddock-html html
# * Update the web page (~/darcs/www/haddock/index.html), and push it
module Distribution.Haddock (
readInterfaceFile,
H.InterfaceFile(..)
) where
import Haddock.Exception
import qualified Haddock.InterfaceFile as H
import Control.Exception
import Control.Monad
readInterfaceFile :: FilePath -> IO (Either String H.InterfaceFile)
readInterfaceFile f =
liftM Right (H.readInterfaceFile f)
`catchDyn`
(\(e::HaddockException) -> return $ Left $ show e)
-----------------------------------------------------------------------------
-- |
-- Module : Documentation.Haddock
-- Copyright : (c) David Waern 2010
-- License : BSD-like
--
-- Maintainer : haddock@projects.haskellorg
-- Stability : experimental
-- Portability : portable
--
-- The Haddock API: A rudimentory, highly experimental API exposing some of
-- the internals of Haddock. Don't expect it to be stable.
-----------------------------------------------------------------------------
module Documentation.Haddock (
-- * Interface
Interface(..),
InstalledInterface(..),
createInterfaces,
processModules,
-- * Export items & declarations
ExportItem(..),
DocForDecl,
FnArgsDoc,
-- * Cross-referencing
LinkEnv,
DocName(..),
-- * Instances
DocInstance,
InstHead,
-- * Documentation comments
Doc(..),
Example(..),
DocMarkup(..),
HaddockModInfo(..),
markup,
-- * Interface files
InterfaceFile(..),
readInterfaceFile,
nameCacheFromGhc,
freshNameCache,
NameCacheAccessor,
-- * Flags and options
Flag(..),
DocOption(..)
) where
import Haddock.InterfaceFile
import Haddock.Interface
import Haddock.Types
import Haddock.Options
import Haddock.Utils
import Main
-- | Create 'Interface' structures from a given list of Haddock command-line
-- flags and file or module names (as accepted by 'haddock' executable). Flags
-- that control documentation generation or show help or version information
-- are ignored.
createInterfaces
:: [Flag] -- ^ A list of command-line flags
-> [String] -- ^ File or module names
-> IO [Interface] -- ^ Resulting list of interfaces
createInterfaces flags modules = do
(_, ifaces, _) <- readPackagesAndProcessModules flags modules
return ifaces
-----------------------------------------------------------------------------
-- |
-- Module : Haddock.Backends.HaddockDB
-- Copyright : (c) Simon Marlow 2003
-- License : BSD-like
-- --
-- Haddock - A Haskell Documentation Tool -- Maintainer : haddock@projects.haskell.org
-- -- Stability : experimental
-- (c) Simon Marlow 2003 -- Portability : portable
-- -----------------------------------------------------------------------------
module Haddock.Backends.HaddockDB (ppDocBook) where
module Haddock.HaddockDB (ppDocBook) where
{- {-
import HaddockTypes import HaddockTypes
...@@ -17,6 +21,7 @@ import Text.PrettyPrint ...@@ -17,6 +21,7 @@ import Text.PrettyPrint
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
-- Printing the results in DocBook format -- Printing the results in DocBook format
ppDocBook :: a
ppDocBook = error "not working" ppDocBook = error "not working"
{- {-
ppDocBook :: FilePath -> [(Module, Interface)] -> String ppDocBook :: FilePath -> [(Module, Interface)] -> String
......
-----------------------------------------------------------------------------
-- |
-- Module : Haddock.Backends.Hoogle
-- Copyright : (c) Neil Mitchell 2006-2008
-- License : BSD-like
--
-- Maintainer : haddock@projects.haskell.org
-- Stability : experimental
-- Portability : portable
--
-- Write out Hoogle compatible documentation
-- http://www.haskell.org/hoogle/
-----------------------------------------------------------------------------
module Haddock.Backends.Hoogle (
ppHoogle
) where
import Haddock.GhcUtils
import Haddock.Types
import Haddock.Utils hiding (out)
import GHC
import Outputable
import Data.Char
import Data.List
import Data.Maybe
import System.FilePath
import System.IO
prefix :: [String]
prefix = ["-- Hoogle documentation, generated by Haddock"
,"-- See Hoogle, http://www.haskell.org/hoogle/"
,""]
ppHoogle :: String -> String -> String -> Maybe (Doc RdrName) -> [Interface] -> FilePath -> IO ()
ppHoogle package version synopsis prologue ifaces odir = do
let filename = package ++ ".txt"
contents = prefix ++
docWith (drop 2 $ dropWhile (/= ':') synopsis) prologue ++
["@package " ++ package] ++
["@version " ++ version | version /= ""] ++
concat [ppModule i | i <- ifaces, OptHide `notElem` ifaceOptions i]
h <- openFile (odir </> filename) WriteMode
hSetEncoding h utf8
hPutStr h (unlines contents)
hClose h
ppModule :: Interface -> [String]
ppModule iface = "" : doc (ifaceDoc iface) ++
["module " ++ moduleString (ifaceMod iface)] ++
concatMap ppExport (ifaceExportItems iface) ++
concatMap ppInstance (ifaceInstances iface)
---------------------------------------------------------------------
-- Utility functions
dropHsDocTy :: HsType a -> HsType a
dropHsDocTy = f
where
g (L src x) = L src (f x)
f (HsForAllTy a b c d) = HsForAllTy a b c (g d)
f (HsBangTy a b) = HsBangTy a (g b)
f (HsAppTy a b) = HsAppTy (g a) (g b)
f (HsFunTy a b) = HsFunTy (g a) (g b)
f (HsListTy a) = HsListTy (g a)
f (HsPArrTy a) = HsPArrTy (g a)
f (HsTupleTy a b) = HsTupleTy a (map g b)
f (HsOpTy a b c) = HsOpTy (g a) b (g c)
f (HsParTy a) = HsParTy (g a)
f (HsKindSig a b) = HsKindSig (g a) b
f (HsDocTy a _) = f $ unL a
f x = x
outHsType :: OutputableBndr a => HsType a -> String
outHsType = out . dropHsDocTy
makeExplicit :: HsType a -> HsType a
makeExplicit (HsForAllTy _ a b c) = HsForAllTy Explicit a b c
makeExplicit x = x
makeExplicitL :: LHsType a -> LHsType a
makeExplicitL (L src x) = L src (makeExplicit x)
dropComment :: String -> String
dropComment (' ':'-':'-':' ':_) = []
dropComment (x:xs) = x : dropComment xs
dropComment [] = []
out :: Outputable a => a -> String
out = f . unwords . map (dropWhile isSpace) . lines . showSDocUnqual . ppr
where
f xs | " <document comment>" `isPrefixOf` xs = f $ drop 19 xs
f (x:xs) = x : f xs
f [] = []
operator :: String -> String
operator (x:xs) | not (isAlphaNum x) && x `notElem` "_' ([{" = "(" ++ x:xs ++ ")"
operator x = x
---------------------------------------------------------------------
-- How to print each export
ppExport :: ExportItem Name -> [String]
ppExport (ExportDecl decl dc subdocs _) = doc (fst dc) ++ f (unL decl)
where
f (TyClD d@TyDecl{})
| isDataDecl d = ppData d subdocs
| otherwise = ppSynonym d
f (TyClD d@ClassDecl{}) = ppClass d
f (ForD (ForeignImport name typ _ _)) = ppSig $ TypeSig [name] typ
f (ForD (ForeignExport name typ _ _)) = ppSig $ TypeSig [name] typ
f (SigD sig) = ppSig sig
f _ = []
ppExport _ = []
ppSig :: Sig Name -> [String]
ppSig (TypeSig names sig) = [operator prettyNames ++ " :: " ++ outHsType typ]
where
prettyNames = concat . intersperse ", " $ map out names
typ = case unL sig of
HsForAllTy Explicit a b c -> HsForAllTy Implicit a b c
x -> x
ppSig _ = []
-- note: does not yet output documentation for class methods
ppClass :: TyClDecl Name -> [String]
ppClass x = out x{tcdSigs=[]} :
concatMap (ppSig . addContext . unL) (tcdSigs x)
where
addContext (TypeSig name (L l sig)) = TypeSig name (L l $ f sig)
addContext _ = error "expected TypeSig"
f (HsForAllTy a b con d) = HsForAllTy a b (reL (context : unLoc con)) d
f t = HsForAllTy Implicit emptyHsQTvs (reL [context]) (reL t)
context = nlHsTyConApp (unL $ tcdLName x)
(map (reL . HsTyVar . hsTyVarName . unL) (hsQTvBndrs (tcdTyVars x)))
ppInstance :: ClsInst -> [String]
ppInstance x = [dropComment $ out x]
ppSynonym :: TyClDecl Name -> [String]
ppSynonym x = [out x]
ppData :: TyClDecl Name -> [(Name, DocForDecl Name)] -> [String]
ppData decl@(TyDecl { tcdTyDefn = defn }) subdocs
= showData decl{ tcdTyDefn = defn { td_cons=[],td_derivs=Nothing }} :
concatMap (ppCtor decl subdocs . unL) (td_cons defn)
where
-- GHC gives out "data Bar =", we want to delete the equals
-- also writes data : a b, when we want data (:) a b
showData d = unwords $ map f $ if last xs == "=" then init xs else xs
where
xs = words $ out d
nam = out $ tcdLName d
f w = if w == nam then operator nam else w
ppData _ _ = panic "ppData"
-- | for constructors, and named-fields...
lookupCon :: [(Name, DocForDecl Name)] -> Located Name -> Maybe (Doc Name)
lookupCon subdocs (L _ name) = case lookup name subdocs of
Just (d, _) -> d
_ -> Nothing
ppCtor :: TyClDecl Name -> [(Name, DocForDecl Name)] -> ConDecl Name -> [String]
ppCtor dat subdocs con = doc (lookupCon subdocs (con_name con))
++ f (con_details con)
where
f (PrefixCon args) = [typeSig name $ args ++ [resType]]
f (InfixCon a1 a2) = f $ PrefixCon [a1,a2]
f (RecCon recs) = f (PrefixCon $ map cd_fld_type recs) ++ concat
[doc (lookupCon subdocs (cd_fld_name r)) ++
[out (unL $ cd_fld_name r) `typeSig` [resType, cd_fld_type r]]
| r <- recs]
funs = foldr1 (\x y -> reL $ HsFunTy (makeExplicitL x) (makeExplicitL y))
apps = foldl1 (\x y -> reL $ HsAppTy x y)
typeSig nm flds = operator nm ++ " :: " ++ outHsType (makeExplicit $ unL $ funs flds)
name = out $ unL $ con_name con
resType = case con_res con of
ResTyH98 -> apps $ map (reL . HsTyVar) $
unL (tcdLName dat) : [hsTyVarName v | L _ (v@UserTyVar {}) <- hsQTvBndrs $ tcdTyVars dat]
ResTyGADT x -> x
---------------------------------------------------------------------
-- DOCUMENTATION
doc :: Outputable o => Maybe (Doc o) -> [String]
doc = docWith ""
docWith :: Outputable o => String -> Maybe (Doc o) -> [String]
docWith [] Nothing = []
docWith header d = ("":) $ zipWith (++) ("-- | " : repeat "-- ") $
[header | header /= ""] ++ ["" | header /= "" && isJust d] ++
maybe [] (showTags . markup markupTag) d
data Tag = TagL Char [Tags] | TagP Tags | TagPre Tags | TagInline String Tags | Str String
deriving Show
type Tags = [Tag]
box :: (a -> b) -> a -> [b]
box f x = [f x]
str :: String -> [Tag]
str a = [Str a]
-- want things like paragraph, pre etc to be handled by blank lines in the source document
-- and things like \n and \t converted away
-- much like blogger in HTML mode
-- everything else wants to be included as tags, neatly nested for some (ul,li,ol)
-- or inlne for others (a,i,tt)
-- entities (&,>,<) should always be appropriately escaped
markupTag :: Outputable o => DocMarkup o [Tag]
markupTag = Markup {
markupParagraph = box TagP,
markupEmpty = str "",
markupString = str,
markupAppend = (++),
markupIdentifier = box (TagInline "a") . str . out,
markupIdentifierUnchecked = box (TagInline "a") . str . out . snd,
markupModule = box (TagInline "a") . str,
markupEmphasis = box (TagInline "i"),
markupMonospaced = box (TagInline "tt"),
markupPic = const $ str " ",
markupUnorderedList = box (TagL 'u'),
markupOrderedList = box (TagL 'o'),
markupDefList = box (TagL 'u') . map (\(a,b) -> TagInline "i" a : Str " " : b),
markupCodeBlock = box TagPre,
markupURL = box (TagInline "a") . str,
markupAName = const $ str "",
markupExample = box TagPre . str . unlines . map exampleToString
}
showTags :: [Tag] -> [String]
showTags = intercalate [""] . map showBlock
showBlock :: Tag -> [String]
showBlock (TagP xs) = showInline xs
showBlock (TagL t xs) = ['<':t:"l>"] ++ mid ++ ['<':'/':t:"l>"]
where mid = concatMap (showInline . box (TagInline "li")) xs
showBlock (TagPre xs) = ["<pre>"] ++ showPre xs ++ ["</pre>"]
showBlock x = showInline [x]
asInline :: Tag -> Tags
asInline (TagP xs) = xs
asInline (TagPre xs) = [TagInline "pre" xs]
asInline (TagL t xs) = [TagInline (t:"l") $ map (TagInline "li") xs]
asInline x = [x]
showInline :: [Tag] -> [String]
showInline = unwordsWrap 70 . words . concatMap f
where
fs = concatMap f
f (Str x) = escape x
f (TagInline s xs) = "<"++s++">" ++ (if s == "li" then trim else id) (fs xs) ++ "</"++s++">"
f x = fs $ asInline x
trim = dropWhile isSpace . reverse . dropWhile isSpace . reverse
showPre :: [Tag] -> [String]
showPre = trimFront . trimLines . lines . concatMap f
where
trimLines = dropWhile null . reverse . dropWhile null . reverse
trimFront xs = map (drop i) xs
where
ns = [length a | x <- xs, let (a,b) = span isSpace x, b /= ""]
i = if null ns then 0 else minimum ns
fs = concatMap f
f (Str x) = escape x
f (TagInline s xs) = "<"++s++">" ++ fs xs ++ "</"++s++">"
f x = fs $ asInline x
unwordsWrap :: Int -> [String] -> [String]
unwordsWrap n = f n []
where
f _ s [] = [g s | s /= []]
f i s (x:xs) | nx > i = g s : f (n - nx - 1) [x] xs
| otherwise = f (i - nx - 1) (x:s) xs
where nx = length x
g = unwords . reverse
escape :: String -> String
escape = concatMap f
where
f '<' = "&lt;"
f '>' = "&gt;"
f '&' = "&amp;"
f x = [x]