-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for .nojekyll file generation for docs
- Loading branch information
Showing
3 changed files
with
46 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import * as fs from "fs"; | ||
import * as path from "path"; | ||
import { RendererComponent, Component } from "typedoc/dist/lib/output/components"; | ||
import { Option, writeFile } from "typedoc/dist/lib/utils"; | ||
import { ParameterType } from "typedoc/dist/lib/utils/options/declaration"; | ||
import { ComponentHost } from "typedoc/dist/lib/utils/component"; | ||
import { Renderer } from "typedoc"; | ||
import { RendererEvent } from "typedoc/dist/lib/output/events"; | ||
|
||
@Component({ | ||
name: "no-jekyll", | ||
}) | ||
export class NoJekyllPlugin extends RendererComponent { | ||
@Option({ | ||
name: "noJekyll", | ||
help: "Generates a .nojekyll file as part of the output", | ||
type: ParameterType.Boolean | ||
}) | ||
noJekyll!: boolean; | ||
|
||
constructor(owner: ComponentHost) { | ||
if (!(owner instanceof Renderer)) throw new TypeError(); | ||
super(owner); | ||
} | ||
|
||
initialize() { | ||
super.initialize(); | ||
this.listenTo(this.owner, RendererEvent.END, this.onEnd); | ||
} | ||
|
||
private onEnd(event: RendererEvent) { | ||
if (this.noJekyll) { | ||
const filename = path.resolve(event.outputDirectory, ".nojekyll"); | ||
try { | ||
writeFile(filename, "", /*writeByteOrderMark*/ false); | ||
} | ||
catch (e) { | ||
this.application.logger.error("Could not write file %s", filename); | ||
} | ||
} | ||
} | ||
} |