mirror of
https://github.com/jfmengels/elm-review.git
synced 2024-11-09 20:22:24 +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;
|
data += chunk;
|
||||||
});
|
});
|
||||||
resp.on('end', () => {
|
resp.on('end', () => {
|
||||||
resolve(JSON.parse(data));
|
resolve(data);
|
||||||
});
|
});
|
||||||
}).on("error", resolve);
|
}).on("error", resolve);
|
||||||
})
|
})
|
||||||
@ -26,14 +26,13 @@ if (!packageName) {
|
|||||||
|
|
||||||
async function downloadFiles() {
|
async function downloadFiles() {
|
||||||
const [elmJson, docsJson] = await Promise.all([
|
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`)
|
get(`https://package.elm-lang.org/packages/${packageName}/latest/docs.json`)
|
||||||
]);
|
]);
|
||||||
return [elmJson, docsJson];
|
return [elmJson, docsJson];
|
||||||
}
|
}
|
||||||
|
|
||||||
function createFile([elmJson, docsJson]) {
|
function createFile([elmJson, docsJson]) {
|
||||||
console.log(elmJson);
|
|
||||||
const moduleName = formatModuleName(packageName);
|
const moduleName = formatModuleName(packageName);
|
||||||
|
|
||||||
return `module Dependencies.${moduleName} exposing (dependency)
|
return `module Dependencies.${moduleName} exposing (dependency)
|
||||||
@ -77,15 +76,35 @@ elmJson =
|
|||||||
"""${JSON.stringify(elmJson, null, 4)}
|
"""${JSON.stringify(elmJson, null, 4)}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
`
|
|
||||||
|
docsJson : String
|
||||||
|
docsJson =
|
||||||
|
"""${docsJson
|
||||||
|
.split("\\\\n")
|
||||||
|
.map(s => s.split("\\n").join("\\\\n"))
|
||||||
|
.join("\\\\n")
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
`
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatModuleName(packageName) {
|
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()
|
downloadFiles()
|
||||||
.then(createFile)
|
.then(createFile)
|
||||||
.then(console.log)
|
.then(console.log)
|
||||||
.catch(console.error);
|
.catch(console.error);
|
Loading…
Reference in New Issue
Block a user