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

Merged
merged 8 commits into from
Dec 6, 2024
Merged

Dedicated sidebar file #1250

merged 8 commits into from
Dec 6, 2024

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
panglesd added a commit to panglesd/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.

src/driver/odoc_unit.ml Show resolved Hide resolved
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 ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, anyway this changes to a more generic sidebar json in #1251.

Copy link
Collaborator

@Julow Julow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect, let's merge !

@Julow Julow merged commit b09cf3b into ocaml:master Dec 6, 2024
12 checks passed
panglesd added a commit to panglesd/sherlodoc that referenced this pull request Dec 9, 2024
Several changes:
- Entries are now defined in the `odoc_index` library,
- Entries can have new kinds (pages, source, ...)
- Indexes have the form of "skeletons of entries", that can be folded.
- Indexes can be created by odoc with the `odoc compile-index` command, and
  then consumed by sherlodoc.

These changes come from:
- ocaml/odoc#1228
- ocaml/odoc#1232
- ocaml/odoc#1233
- ocaml/odoc#1244
- ocaml/odoc#1250
- ocaml/odoc#1251
jonludlam pushed a commit to jonludlam/odoc that referenced this pull request Dec 10, 2024
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