typedoc-plugin-markdown
Advanced tools
Comparing version 2.2.5 to 2.2.6
@@ -14,36 +14,13 @@ "use strict"; | ||
super.initialize(); | ||
const platform = this.application.options.getValue('platform'); | ||
const namedAnchors = this.application.options.getValue('namedAnchors'); | ||
const hideBreadcrumbs = this.application.options.getValue('hideBreadcrumbs'); | ||
const hideIndexes = this.application.options.getValue('hideIndexes'); | ||
const hideSourceFiles = this.application.options.getValue('hideSources'); | ||
Handlebars.registerHelper('ifNamedAnchors', function (options) { | ||
if (namedAnchors) { | ||
return options.fn(this); | ||
} | ||
return options.inverse(this); | ||
return namedAnchors ? options.fn(this) : options.inverse(this); | ||
}); | ||
Handlebars.registerHelper('ifMainTitle', function (options) { | ||
if (platform === 'docusaurus') { | ||
return options.inverse(this); | ||
} | ||
return options.fn(this); | ||
}); | ||
Handlebars.registerHelper('ifBreadcrumbs', function (options) { | ||
if (hideBreadcrumbs || platform === 'gitbook' || platform === 'vuepress') { | ||
return options.inverse(this); | ||
} | ||
return options.fn(this); | ||
return hideBreadcrumbs ? options.inverse(this) : options.fn(this); | ||
}); | ||
Handlebars.registerHelper('ifIndexes', function (options) { | ||
if (hideIndexes || platform === 'vuepress') { | ||
return options.inverse(this); | ||
} | ||
return options.fn(this); | ||
}); | ||
Handlebars.registerHelper('ifSources', function (options) { | ||
if (hideSourceFiles) { | ||
return options.inverse(this); | ||
} | ||
return options.fn(this); | ||
return hideSourceFiles ? options.inverse(this) : options.fn(this); | ||
}); | ||
@@ -50,0 +27,0 @@ } |
@@ -29,3 +29,3 @@ "use strict"; | ||
} | ||
const subThemes = ['docusaurus', 'vuepress', 'gitbook', 'bitbucket']; | ||
const subThemes = ['docusaurus', 'docusaurus2', 'vuepress', 'gitbook', 'bitbucket']; | ||
if (subThemes.includes(theme)) { | ||
@@ -32,0 +32,0 @@ options.setValue('theme', path.join(__dirname, 'subthemes', theme)); |
{ | ||
"name": "typedoc-plugin-markdown", | ||
"version": "2.2.5", | ||
"version": "2.2.6", | ||
"description": "A plugin for TypeDoc that enables TypeScript API documentation to be generated in Markdown.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -14,2 +14,5 @@ # typedoc-plugin-markdown | ||
By default, the Markdown theme will attempt to render standard CommonMark, suitable for the majority of Markdown engines. | ||
It follows the same structure and file patterns as the default HTML theme. | ||
## Installation | ||
@@ -24,3 +27,3 @@ | ||
```bash | ||
$ node_modules/.bin/typedoc --plugin typedoc-plugin-markdown [args] | ||
$ typedoc --plugin typedoc-plugin-markdown [args] | ||
``` | ||
@@ -35,16 +38,6 @@ | ||
**Configuring a theme** | ||
The following arguments can be used in addition to the default [TypeDoc arguments](https://github.com/TypeStrong/typedoc#arguments). | ||
By default, the Markdown theme will attempt to render standard CommonMark, suitable for the majority of Markdown engines. | ||
It follows the same structure and file patterns as the default HTML theme. The plugin also comes packaged with some additional built-in themes and can be extended with a custom theme. | ||
- `--theme`<br> | ||
- `markdown` Standard Markdown theme (default). | ||
- `docusaurus` Adds Front Matter header to pages, and attempts to update sidebars.json. | ||
- `vuepress` Adds Front Matter header to pages, and configures vuepress configs. | ||
- `bitbucket` Parses internal anchor links to support Bitbucket's internal anchor linking. | ||
- `path/to/theme` Path to a custom theme. | ||
**Configuring output** | ||
- `--theme <markdown|docusaurus|docusaurus2|vuepress|bitbucket|path/to/theme>`<br> | ||
Specify the theme that should be used. Defaults to `markdown`. Please read the [theming guide](https://github.com/tgreyuk/typedoc-plugin-markdown/blob/master/THEMES.md) for further details. | ||
- `--namedAnchors`<br> | ||
@@ -57,57 +50,4 @@ Use HTML named anchors as fragment identifiers for engines that do not automatically assign header ids. | ||
## Custom theme | ||
The Markdown theme packaged with the plugin can also be extended with a custom Markdown theme using the standard TypeDoc theming pattern as per https://typedoc.org/guides/themes/. | ||
### Create a theme.js class | ||
As per the theme docs create a `theme.js` file that extends the Markdown theme, and TypeDoc will then attempt to load from a given location. | ||
_custom-theme-dir/theme.js_ | ||
```js | ||
const MarkdownTheme = require('typedoc-plugin-markdown/dist/theme'); | ||
class CustomMarkdownTheme extends MarkdownTheme.default { | ||
constructor(renderer, basePath) { | ||
super(renderer, basePath); | ||
} | ||
} | ||
exports.default = CustomMarkdownTheme; | ||
``` | ||
### Update resources | ||
If used with the plugin, the theme will inherit the resources of the Markdown theme (https://github.com/tgreyuk/typedoc-plugin-markdown/tree/master/src/resources), rather than the default theme. These can be overdidden by shadowing (or adding new) resources in the custom theme directory. | ||
The resources are based on and follow the same structure as [typedoc-default-themes](https://github.com/TypeStrong/typedoc-default-themes) | ||
### Building the theme | ||
#### CLI | ||
``` | ||
node_modules/.bin/typedoc ./src --theme ./custom-theme-dir --out docs | ||
``` | ||
#### API | ||
```js | ||
const { Application } = require('typedoc'); | ||
const path = require('path'); | ||
const app = new Application({ | ||
theme: path.join(__dirname, 'custom-theme-dir'), | ||
plugin: 'typedoc-plugin-markdown', | ||
}); | ||
const project = app.convert(app.expandInputFiles(['src'])); | ||
app.generateDocs(project, 'docs'); | ||
``` | ||
See https://typedoc.org/guides/installation/#node-module | ||
## License | ||
MIT | ||
[MIT](https://github.com/tgreyuk/typedoc-plugin-markdown/blob/master/LICENSE) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
74806
84
1499
50
7