Skip to content

Commit

Permalink
Merge pull request #1 from tobilg/master
Browse files Browse the repository at this point in the history
Merge in master of parent repo tobilg/api2html
  • Loading branch information
lukseven authored Sep 24, 2019
2 parents 03bc24d + 9821566 commit f493790
Show file tree
Hide file tree
Showing 6 changed files with 1,196 additions and 649 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,8 @@ typings/

# Output files
out/
docs/.DS_Store

.idea

.DS_Store
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,22 @@ Usage in `package.json`:
### Available commands

```bash
$ api2html --help

Usage: api2html [options] <sourcePath>

$ api2html --help
Usage: api2html [options] <sourcePath>

Options:

-V, --version output the version number
-r, --resolve <source> resolve external dependencies, source should be a url or a path
-o, --out <outputPath> output path for the resulting HTML document
-t, --theme <themeName> theme to use (see https://highlightjs.org/static/demo/ for a list)
-c, --customLogo <logoPath> use custom logo at the respective path
-u, --customLogoUrl <logoURL> url for the custom logo to point to
-C, --customCss use custom css
-P, --customCssPath <cssPath> use custom css file
-i, --includes <includesList> comma-separated list of files to include
-l, --languages <languageList> comma-separated list of languages to use for the language tabs (out of shell, http, javascript, javascript--nodejs, ruby, python, java, go)
-s, --search enable search
-m, --summary use summary instead of operationId for TOC
-S, --summary use summary instead of operationId for TOC
-b, --omitBody Omit top-level fake body parameter object
-R, --raw Show raw schemas in samples, not example values
-h, --help output usage information
Expand Down
34 changes: 30 additions & 4 deletions bin/api2html.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ const languageMap = {
"ruby": "Ruby",
"python": "Python",
"java": "Java",
"go": "Go"
"go": "Go",
"php": "PHP"
};

const icons = {
Expand All @@ -34,11 +35,13 @@ program
.option("-o, --out <outputPath>", "output path for the resulting HTML document")
.option("-t, --theme <themeName>", "theme to use (see https://highlightjs.org/static/demo/ for a list)")
.option("-c, --customLogo <logoPath>", "use custom logo at the respective path")
.option("-s, --customCss", "use custom css")
.option("-u, --customLogoUrl <logoURL>", "url for the custom logo to point to")
.option("-C, --customCss", "use custom css")
.option("-P, --customCssPath <cssPath>", "use custom css file")
.option("-i, --includes <includesList>", "comma-separated list of files to include")
.option("-l, --languages <languageList>", "comma-separated list of languages to use for the language tabs (out of " + Object.getOwnPropertyNames(languageMap).join(", ") + ")")
.option("-s, --search", "enable search")
.option("-m, --summary", "use summary instead of operationId for TOC")
.option("-S, --summary", "use summary instead of operationId for TOC")
.option("-b, --omitBody", "Omit top-level fake body parameter object")
.option("-R, --raw", "Show raw schemas in samples, not example values")
.parse(process.argv);
Expand Down Expand Up @@ -117,12 +120,31 @@ if (program.args.length === 0) {
// Check for custom logo option
if (program.customLogo) {
shinOptions.logo = program.customLogo;

// Check for logo url option
if (program.customLogoUrl) {
shinOptions['logo-url'] = program.customLogoUrl;
}
}

// Check for custom css option
if (program.customCss) {
shinOptions.customCss = true;
}

let customCss = "";
if (program.customCssPath) {
shinOptions.customCss = true;

try {
customCss = fs.readFileSync(path.resolve(program.customCssPath), "utf8");
console.log(chalk.green(icons.ok) + " Read custom css file!");
}
catch (error) {
console.log(chalk.red(icons.fail) + " Error loading custom css file:");
console.log(err.message);
}
}

let api = null;

Expand Down Expand Up @@ -158,7 +180,11 @@ if (program.args.length === 0) {
process.exit(-1);
}

console.log(chalk.green(icons.ok) + " Rendered HTML form markdown!");
console.log(chalk.green(icons.ok) + " Rendered HTML from markdown!");

if (customCss) {
html = html.replace (/\/\* place your custom CSS overrides here \*\//i, customCss);
}

try {

Expand Down
Loading

0 comments on commit f493790

Please sign in to comment.