@@ -50,8 +50,7 @@ if Fs.existsSync(dirVersion) {
50
50
Fs .mkdirSync (dirVersion )
51
51
}
52
52
53
- // "Js.res" does not work for some reason
54
- let entryPointFiles = ["Belt.res" , "Dom.res" , "Stdlib.res" ]
53
+ let entryPointFiles = ["Belt.res" , "Dom.res" , "Js.res" , "Stdlib.res" ]
55
54
56
55
let hiddenModules = ["Js.Internal" , "Js.MapperRt" ]
57
56
@@ -72,23 +71,32 @@ type section = {
72
71
73
72
let env = Process .env
74
73
75
- let docsDecoded = entryPointFiles -> Array .map (libFile => {
76
- let entryPointFile = Path .join2 (compilerLibPath , libFile )
74
+ let docsDecoded = entryPointFiles -> Array .map (libFile =>
75
+ try {
76
+ let entryPointFile = Path .join2 (compilerLibPath , libFile )
77
77
78
- Dict .set (env , "FROM_COMPILER" , "false" )
78
+ Dict .set (env , "FROM_COMPILER" , "false" )
79
79
80
- let output =
81
- ChildProcess .execSync (
80
+ let output = ChildProcess .execSync (
82
81
` ./node_modules/.bin/rescript-tools doc ${entryPointFile}` ,
82
+ ~options = {
83
+ maxBuffer : 30_000_000 .,
84
+ },
83
85
)-> Buffer .toString
84
86
85
- output
86
- -> JSON .parseExn
87
- -> Docgen .decodeFromJson
88
- })
89
-
90
- let isStdlib = (id : string ) => String .startsWith (id , "Stdlib" )
91
- let replaceIdWithStdlib = (id : string ) => isStdlib (id ) ? String .replace (id , "Stdlib" , "Core" ) : id
87
+ output
88
+ -> JSON .parseExn
89
+ -> Docgen .decodeFromJson
90
+ } catch {
91
+ | Exn .Error (error ) =>
92
+ Console .error (
93
+ ` Error while generating docs from ${libFile}: ${error
94
+ -> Error.message
95
+ -> Option.getOr("[no message]" )}` ,
96
+ )
97
+ Error .raise (error )
98
+ }
99
+ )
92
100
93
101
let removeStdlibOrPrimitive = s => s -> String .replaceAllRegExp (/ Stdlib_ |Primitive_js_extern \./ g , "" )
94
102
@@ -111,7 +119,6 @@ let docs = docsDecoded->Array.map(doc => {
111
119
if Array .includes (hiddenModules , id ) {
112
120
getModules (rest , moduleNames )
113
121
} else {
114
- let id = replaceIdWithStdlib (id )
115
122
getModules (
116
123
list {... rest , ... List .fromArray (items )},
117
124
list {{id , items , name , docstrings }, ... moduleNames },
@@ -121,7 +128,7 @@ let docs = docsDecoded->Array.map(doc => {
121
128
| list {} => moduleNames
122
129
}
123
130
124
- let id = replaceIdWithStdlib ( doc .name )
131
+ let id = doc .name
125
132
126
133
let top = {id , name : id , docstrings : doc .docstrings , items : topLevelItems }
127
134
let submodules = getModules (doc .items -> List .fromArray , list {})-> List .toArray
@@ -135,7 +142,6 @@ let allModules = {
135
142
let encodeItem = (docItem : Docgen .item ) => {
136
143
switch docItem {
137
144
| Value ({id , name , docstrings , signature , ?deprecated }) => {
138
- let id = replaceIdWithStdlib (id )
139
145
let dict = Dict .fromArray (
140
146
[
141
147
("id" , id -> String ),
@@ -164,7 +170,6 @@ let allModules = {
164
170
}
165
171
166
172
| Type ({id , name , docstrings , signature , ?deprecated }) =>
167
- let id = replaceIdWithStdlib (id )
168
173
let dict = Dict .fromArray (
169
174
[
170
175
("id" , id -> String ),
@@ -194,10 +199,8 @@ let allModules = {
194
199
-> Array .filterMap (item => encodeItem (item ))
195
200
-> Array
196
201
197
- let id = replaceIdWithStdlib (mod .id )
198
-
199
202
let rest = Dict .fromArray ([
200
- ("id" , id -> String ),
203
+ ("id" , mod . id -> String ),
201
204
("name" , mod .name -> String ),
202
205
("docstrings" , mod .docstrings -> Array .map (s => s -> String )-> Array ),
203
206
("items" , items ),
@@ -220,8 +223,6 @@ let () = {
220
223
allModules -> Array .forEach (((topLevelName , mod )) => {
221
224
let json = JSON .Object (mod )
222
225
223
- let topLevelName = replaceIdWithStdlib (topLevelName )
224
-
225
226
Fs .writeFileSync (
226
227
Path .join ([dirVersion , ` ${topLevelName-> String.toLowerCase}.json` ]),
227
228
json -> JSON .stringify (~space = 2 ),
@@ -264,7 +265,6 @@ let () = {
264
265
}
265
266
266
267
let tocTree = docsDecoded -> Array .map (({name , items }) => {
267
- let name = replaceIdWithStdlib (name )
268
268
let path = name -> String .toLowerCase
269
269
(
270
270
path ,
0 commit comments