@@ -50,8 +50,7 @@ if Fs.existsSync(dirVersion) {
5050 Fs .mkdirSync (dirVersion )
5151}
5252
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" ]
5554
5655let hiddenModules = ["Js.Internal" , "Js.MapperRt" ]
5756
@@ -72,23 +71,32 @@ type section = {
7271
7372let env = Process .env
7473
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 )
7777
78- Dict .set (env , "FROM_COMPILER" , "false" )
78+ Dict .set (env , "FROM_COMPILER" , "false" )
7979
80- let output =
81- ChildProcess .execSync (
80+ let output = ChildProcess .execSync (
8281 ` ./node_modules/.bin/rescript-tools doc ${entryPointFile}` ,
82+ ~options = {
83+ maxBuffer : 30_000_000 .,
84+ },
8385 )-> Buffer .toString
8486
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+ )
92100
93101let removeStdlibOrPrimitive = s => s -> String .replaceAllRegExp (/ Stdlib_ |Primitive_js_extern \./ g , "" )
94102
@@ -111,7 +119,6 @@ let docs = docsDecoded->Array.map(doc => {
111119 if Array .includes (hiddenModules , id ) {
112120 getModules (rest , moduleNames )
113121 } else {
114- let id = replaceIdWithStdlib (id )
115122 getModules (
116123 list {... rest , ... List .fromArray (items )},
117124 list {{id , items , name , docstrings }, ... moduleNames },
@@ -121,7 +128,7 @@ let docs = docsDecoded->Array.map(doc => {
121128 | list {} => moduleNames
122129 }
123130
124- let id = replaceIdWithStdlib ( doc .name )
131+ let id = doc .name
125132
126133 let top = {id , name : id , docstrings : doc .docstrings , items : topLevelItems }
127134 let submodules = getModules (doc .items -> List .fromArray , list {})-> List .toArray
@@ -135,7 +142,6 @@ let allModules = {
135142 let encodeItem = (docItem : Docgen .item ) => {
136143 switch docItem {
137144 | Value ({id , name , docstrings , signature , ?deprecated }) => {
138- let id = replaceIdWithStdlib (id )
139145 let dict = Dict .fromArray (
140146 [
141147 ("id" , id -> String ),
@@ -164,7 +170,6 @@ let allModules = {
164170 }
165171
166172 | Type ({id , name , docstrings , signature , ?deprecated }) =>
167- let id = replaceIdWithStdlib (id )
168173 let dict = Dict .fromArray (
169174 [
170175 ("id" , id -> String ),
@@ -194,10 +199,8 @@ let allModules = {
194199 -> Array .filterMap (item => encodeItem (item ))
195200 -> Array
196201
197- let id = replaceIdWithStdlib (mod .id )
198-
199202 let rest = Dict .fromArray ([
200- ("id" , id -> String ),
203+ ("id" , mod . id -> String ),
201204 ("name" , mod .name -> String ),
202205 ("docstrings" , mod .docstrings -> Array .map (s => s -> String )-> Array ),
203206 ("items" , items ),
@@ -220,8 +223,6 @@ let () = {
220223 allModules -> Array .forEach (((topLevelName , mod )) => {
221224 let json = JSON .Object (mod )
222225
223- let topLevelName = replaceIdWithStdlib (topLevelName )
224-
225226 Fs .writeFileSync (
226227 Path .join ([dirVersion , ` ${topLevelName-> String.toLowerCase}.json` ]),
227228 json -> JSON .stringify (~space = 2 ),
@@ -264,7 +265,6 @@ let () = {
264265 }
265266
266267 let tocTree = docsDecoded -> Array .map (({name , items }) => {
267- let name = replaceIdWithStdlib (name )
268268 let path = name -> String .toLowerCase
269269 (
270270 path ,
0 commit comments