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

[server] include readmes on demand only

parent d5e0d0a5
No related branches found
No related tags found
No related merge requests found
...@@ -327,10 +327,7 @@ let resolve_readme ~plugin = function ...@@ -327,10 +327,7 @@ let resolve_readme ~plugin = function
Printf.sprintf "%s/server/%s" Fc_config.datadir readme Printf.sprintf "%s/server/%s" Fc_config.datadir readme
| Plugin name -> | Plugin name ->
Printf.sprintf "%s/%s/server/%s" Fc_config.datadir name readme Printf.sprintf "%s/%s/server/%s" Fc_config.datadir name readme
in in Some file
if Sys.file_exists file
then Some file
else (Senv.warning "Can not find %S file" file ; None)
(* -------------------------------------------------------------------------- *) (* -------------------------------------------------------------------------- *)
(* --- Declarations --- *) (* --- Declarations --- *)
......
...@@ -45,6 +45,7 @@ type page = { ...@@ -45,6 +45,7 @@ type page = {
title : string ; title : string ;
order : int ; order : int ;
descr : Markdown.elements ; descr : Markdown.elements ;
readme: string option ;
mutable sections : section list ; mutable sections : section list ;
} }
...@@ -74,12 +75,9 @@ let page chapter ~title ?(descr=[]) ?readme ~filename () = ...@@ -74,12 +75,9 @@ let page chapter ~title ?(descr=[]) ?readme ~filename () =
Senv.failure "Duplicate page '%s' path@." path ; other Senv.failure "Duplicate page '%s' path@." path ; other
with Not_found -> with Not_found ->
let order = incr order ; !order in let order = incr order ; !order in
let descr = match readme with
| None -> Markdown.section ~title descr
| Some file -> Markdown.rawfile file @ descr in
let page = { let page = {
order ; rootdir ; path ; order ; rootdir ; path ;
chapter ; title ; descr ; chapter ; title ; descr ; readme ;
sections=[] ; sections=[] ;
} in } in
pages := Pages.add path page !pages ; page pages := Pages.add path page !pages ; page
...@@ -323,9 +321,17 @@ let dump ~root ?(meta=true) () = ...@@ -323,9 +321,17 @@ let dump ~root ?(meta=true) () =
Pages.iter Pages.iter
(fun path page -> (fun path page ->
Senv.feedback "[doc] Page: '%s'" path ; Senv.feedback "[doc] Page: '%s'" path ;
let body = Markdown.subsections page.descr (build [] page.sections) in
let title = page.title in let title = page.title in
pp_one_page ~root ~page:path ~title body ; let intro = match page.readme with
| None -> Markdown.section ~title page.descr
| Some file ->
if Sys.file_exists file
then Markdown.rawfile file @ page.descr
else (Senv.warning "Can not find %S file" file ;
Markdown.section ~title page.descr)
in
let body = Markdown.subsections page.descr (build [] page.sections) in
pp_one_page ~root ~page:path ~title (intro @ body) ;
if meta then if meta then
let path = Printf.sprintf "%s/%s.json" root path in let path = Printf.sprintf "%s/%s.json" root path in
Yojson.Basic.to_file path (metadata page) ; Yojson.Basic.to_file path (metadata page) ;
......
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