Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jsdoc to markdown functionality added #89

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/dist
/docs
/node_modules
/vircadia-dev-docs
VERSION.json
vircadia-web-sdk-*.tgz

Expand Down
65 changes: 65 additions & 0 deletions ConvertHtmlTomarkdown.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/* eslint-disable @typescript-eslint/restrict-plus-operands */
/* eslint-disable no-var */
/* eslint-disable vars-on-top */
/* eslint-disable no-param-reassign */
/* eslint-disable @typescript-eslint/restrict-template-expressions */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-var-requires */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-unused-vars */
/* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/no-shadow */
const fs = require("fs");
const path = require("path");
const util = require("util");
const TurndownService = require("turndown");

fs.mkdir("docs/markdown", (error) => {
if (error) {
console.log("Folder exists already.");
} else {
fs.mkdirSync("docs/markdown", { recursive: true });
}
});
function readFiles(dirname, onFileContent, onError) {
fs.readdir(dirname, function (err, filenames) {
if (err) {
onError(err);
return;
}
filenames.forEach(function (filename) {
fs.readFile(dirname + filename, "utf-8", function (err, content) {
if (err) {
onError(err);
return;
}
onFileContent(filename, content);
});
});
});
}
// for dev it would be docs/dev/
readFiles("docs/sdk/", function (filename, content) {
const fileExt = filename.split(".").pop();
const fileWithoutExt = filename.split(".").shift();
if (fileExt === "html") {
fs.readFile(path.join(__dirname, "docs", "dev", filename), "utf8", function (err, data) {
if (err) {
console.log(err);
process.exit(1);
}
const content = util.format(data);
const turndownService = new TurndownService();
const markdown = turndownService.turndown(content);
fs.writeFile(`./docs/markdown/${fileWithoutExt}.md`, markdown, (err) => {
if (err) {
console.log(err);
} else {
console.log("File written successfully\n");
}
});
});
}
}, function (err) {
// return null;
});
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,18 @@ npm run sdkdoc
Developer documentation (includes SDK API documentation):
```
npm run devdoc

```

### Generate markdown documentations

SDK API documentation:
```
npm run markdown-docs

```




### Publish to NPM
Expand Down
Loading