typedoc-plugin-markdown
Advanced tools
Comparing version 1.0.15 to 1.1.0
@@ -15,3 +15,3 @@ "use strict"; | ||
component: 'markdown', | ||
help: 'Markdown Plugin: Markdown parser ie: "bitbucket"', | ||
help: 'Markdown Plugin: (github|bitbucket|gitbook) Specifies the markdown rendering engine. Defaults to github.', | ||
name: 'mdFlavour', | ||
@@ -18,0 +18,0 @@ type: declaration_1.ParameterType.String, |
"use strict"; | ||
var __assign = (this && this.__assign) || Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var index_1 = require("typedoc/dist/lib/models/reflections/index"); | ||
var service_1 = require("../service"); | ||
var theme_service_1 = require("../theme.service"); | ||
function compileGroup(group, parent) { | ||
var options = service_1.ThemeService.getOptions(); | ||
var options = theme_service_1.ThemeService.getOptions(); | ||
var md = ''; | ||
@@ -14,3 +22,3 @@ if (!options.excludePrivate || !group.allChildrenArePrivate) { | ||
} | ||
md = service_1.ThemeService.compilePartial("members.group.hbs", Object.assign(group, { displayTitle: displayTitle, isMainTitle: isMainTitle })); | ||
md = theme_service_1.ThemeService.compilePartial("members.group.hbs", __assign({}, group, { displayTitle: displayTitle, isMainTitle: isMainTitle })); | ||
} | ||
@@ -17,0 +25,0 @@ return md; |
"use strict"; | ||
var __assign = (this && this.__assign) || Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var index_1 = require("typedoc/dist/lib/models/reflections/index"); | ||
var service_1 = require("../service"); | ||
var theme_service_1 = require("../theme.service"); | ||
function compileIndex(member) { | ||
var md = ''; | ||
if (member.kind !== index_1.ReflectionKind.Interface) { | ||
md = service_1.ThemeService.compilePartial('index.hbs', Object.assign(member)); | ||
md = theme_service_1.ThemeService.compilePartial('index.hbs', __assign({}, member)); | ||
} | ||
@@ -10,0 +18,0 @@ return md; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var index_1 = require("typedoc/dist/lib/models/reflections/index"); | ||
var service_1 = require("../service"); | ||
var theme_service_1 = require("../theme.service"); | ||
function compileMember(member) { | ||
var options = service_1.ThemeService.getOptions(); | ||
var options = theme_service_1.ThemeService.getOptions(); | ||
var md = ''; | ||
@@ -11,9 +11,9 @@ if (!(options.excludePrivate && member.flags.isPrivate)) { | ||
case index_1.ReflectionKind.Constructor: | ||
md = service_1.ThemeService.compilePartial('member.constructor.hbs', member); | ||
md = theme_service_1.ThemeService.compilePartial('member.constructor.hbs', member); | ||
break; | ||
case index_1.ReflectionKind.ObjectLiteral: | ||
md = service_1.ThemeService.compilePartial('member.object.hbs', member); | ||
md = theme_service_1.ThemeService.compilePartial('member.object.hbs', member); | ||
break; | ||
default: | ||
md = service_1.ThemeService.compilePartial('member.hbs', member); | ||
md = theme_service_1.ThemeService.compilePartial('member.hbs', member); | ||
} | ||
@@ -20,0 +20,0 @@ } |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var service_1 = require("../service"); | ||
var theme_service_1 = require("../theme.service"); | ||
function compileSources(sources) { | ||
var options = service_1.ThemeService.getOptions(); | ||
var options = theme_service_1.ThemeService.getOptions(); | ||
var md = ''; | ||
if (!options.mdHideSources) { | ||
md = service_1.ThemeService.compilePartial('member.sources.hbs', sources); | ||
md = theme_service_1.ThemeService.compilePartial('member.sources.hbs', sources); | ||
} | ||
@@ -10,0 +10,0 @@ return md; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var service_1 = require("../service"); | ||
var flavour_enum_1 = require("../enums/flavour.enum"); | ||
var theme_service_1 = require("../theme.service"); | ||
function getAnchor(anchor) { | ||
var options = service_1.ThemeService.getOptions(); | ||
return options.mdFlavour === 'bitbucket' ? '' : "<a id=\"" + anchor + "\"></a>"; | ||
var options = theme_service_1.ThemeService.getOptions(); | ||
return options.mdFlavour === flavour_enum_1.Flavour.BITBUCKET ? '' : "<a id=\"" + anchor + "\"></a>"; | ||
} | ||
exports.getAnchor = getAnchor; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var service_1 = require("../service"); | ||
var theme_service_1 = require("../theme.service"); | ||
function getSourceFile(fileName, line, url) { | ||
var options = service_1.ThemeService.getOptions(); | ||
var options = theme_service_1.ThemeService.getOptions(); | ||
var md = 'Defined in '; | ||
@@ -7,0 +7,0 @@ if (options.mdFlavour === 'bitbucket' && options.mdSourceRepo) { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var index_1 = require("typedoc/dist/lib/models/reflections/index"); | ||
var service_1 = require("../service"); | ||
var theme_service_1 = require("../theme.service"); | ||
function ifDisplayIndexItem(item, opts) { | ||
var options = service_1.ThemeService.getOptions(); | ||
var options = theme_service_1.ThemeService.getOptions(); | ||
if ((!item.anchor && !item.groups && item.kind !== index_1.ReflectionKind.Interface) || | ||
@@ -8,0 +8,0 @@ (options.excludePrivate && item.flags.isPrivate)) { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var service_1 = require("../service"); | ||
var theme_service_1 = require("../theme.service"); | ||
function ifGroupContainesVisibleItems(group, opts) { | ||
var options = service_1.ThemeService.getOptions(); | ||
var options = theme_service_1.ThemeService.getOptions(); | ||
if (!options.excludePrivate || !group.allChildrenArePrivate) { | ||
@@ -7,0 +7,0 @@ return opts.fn(this); |
@@ -12,2 +12,10 @@ "use strict"; | ||
})(); | ||
var __assign = (this && this.__assign) || Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -17,6 +25,6 @@ var fs = require("fs"); | ||
var index_1 = require("typedoc/dist/lib/models/reflections/index"); | ||
var index_2 = require("typedoc/dist/lib/models/reflections/index"); | ||
var UrlMapping_1 = require("typedoc/dist/lib/output/models/UrlMapping"); | ||
var DefaultTheme_1 = require("typedoc/dist/lib/output/themes/DefaultTheme"); | ||
var service_1 = require("./service"); | ||
var flavour_enum_1 = require("./enums/flavour.enum"); | ||
var theme_service_1 = require("./theme.service"); | ||
var MarkdownTheme = (function (_super) { | ||
@@ -28,7 +36,6 @@ __extends(MarkdownTheme, _super); | ||
renderer.removeComponent('javascript-index'); | ||
renderer.removeComponent('navigation'); | ||
renderer.removeComponent('toc'); | ||
renderer.removeComponent('pretty-print'); | ||
service_1.ThemeService.options = options; | ||
service_1.ThemeService.resources = _this.resources; | ||
theme_service_1.ThemeService.options = options; | ||
theme_service_1.ThemeService.resources = _this.resources; | ||
return _this; | ||
@@ -63,3 +70,3 @@ } | ||
MarkdownTheme.applyAnchorUrl = function (reflection, container) { | ||
var options = service_1.ThemeService.getOptions(); | ||
var options = theme_service_1.ThemeService.getOptions(); | ||
if (!reflection.url || !DefaultTheme_1.DefaultTheme.URL_PREFIX.test(reflection.url)) { | ||
@@ -72,25 +79,23 @@ var anchor = DefaultTheme_1.DefaultTheme.getUrl(reflection, container, '.'); | ||
switch (reflection.kind) { | ||
case index_2.ReflectionKind.ExternalModule: | ||
anchorRef = "external-module-" + service_1.ThemeService.getAnchorRef(reflection.name) + "-"; | ||
case index_1.ReflectionKind.ExternalModule: | ||
anchorRef = "external-module-" + theme_service_1.ThemeService.getAnchorRef(reflection.name) + "-"; | ||
break; | ||
case index_2.ReflectionKind.Class: | ||
anchorRef = "class-" + service_1.ThemeService.getAnchorRef(reflection.name); | ||
case index_1.ReflectionKind.Class: | ||
anchorRef = "class-" + theme_service_1.ThemeService.getAnchorRef(reflection.name); | ||
break; | ||
case index_2.ReflectionKind.Interface: | ||
anchorRef = "interface-" + service_1.ThemeService.getAnchorRef(reflection.name); | ||
case index_1.ReflectionKind.Interface: | ||
anchorRef = "interface-" + theme_service_1.ThemeService.getAnchorRef(reflection.name); | ||
break; | ||
case index_2.ReflectionKind.Module: | ||
anchorRef = "module-" + service_1.ThemeService.getAnchorRef(reflection.name); | ||
case index_2.ReflectionKind.Enum: | ||
if (reflection.parent.kind === 0 || reflection.parent.kind === index_2.ReflectionKind.ExternalModule) { | ||
anchorRef = "module-" + service_1.ThemeService.getAnchorRef(reflection.name); | ||
} | ||
else { | ||
anchorRef = "enumeration-" + service_1.ThemeService.getAnchorRef(reflection.name); | ||
} | ||
case index_1.ReflectionKind.Module: | ||
anchorRef = "module-" + theme_service_1.ThemeService.getAnchorRef(reflection.name); | ||
case index_1.ReflectionKind.Enum: | ||
var isModule = reflection.parent.kind === 0 || reflection.parent.kind === index_1.ReflectionKind.ExternalModule; | ||
anchorRef = isModule ? | ||
"module-" + theme_service_1.ThemeService.getAnchorRef(reflection.name) : | ||
"enumeration-" + theme_service_1.ThemeService.getAnchorRef(reflection.name); | ||
break; | ||
default: | ||
if (options.mdFlavour === 'bitbucket') { | ||
if (options.mdFlavour === flavour_enum_1.Flavour.BITBUCKET) { | ||
var anchorPrefix_1 = ''; | ||
if (reflection.kind === index_2.ReflectionKind.ObjectLiteral) { | ||
if (reflection.kind === index_1.ReflectionKind.ObjectLiteral) { | ||
anchorPrefix_1 += 'object-literal-'; | ||
@@ -101,4 +106,4 @@ } | ||
}); | ||
var prefixRef = service_1.ThemeService.getAnchorRef(anchorPrefix_1); | ||
var reflectionRef = service_1.ThemeService.getAnchorRef(reflection.name); | ||
var prefixRef = theme_service_1.ThemeService.getAnchorRef(anchorPrefix_1); | ||
var reflectionRef = theme_service_1.ThemeService.getAnchorRef(reflection.name); | ||
anchorRef = "markdown-header-" + prefixRef + reflectionRef; | ||
@@ -125,18 +130,34 @@ } | ||
MarkdownTheme.prototype.getUrls = function (project) { | ||
var urls = []; | ||
var options = theme_service_1.ThemeService.getOptions(); | ||
var urlMappings = []; | ||
var entryPoint = this.getEntryPoint(project); | ||
service_1.ThemeService.projectName = entryPoint.name; | ||
var additionalContext = { | ||
theme_service_1.ThemeService.projectName = entryPoint.name; | ||
urlMappings.push(new UrlMapping_1.UrlMapping('README.md', __assign({}, entryPoint, { | ||
displayReadme: this.application.options.getValue('readme') !== 'none', | ||
hideBreadcrumbs: true, | ||
isIndex: true, | ||
}; | ||
var context = Object.assign(entryPoint, additionalContext); | ||
urls.push(new UrlMapping_1.UrlMapping('README.md', context, 'reflection.hbs')); | ||
}), 'reflection.hbs')); | ||
if (entryPoint.children) { | ||
entryPoint.children.forEach(function (child) { | ||
MarkdownTheme.buildUrls(child, urls); | ||
MarkdownTheme.buildUrls(child, urlMappings); | ||
}); | ||
} | ||
return urls; | ||
if (options.mdFlavour === flavour_enum_1.Flavour.GITBOOK) { | ||
var navigation = this.getNavigation(project).children.map(function (navigationItem) { | ||
var subNavigation = navigationItem.dedicatedUrls ? navigationItem.dedicatedUrls.map(function (url) { | ||
return { | ||
title: function () { | ||
var urlMapping = urlMappings.find(function (item) { | ||
return item.url === url; | ||
}); | ||
return urlMapping ? urlMapping.model.name : null; | ||
}, | ||
url: url, | ||
}; | ||
}) : null; | ||
return __assign({}, navigationItem, { subNavigation: subNavigation }); | ||
}); | ||
urlMappings.push(new UrlMapping_1.UrlMapping('SUMMARY.md', { navigation: navigation }, 'navigation.hbs')); | ||
} | ||
return urlMappings; | ||
}; | ||
@@ -143,0 +164,0 @@ return MarkdownTheme; |
{ | ||
"name": "typedoc-plugin-markdown", | ||
"version": "1.0.15", | ||
"version": "1.1.0", | ||
"description": "A plugin for Typedoc that exposes themes and options for rendering markdown.", | ||
@@ -12,6 +12,7 @@ "main": "dist/index.js", | ||
"copy:plugin": "copyfiles package.json './dist/**/*' node_modules/typedoc-plugin-markdown/", | ||
"mocks": "npm run mocks:default && npm run mocks:bitbucket", | ||
"mocks:default": "typedoc ./tests/src --out ./tests/out/default --theme markdown --gitRevision master --media tests/src/media/ --includes tests/src/inc/", | ||
"mocks": "npm run mocks:github && npm run mocks:bitbucket && npm run mocks:gitbook", | ||
"mocks:github": "typedoc ./tests/src --out ./tests/out/github --theme markdown --gitRevision master --media tests/src/media/ --includes tests/src/inc/", | ||
"mocks:bitbucket": "typedoc ./tests/src --out ./tests/out/bitbucket --theme markdown --gitRevision master --media tests/src/media/ --includes tests/src/inc/ --excludePrivate --readme none --mode file --mdFlavour bitbucket --mdSourceRepo 'https://bitbucket.org/owner/repository_name'", | ||
"mocks:html": "typedoc --mode modules --out tests/html tests", | ||
"mocks:gitbook": "typedoc ./tests/src --out ./tests/out/gitbook --theme markdown --gitRevision master --mdFlavour gitbook --media tests/src/media/ --includes tests/src/inc/", | ||
"mocks:html": "typedoc --out tests/html tests --media tests/src/media/ --includes tests/src/inc/", | ||
"lint": "tslint --project ./src/tsconfig.json", | ||
@@ -21,3 +22,3 @@ "prepare": "rm -rf dist && tsc -p ./src/tsconfig.json && npm run copy:static", | ||
"pretest": "rm -rf tests/out && rm -rf node_modules/typedoc-plugin-markdown && npm run copy:plugin && npm run mocks", | ||
"test": "mocha tests/**/test.*.js" | ||
"test": "mocha tests/index.js" | ||
}, | ||
@@ -24,0 +25,0 @@ "author": "Thomas Grey", |
@@ -19,8 +19,15 @@ # typedoc-plugin-markdown | ||
The plugin provides an additional markdown theme. | ||
The plugin provides an additional markdown theme: | ||
```javascript | ||
node_modules/.bin/typedoc --theme markdown | ||
``` | ||
$ node_modules/.bin/typedoc --theme markdown | ||
``` | ||
npm script: | ||
``` | ||
"scripts": { | ||
"docs": "typedoc --theme markdown" | ||
} | ||
``` | ||
## Additional arguments | ||
@@ -30,6 +37,10 @@ | ||
* `--mdFlavour<github|bitbucket>`<br /> | ||
Specifies the markdown rendering engine. Defaults to `github`. | ||
* `--mdFlavour<github|bitbucket|gitbook>`<br /> | ||
* `github`: Default output. | ||
* `bitbucket`: Renders markdown to support bitbucket anchor linking and more. | ||
* `gitbook`: Adds SUMMARY.md file to generate a book's table of contents. | ||
* `--mdHideSources`<br /> | ||
Suppress sources from output | ||
Suppress source file linking from output. | ||
* `--mdSourceRepo<path.to.repo>`<br /> | ||
@@ -40,3 +51,3 @@ The source repo to use for source file linking. Will be ignored on github flavoured projects.<br /> | ||
## Example output | ||
## Sample output | ||
@@ -76,3 +87,3 @@ ### The following DocComments: | ||
Browse some <a href="https://github.com/tgreyjs/typedoc-plugin-markdown/tree/master/tests/mocks/default/README.md">mocked samples</a> to view further examples of generated output. | ||
Browse some <a href="https://github.com/tgreyjs/typedoc-plugin-markdown/tree/master/samples/github/README.md">mocked samples</a> to view further examples of generated output. | ||
@@ -79,0 +90,0 @@ ## Acknowledgements |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
44386
51
544
89
1