Skip to content
Snippets Groups Projects
Commit 4bd9b401 authored by Loïc Correnson's avatar Loïc Correnson
Browse files

[server] generated doc enhancements

parent 2ceb184a
No related branches found
No related tags found
No related merge requests found
...@@ -36,7 +36,7 @@ body { ...@@ -36,7 +36,7 @@ body {
height: 100%; height: 100%;
overflow: hidden; overflow: hidden;
font-family: "Verdana", sans; font-family: "Verdana", sans;
font-size: 12pt; font-size: 10pt;
} }
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
...@@ -72,7 +72,7 @@ body { ...@@ -72,7 +72,7 @@ body {
justify-content: left ; justify-content: left ;
align-content: center ; align-content: center ;
box-sizing: border-box ; box-sizing: border-box ;
width: 18cm ; width: 22cm ;
height: 100% ; height: 100% ;
padding: 0cm 1cm 1cm 1cm ; padding: 0cm 1cm 1cm 1cm ;
} }
...@@ -81,10 +81,6 @@ body { ...@@ -81,10 +81,6 @@ body {
/* --- Navigation --- */ /* --- Navigation --- */
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
#TOC {
font-size: smaller ;
}
#NAVIGATION a { #NAVIGATION a {
color: black ; color: black ;
} }
...@@ -92,7 +88,7 @@ body { ...@@ -92,7 +88,7 @@ body {
#NAVIGATION a.root { #NAVIGATION a.root {
display: block; display: block;
font-family: "Optima", "Verdana", "Arial", sans; font-family: "Optima", "Verdana", "Arial", sans;
font-size: 16pt; font-size: 10pt;
margin-top: 1cm; margin-top: 1cm;
margin-bottom: 6mm; margin-bottom: 6mm;
} }
...@@ -123,7 +119,7 @@ body { ...@@ -123,7 +119,7 @@ body {
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
h1 { h1 {
width: 18cm; width: 22cm;
font-family: "Optima", "Verdana", "Arial", sans; font-family: "Optima", "Verdana", "Arial", sans;
text-align: left; text-align: left;
margin-top: 1cm; margin-top: 1cm;
...@@ -141,7 +137,7 @@ h2 { ...@@ -141,7 +137,7 @@ h2 {
} }
h3 { h3 {
width: 17cm; width: 18cm;
font-family: "Optima", "Verdana", "Arial", sans; font-family: "Optima", "Verdana", "Arial", sans;
margin-top: 5mm; margin-top: 5mm;
margin-bottom: 3mm; margin-bottom: 3mm;
...@@ -158,11 +154,11 @@ h4,h5,h6 { ...@@ -158,11 +154,11 @@ h4,h5,h6 {
font-weight: bold; font-weight: bold;
} }
p { margin: 18px 0px 18px 0px; width: 15cm; } p { margin: 18px 0px 18px 0px; width: 18cm; }
ul,ol,blockquote { ul,ol,blockquote {
margin-left: 24px ; margin-left: 24px ;
width: 13cm; width: 15cm;
} }
li { li {
...@@ -188,10 +184,13 @@ hr { ...@@ -188,10 +184,13 @@ hr {
table { table {
border-collapse: collapse ; border-collapse: collapse ;
margin-top: 4mm ;
margin-bottom: 4mm ;
margin-left: 6mm ; margin-left: 6mm ;
} }
th,td { th,td {
font-weight: normal ;
padding: 2px 16px 2px 12px ; padding: 2px 16px 2px 12px ;
} }
......
...@@ -63,7 +63,7 @@ let failure ?json msg = ...@@ -63,7 +63,7 @@ let failure ?json msg =
let failure_from_type_error msg json = let failure_from_type_error msg json =
failure ~json "%s" msg failure ~json "%s" msg
let page = Doc.page `Kernel ~title:"Kernel Types" ~filename:"data.md" let page = Doc.page `Kernel ~title:"Basic Types" ~filename:"data.md"
(* -------------------------------------------------------------------------- *) (* -------------------------------------------------------------------------- *)
(* --- Option --- *) (* --- Option --- *)
......
...@@ -162,14 +162,14 @@ let doc_input (type a) (input : a rq_input) = ...@@ -162,14 +162,14 @@ let doc_input (type a) (input : a rq_input) =
match input with match input with
| Pnone -> assert false | Pnone -> assert false
| Pdata _ -> [] | Pdata _ -> []
| Pfields fs -> [Syntax.fields ~title:"Input" (List.rev fs)] | Pfields fs -> [Syntax.fields ~title:"Input Params" (List.rev fs)]
(* json output syntax *) (* json output syntax *)
let doc_output (type b) (output : b rq_output) = let doc_output (type b) (output : b rq_output) =
match output with match output with
| Rnone -> assert false | Rnone -> assert false
| Rdata _ -> [] | Rdata _ -> []
| Rfields fs -> [Syntax.fields ~title:"Output" (List.rev fs)] | Rfields fs -> [Syntax.fields ~title:"Output Params" (List.rev fs)]
(* -------------------------------------------------------------------------- *) (* -------------------------------------------------------------------------- *)
(* --- Multi-Parameters Requests --- *) (* --- Multi-Parameters Requests --- *)
...@@ -339,16 +339,13 @@ let register_sig (type a b) (s : (a,b) signature) (process : rq -> a -> b) = ...@@ -339,16 +339,13 @@ let register_sig (type a b) (s : (a,b) signature) (process : rq -> a -> b) =
let skind = Main.string_of_kind s.kind in let skind = Main.string_of_kind s.kind in
let title = Printf.sprintf "`%s` %s" skind s.name in let title = Printf.sprintf "`%s` %s" skind s.name in
let index = [ Printf.sprintf "%s (`%s`)" s.name skind ] in let index = [ Printf.sprintf "%s (`%s`)" s.name skind ] in
let header = [ plain "Input", Center; plain "Output", Center] in let input =
let content = Syntax.define (plain "Input") (Syntax.text @@ sy_input s.input) in
[[ Syntax.text @@ sy_input s.input ; let output =
Syntax.text @@ sy_output s.output ]] Syntax.define (plain "Output") (Syntax.text @@ sy_output s.output) in
in
let synopsis = Table { caption=None ; header; content } in
let description = let description =
[ Block [Text s.descr ] ; synopsis ; Block s.details] @ Block ( Text s.descr :: input :: output :: s.details ) ::
doc_input s.input @ ( doc_input s.input @ doc_output s.output )
doc_output s.output
in in
let _ = let _ =
Doc.publish ~page:s.page ~name:s.name ~title ~index description [] Doc.publish ~page:s.page ~name:s.name ~title ~index description []
......
...@@ -60,6 +60,9 @@ let text { text } = text ...@@ -60,6 +60,9 @@ let text { text } = text
let protect a = let protect a =
if a.atomic then a.text else Markdown.(plain "(" @ a.text @ plain ")") if a.atomic then a.text else Markdown.(plain "(" @ a.text @ plain ")")
let define left right =
Markdown.(Block_quote [Block[Text ( left @ plain ":=" @ right )]])
let publish ~page ~name ~descr ~synopsis ?(details = []) () = let publish ~page ~name ~descr ~synopsis ?(details = []) () =
check_name name ; check_name name ;
check_page page name ; check_page page name ;
...@@ -68,15 +71,16 @@ let publish ~page ~name ~descr ~synopsis ?(details = []) () = ...@@ -68,15 +71,16 @@ let publish ~page ~name ~descr ~synopsis ?(details = []) () =
let index = [ Printf.sprintf "%s (`DATA`)" name ] in let index = [ Printf.sprintf "%s (`DATA`)" name ] in
let dref = Doc.href page id in let dref = Doc.href page id in
let dlink = Markdown.href ~text:(Markdown.emph name) dref in let dlink = Markdown.href ~text:(Markdown.emph name) dref in
let syntax = Markdown.(glue [ let data = Markdown.(plain "<" @ dlink @ plain ">") in
plain "<" ; dlink ; plain ">" ; plain ":=" ; synopsis.text ]) in let content = Markdown.(Block(
let content = Markdown.(Block ( text descr @ text syntax ) :: details) in [ Text descr ; define data synopsis.text ]
)) :: details in
let _href = Doc.publish ~page ~name:id ~title ~index content [] in let _href = Doc.publish ~page ~name:id ~title ~index content [] in
atom dlink atom dlink
(* -------------------------------------------------------------------------- *) (* -------------------------------------------------------------------------- *)
let unit = atom @@ Markdown.plain "-" let unit = atom @@ Markdown.code "null"
let any = atom @@ Markdown.emph "any" let any = atom @@ Markdown.emph "any"
let int = atom @@ Markdown.emph "int" let int = atom @@ Markdown.emph "int"
let ident = atom @@ Markdown.emph "ident" let ident = atom @@ Markdown.emph "ident"
...@@ -86,7 +90,7 @@ let boolean = atom @@ Markdown.emph "boolean" ...@@ -86,7 +90,7 @@ let boolean = atom @@ Markdown.emph "boolean"
let data name dref = atom @@ Markdown.href ~text:(Markdown.emph name) dref let data name dref = atom @@ Markdown.href ~text:(Markdown.emph name) dref
let escaped name = let escaped name =
Markdown.code (Printf.sprintf "'%s'" @@ String.escaped name) Markdown.code (Printf.sprintf "\"%s\"" @@ String.escaped name)
let tag name = atom @@ escaped name let tag name = atom @@ escaped name
let array a = atom @@ Markdown.(code "[" @ protect a @ code ", … ]") let array a = atom @@ Markdown.(code "[" @ protect a @ code ", … ]")
...@@ -146,7 +150,7 @@ let fields ?(title="Field") (fds : field list) = ...@@ -146,7 +150,7 @@ let fields ?(title="Field") (fds : field list) =
plain "Format", Center; plain "Format", Center;
plain "Description", Left plain "Description", Left
] in ] in
let row f = [ code f.fd_name ; f.fd_syntax.text ; f.fd_descr ] in let row f = [ escaped f.fd_name ; f.fd_syntax.text ; f.fd_descr ] in
Markdown.Table { Markdown.Table {
caption = None ; header ; content = List.map row fds ; caption = None ; header ; content = List.map row fds ;
} }
......
...@@ -57,6 +57,9 @@ type tag = { ...@@ -57,6 +57,9 @@ type tag = {
tag_descr : Markdown.text ; tag_descr : Markdown.text ;
} }
(** Syntactic definition: LEFT := RIGHT *)
val define : Markdown.text -> Markdown.text -> Markdown.block_element
(** Builds a table with tags description. (** Builds a table with tags description.
The [~title] is applied to the tag name column The [~title] is applied to the tag name column
(shall be capitalized, defaults to ["Tag"]). *) (shall be capitalized, defaults to ["Tag"]). *)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment