-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dedicated sidebar file #1250
base: master
Are you sure you want to change the base?
Dedicated sidebar file #1250
Conversation
And not the index file, to avoid doing multiple times the same thing
e6ff8d0
to
0031767
Compare
open_out_bin (Fs.File.to_string output) | ||
in | ||
let output = Format.formatter_of_out_channel output_channel in | ||
Format.fprintf output "%s" text |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's best practice to close the channel. We have Fun.protect
in utils to help close properly.
("modules", `Array (List.map (Tree.to_json toc_to_json) units)); | ||
] | ||
|
||
let sidebar_to_json ({ pages; libraries } : Odoc_document.Sidebar.t) = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this function be in the HTML generator ? That's where the other JSON function are located.
The HTML generator is used in these functions.
type index = { | ||
pkg_args : Pkg_args.t; | ||
output_file : Fpath.t; | ||
json : bool; | ||
search_dir : Fpath.t; | ||
sidebar : sidebar option; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found that sidebar
is never None
: panglesd#34
let sidebar_to_json ({ pages; libraries } : Odoc_document.Sidebar.t) = | ||
let pages = List.map pages_to_json pages in | ||
let libraries = List.map libs_to_json libraries in | ||
`Object [ ("pages", `Array pages); ("libraries", `Array libraries) ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The JSON is slightly confusing with two things called pages. Shouldn't this be called manuals
?
This PR adds a
odoc sidebar-generate
command which takes an index (.odoc-index
) as input and produces a sidebar file (.odoc-sidebar
or.json
if--json
is passed).This allows to reduce the time spent HTML generating, as sidebar files are much smaller than index files (they don't contain values and other entries that are not shown in the sidebar anyway).
The json format is likely to change with #1247.