API ref now has bootstrap
This commit is contained in:
parent
19387f6c49
commit
5d89427fbd
|
@ -79,11 +79,14 @@ Generating an API reference for a library is a heavy and slow operation, so it n
|
|||
"apiref": {
|
||||
"lang": "nim",
|
||||
"mainfile": "nimcrypto.nim",
|
||||
"subfolder": "nimcrypto"
|
||||
"subfolder": "nimcrypto",
|
||||
"bootstrap": "nimble install -y" // <-- OPTIONAL
|
||||
},
|
||||
```
|
||||
|
||||
The only supported language is currently `nim` and it requires the `0.20.0` devel version! The mainfile is the entry file through which the generator starts generating the doc, this might be language specific like in the case of Nim. In Nim's case, the JSON is generated in a subfolder, which is specified in the `subfolder` value. For Nim, all three values are required.
|
||||
The only supported language is currently `nim` and it requires a version at or above 0.19.6! The mainfile is the entry file through which the generator starts generating the doc, this might be language specific like in the case of Nim. In Nim's case, the JSON is generated in a subfolder, which is specified in the `subfolder` value. For Nim, all three values are required.
|
||||
|
||||
If the `bootstrap` option is provided, the generator will run this command verbatim inside the folder of the cloned repo. This is useful for installing dependencies or pre-generating things inside the folder of the lib itself. **Note that if your bootstrap is something like `nimble install -y`, your global nimble folder will be updated! Back it up before launching the generator and then go [yell at @dom96](https://github.com/nim-lang/nimble).**
|
||||
|
||||
## Enhancing the docs further
|
||||
|
||||
|
|
|
@ -122,15 +122,14 @@ module.exports = {
|
|||
const apiRefTemplateNim = "#### {name} \n\n {description} \n\n```nim{code}\n```\n\n";
|
||||
console.log("Starting nimdoc generation for repo " + repos[i].label);
|
||||
|
||||
execSync('git clone ' + repos[i].location + " " + repos[i].name, (err, stdout, stderr) => {
|
||||
if (err) {
|
||||
console.error("Could not launch git clone");
|
||||
return;
|
||||
}
|
||||
execSync('git clone ' + repos[i].location + " " + repos[i].name);
|
||||
|
||||
console.log(`stdout: ${stdout}`);
|
||||
console.log(`stderr: ${stderr}`);
|
||||
});
|
||||
// Bootstrap if needed
|
||||
if (repos[i].apiref.bootstrap !== undefined) {
|
||||
process.chdir(repos[i].name);
|
||||
console.log(execSync(repos[i].apiref.bootstrap).toString());
|
||||
process.chdir('..');
|
||||
}
|
||||
|
||||
// Two passes because jsondoc is kinda broken
|
||||
// Bug: https://github.com/nim-lang/Nim/issues/11953
|
||||
|
@ -143,14 +142,15 @@ module.exports = {
|
|||
|
||||
let dir = repos[i].name + '/' + repos[i].apiref.subfolder;
|
||||
|
||||
let extension = '.json';
|
||||
let jsonFiles = [];
|
||||
// Consume main file
|
||||
jsonFiles.push(JSON.parse(fs.readFileSync(dir + "/" + repos[i].apiref.mainfile.split(".nim")[0] + ".json")));
|
||||
jsonFiles.push(JSON.parse(fs.readFileSync(dir + "/" + repos[i].apiref.mainfile.split(".nim")[0] + extension)));
|
||||
// Consume all other files
|
||||
let subdir = dir + "/" + repos[i].apiref.mainfile.split(".nim")[0];
|
||||
let files = fs.readdirSync(subdir);
|
||||
files.forEach(file => {
|
||||
if(/\.json$/.test(file)) {
|
||||
if(file.indexOf(extension ) > -1) {
|
||||
let jsonContent = fs.readFileSync(subdir + "/" + file);
|
||||
jsonFiles.push(
|
||||
JSON.parse(jsonContent)
|
||||
|
|
|
@ -5,6 +5,12 @@
|
|||
"label": "Chronicles",
|
||||
"location": "https://github.com/status-im/nim-chronicles",
|
||||
"update": true,
|
||||
"apiref": {
|
||||
"lang": "nim",
|
||||
"mainfile": "chronicles.nim",
|
||||
"subfolder": "htmldocs",
|
||||
"bootstrap": "nimble install -y"
|
||||
},
|
||||
"frontMatter": {
|
||||
"sidebar": "auto"
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue