-
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
Open
panglesd
wants to merge
6
commits into
ocaml:master
Choose a base branch
from
panglesd:root-in-sidebar
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Dedicated sidebar file #1250
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
64e4456
Move Json module to Odoc_utils
panglesd 8c11481
Sidebar generation: Add a command to generate the sidebar
panglesd 60da2d7
Sidebar generate: Add a "kind" to the json output
panglesd e4b03f3
Sidebar-generate: take sidebar as input in html-generate
panglesd d851077
Sidebar generate: Update driver
panglesd 0031767
Changelog entry for #1250
panglesd File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,87 +1,3 @@ | ||
(* Shared utility functions *) | ||
|
||
let optional_elt f ?a = function [] -> [] | l -> [ f ?a l ] | ||
|
||
module Json = struct | ||
type json = | ||
[ `Null | ||
| `Bool of bool | ||
| `Float of float | ||
| `String of string | ||
| `Array of json list | ||
| `Object of (string * json) list ] | ||
|
||
let rec buffer_add_json b = function | ||
| `Null -> Buffer.add_string b "null" | ||
| `Bool bool -> Buffer.add_string b (if bool then "true" else "false") | ||
| `Float f -> Buffer.add_string b (Printf.sprintf "%.16g" f) | ||
| `String s -> buffer_add_json_string b s | ||
| `Array els -> ( | ||
match els with | ||
| [] -> Buffer.add_string b "[]" | ||
| el :: els -> | ||
let add_sep_el b e = | ||
Buffer.add_char b ','; | ||
buffer_add_json b e | ||
in | ||
Buffer.add_char b '['; | ||
buffer_add_json b el; | ||
List.iter (add_sep_el b) els; | ||
Buffer.add_char b ']') | ||
| `Object mems -> ( | ||
match mems with | ||
| [] -> Buffer.add_string b "{}" | ||
| mem :: mems -> | ||
let add_mem b (k, v) = | ||
buffer_add_json_string b k; | ||
Buffer.add_char b ':'; | ||
buffer_add_json b v | ||
in | ||
let add_sep_mem b mem = | ||
Buffer.add_char b ','; | ||
add_mem b mem | ||
in | ||
Buffer.add_char b '{'; | ||
add_mem b mem; | ||
List.iter (add_sep_mem b) mems; | ||
Buffer.add_char b '}') | ||
|
||
and buffer_add_json_string b s = | ||
let is_control = function | ||
| '\x00' .. '\x1F' | '\x7F' -> true | ||
| _ -> false | ||
in | ||
let len = String.length s in | ||
let max_idx = len - 1 in | ||
let flush b start i = | ||
if start < len then Buffer.add_substring b s start (i - start) | ||
in | ||
let rec loop start i = | ||
match i > max_idx with | ||
| true -> flush b start i | ||
| false -> ( | ||
let next = i + 1 in | ||
match String.get s i with | ||
| '"' -> | ||
flush b start i; | ||
Buffer.add_string b "\\\""; | ||
loop next next | ||
| '\\' -> | ||
flush b start i; | ||
Buffer.add_string b "\\\\"; | ||
loop next next | ||
| c when is_control c -> | ||
flush b start i; | ||
Buffer.add_string b (Printf.sprintf "\\u%04X" (Char.code c)); | ||
loop next next | ||
| _c -> loop start next) | ||
in | ||
Buffer.add_char b '"'; | ||
loop 0 0; | ||
Buffer.add_char b '"' | ||
|
||
let to_string json = | ||
let b = Buffer.create 1024 in | ||
buffer_add_json b json; | ||
Buffer.contents b | ||
end |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 neverNone
: panglesd#34