Skip to content

Commit

Permalink
ready for reasonreact
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredly committed Apr 5, 2018
1 parent cd803fb commit 853f805
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
1 change: 1 addition & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ The binary is then in `./lib/bs/native/main.native`.

## itemized work to do

- [ ] respect @deprecated (and other things?)
- [x] aliases - only show the last item of a type path (full on hover)
- if the last item is "t", then also show the parent
- [x] A sidebar!
Expand Down
13 changes: 10 additions & 3 deletions src/Main.re
Original file line number Diff line number Diff line change
Expand Up @@ -358,9 +358,16 @@ let getMarkdowns = (projectName, base) => {

let generateProject = (projectName, base) => {
let compiledRoot = base /+ "lib/bs/js/";
if (!Files.exists(compiledRoot)) {
print_endline("You must run bucklescript first to generate the artifacts. " ++ compiledRoot ++ " not found.");
exit(1);
let compiledRoot = if (!Files.exists(compiledRoot)) {
let compiledRoot = base /+ "lib/bs/";
if (!Files.exists(compiledRoot)) {
print_endline("You must run bucklescript first to generate the artifacts. " ++ compiledRoot ++ " not found.");
exit(1);
} else {
compiledRoot
}
} else {
compiledRoot
};
let found = Files.collect(compiledRoot, name => Filename.check_suffix(name, ".cmt") || Filename.check_suffix(name, ".cmti"));
let markdowns = getMarkdowns(projectName, base);
Expand Down
17 changes: 10 additions & 7 deletions src/PrintType.re
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ let tuple_list = (items, loop) => {
str(")")
};

let replace = (one, two, text) => Str.global_replace(Str.regexp_string(one), two, text);
let htmlEscape = text => replace("<", "&lt;", text) |> replace(">", "&gt;");

let print_expr = (stringifier, typ) => {
let loop = stringifier.expr(stringifier);
open Types;
Expand Down Expand Up @@ -81,15 +84,15 @@ let print_expr = (stringifier, typ) => {
| args => tuple_list(args, loop)
}
}
| Tobject(_, _) => str("<object>")
| Tfield(_, _, _, _) => str("<field>")
| Tnil => str("nil")
| Tlink(inner) => loop(inner)
| Tsubst(inner) => loop(inner)
| Tvariant(_) => str("<variant>")
| Tunivar(_) => str("<univar>")
| Tpoly(_, _) => str("<poly>")
| Tpackage(_, _, _) => str("<package>")
| Tfield(_, _, _, _)
| Tnil
| Tvariant(_)
| Tunivar(_)
| Tpoly(_, _)
| Tpackage(_, _, _)
| Tobject(_, _) => str({Printtyp.type_expr(Format.str_formatter, typ); Format.flush_str_formatter()} |> htmlEscape)
}
};

Expand Down

0 comments on commit 853f805

Please sign in to comment.