Skip to content

Commit

Permalink
fix: docs not being generated
Browse files Browse the repository at this point in the history
  • Loading branch information
abose committed Apr 14, 2023
1 parent 0261a87 commit ddf05b3
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 69 deletions.
19 changes: 4 additions & 15 deletions build/jsDocGenerate.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

/* eslint-env node */
import * as documentation from 'documentation';
import glob from "glob";
import {glob} from "glob";
import * as path from "path";
import * as fs from "fs";
import clc from 'cli-color';
Expand All @@ -45,26 +45,15 @@ function getIndexMarkdown(docRoot, filePaths) {

async function generateDocIndex(docRoot) {
const indexFileName = `${docRoot}GitHub-API-Index.md`;
let allDocFiles = await _getAllFiles(docRoot, '/**/*.md');
let allDocFiles = await _getAllFiles(docRoot, '**/*.md');
let indexMarkdown = getIndexMarkdown(docRoot, allDocFiles);
console.log("creating index file: ", clc.green(indexFileName));
fs.mkdirSync(path.dirname(indexFileName), { recursive: true })
fs.writeFileSync(indexFileName, indexMarkdown);
}

async function _getAllFiles(docRoot, globPattern) {
return new Promise((resolve, reject)=>{
let getDirectories = function (src, callback) {
glob(src + globPattern, callback);
};
getDirectories(docRoot, function (err, res) {
if (err) {
reject(err);
} else {
resolve(res);
}
});
});
return await glob(docRoot + globPattern, { ignore: 'node_modules/**' });
}

async function _processFile(filePath, srcRelativePath, generatedDocRoot) {
Expand Down Expand Up @@ -103,7 +92,7 @@ async function generateDocs() {
generatedDocRoot = generatedDocRoot + "/";
}
console.log(`Generating docs for "${clc.green(srcRoot)}" to folder "${clc.green(generatedDocRoot)}"`);
let allSrcFiles = await _getAllFiles(srcRoot, '/**/*.js')
let allSrcFiles = await _getAllFiles(srcRoot, '**/*.js');
console.log(`Found ${clc.blue(allSrcFiles.length)} js files. Scanning for files with comment // ${clc.blue(TAG_INCLUDE_IN_API_DOCS)} `);
console.log(`Cleaning Generating docs folder "${clc.green(generatedDocRoot)}"`);
fs.rmSync(generatedDocRoot, { recursive: true, force: true });
Expand Down
8 changes: 3 additions & 5 deletions docs/generatedApiDocs/index-API.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@ See [https://github.com/aicore/template-nodejs/wiki/How-To-Write-Docs][1] for mo

and markdown code!

// usage within core:
const Metrics = require("utils/Metrics");

// usage within default extensions:
const Metrics = brackets.getModule("utils/Metrics");
```js
console.log("write sample code examples with code blocks");
```

## helloWorld

Expand Down
84 changes: 42 additions & 42 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"cli-color": "2.0.3",
"documentation": "14.0.1",
"eslint": "8.38.0",
"glob": "9.3.4",
"glob": "^10.0.0",
"husky": "8.0.3",
"mocha": "10.2.0"
},
Expand Down
8 changes: 2 additions & 6 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,8 @@
* See https://github.com/aicore/template-nodejs/wiki/How-To-Write-Docs for more details on how to style docs.
* ### Use markdown headings!
* and markdown code!
* ```
* // usage within core:
* const Metrics = require("utils/Metrics");
*
* // usage within default extensions:
* const Metrics = brackets.getModule("utils/Metrics");
* ```js
* console.log("write sample code examples with code blocks");
* ```
*
* @module hello
Expand Down

0 comments on commit ddf05b3

Please sign in to comment.