Skip to content
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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Conversation

panglesd
Copy link
Collaborator

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.

panglesd added a commit to panglesd/odoc that referenced this pull request Nov 18, 2024
jonludlam pushed a commit to jonludlam/odoc that referenced this pull request Nov 21, 2024
jonludlam pushed a commit to jonludlam/odoc that referenced this pull request Nov 25, 2024
jonludlam pushed a commit to jonludlam/odoc that referenced this pull request Nov 28, 2024
open_out_bin (Fs.File.to_string output)
in
let output = Format.formatter_of_out_channel output_channel in
Format.fprintf output "%s" text
Copy link
Collaborator

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) =
Copy link
Collaborator

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;
Copy link
Collaborator

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) ]
Copy link
Collaborator

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 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants