mirror of
https://github.com/jfmengels/elm-review.git
synced 2024-09-19 03:57:20 +03:00
WIP Attempt generation of docs.json
This commit is contained in:
parent
3b711ffc85
commit
ac445bb695
@ -9,7 +9,7 @@ function get(url) {
|
||||
data += chunk;
|
||||
});
|
||||
resp.on('end', () => {
|
||||
resolve(JSON.parse(data));
|
||||
resolve(data);
|
||||
});
|
||||
}).on("error", resolve);
|
||||
})
|
||||
@ -26,14 +26,13 @@ if (!packageName) {
|
||||
|
||||
async function downloadFiles() {
|
||||
const [elmJson, docsJson] = await Promise.all([
|
||||
get(`https://package.elm-lang.org/packages/${packageName}/latest/elm.json`),
|
||||
get(`https://package.elm-lang.org/packages/${packageName}/latest/elm.json`).then(s => JSON.parse(s)),
|
||||
get(`https://package.elm-lang.org/packages/${packageName}/latest/docs.json`)
|
||||
]);
|
||||
return [elmJson, docsJson];
|
||||
}
|
||||
|
||||
function createFile([elmJson, docsJson]) {
|
||||
console.log(elmJson);
|
||||
const moduleName = formatModuleName(packageName);
|
||||
|
||||
return `module Dependencies.${moduleName} exposing (dependency)
|
||||
@ -77,15 +76,35 @@ elmJson =
|
||||
"""${JSON.stringify(elmJson, null, 4)}
|
||||
"""
|
||||
|
||||
`
|
||||
|
||||
docsJson : String
|
||||
docsJson =
|
||||
"""${docsJson
|
||||
.split("\\\\n")
|
||||
.map(s => s.split("\\n").join("\\\\n"))
|
||||
.join("\\\\n")
|
||||
}
|
||||
"""
|
||||
|
||||
`
|
||||
}
|
||||
|
||||
function formatModuleName(packageName) {
|
||||
return "ElmCore"
|
||||
return "ElmParser"
|
||||
}
|
||||
|
||||
function formatModule(moduleDoc) {
|
||||
// if (JSON.stringify(moduleDoc).includes("initialize 4")) {
|
||||
// console.log(JSON.stringify(moduleDoc).slice(2470, 2530))
|
||||
// }
|
||||
|
||||
return JSON.stringify(JSON.stringify(moduleDoc));
|
||||
// .split("\\n")
|
||||
// .join("\\\\n");
|
||||
}
|
||||
|
||||
|
||||
downloadFiles()
|
||||
.then(createFile)
|
||||
.then(console.log)
|
||||
.catch(console.error);
|
||||
.catch(console.error);
|
Loading…
Reference in New Issue
Block a user