@compodoc/compodoc
Advanced tools
Comparing version 1.1.1 to 1.1.2
{ | ||
"name": "@compodoc/compodoc", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"description": "The missing documentation tool for your Angular application", | ||
@@ -14,4 +14,4 @@ "main": "dist/index.js", | ||
"start": "npm run test:watch", | ||
"pretest": "./node_modules/.bin/tsc -p test/tsconfig.json", | ||
"test": "./node_modules/.bin/mocha-parallel-tests test", | ||
"pretest": "./node_modules/.bin/tsc -p test/tsconfig.json && node test/dist/cli/cli-clean-root-folder.js", | ||
"test": "./node_modules/.bin/mocha-parallel-tests test && node test/dist/cli/cli-revert-root-folder.js", | ||
"posttest": "rimraf test/dist", | ||
@@ -68,3 +68,3 @@ "angularexpo": "npm run pretest && node tools/tests-angularexpo.js", | ||
"glob": "^7.1.2", | ||
"handlebars": "^4.0.11", | ||
"handlebars": "4.0.10", | ||
"html-entities": "^1.2.1", | ||
@@ -78,3 +78,3 @@ "json5": "^1.0.1", | ||
"traverse": "^0.6.6", | ||
"ts-simple-ast": "10.0.1", | ||
"ts-simple-ast": "10.2.0", | ||
"uuid": "^3.2.1" | ||
@@ -81,0 +81,0 @@ }, |
@@ -201,4 +201,4 @@ import * as path from 'path'; | ||
// RouterParser.printModulesRoutes(); | ||
// RouterParser.printRoutes(); | ||
// this.routerParser.printModulesRoutes(); | ||
// this.routerParser.printRoutes(); | ||
@@ -314,5 +314,5 @@ if (!this.configuration.mainData.disableRoutesGraph) { | ||
// scannedFile = this.routerParser.cleanFileIdentifiers(astFile).compilerNode; | ||
let firstClean = this.routerParser.cleanFileSpreads(astFile); | ||
scannedFile = firstClean.compilerNode; | ||
let firstClean = this.routerParser.cleanFileSpreads(astFile).compilerNode; | ||
scannedFile = this.routerParser.cleanFileDynamics(astFile).compilerNode; | ||
scannedFile = this.routerParser.cleanCallExpressions(astFile).compilerNode; | ||
@@ -319,0 +319,0 @@ scannedFile.kind = SyntaxKind.SourceFile; |
@@ -51,2 +51,10 @@ import { SymbolHelper, IParseDeepIdentifierResult } from './symbol-helper'; | ||
private cleanImportForRootForChild(name: string): string { | ||
let nsModule = name.split('.'); | ||
if (nsModule.length > 0) { | ||
name = nsModule[0]; | ||
} | ||
return name; | ||
} | ||
public getModuleImports( | ||
@@ -58,2 +66,3 @@ props: ReadonlyArray<ts.ObjectLiteralElementLike>, | ||
.getSymbolDeps(props, 'imports', srcFile) | ||
.map(name => this.cleanImportForRootForChild(name)) | ||
.map(name => this.symbolHelper.parseDeepIndentifier(name)); | ||
@@ -60,0 +69,0 @@ } |
@@ -14,2 +14,6 @@ import * as path from 'path'; | ||
private precompiledMenu; | ||
private compiledMobileMenu; | ||
private compiledMenu; | ||
constructor( | ||
@@ -26,3 +30,2 @@ configuration: ConfigurationInterface, | ||
let partials = [ | ||
'menu', | ||
'overview', | ||
@@ -79,7 +82,32 @@ 'markdown', | ||
this.cache.page = data; | ||
this.compiledPage = Handlebars.compile(this.cache.page); | ||
this.compiledPage = Handlebars.compile(this.cache.page, { | ||
preventIndent: true, | ||
strict: true | ||
}); | ||
}); | ||
}).then(() => { | ||
return this.fileEngine | ||
.get(path.resolve(__dirname + '/../src/templates/partials/menu.hbs')) | ||
.then(menuTemplate => { | ||
this.precompiledMenu = Handlebars.compile(menuTemplate, { | ||
preventIndent: true, | ||
strict: true | ||
}); | ||
}); | ||
}).then(() => { }); | ||
} | ||
public renderMenu(data) { | ||
return new Promise((resolve, reject) => { | ||
try { | ||
this.compiledMobileMenu = this.precompiledMenu({...data}); | ||
data.menu = 'normal'; | ||
this.compiledMenu = this.precompiledMenu({...data}); | ||
resolve(); | ||
} catch(err) { | ||
reject(err); | ||
} | ||
}); | ||
} | ||
public render(mainData: any, page: any): string { | ||
@@ -94,3 +122,3 @@ let o = mainData; | ||
data: o | ||
}); | ||
}).replace('<!-- XS MENU CONTENT -->', this.compiledMobileMenu).replace('<!-- NORMAL MENU CONTENT -->', this.compiledMenu); | ||
} | ||
@@ -97,0 +125,0 @@ |
@@ -9,92 +9,178 @@ document.addEventListener('DOMContentLoaded', function() { | ||
document.getElementById('btn-menu').addEventListener('click', function() { | ||
if (menuCollapsed) { | ||
mobileMenu.style.display = 'none'; | ||
} else { | ||
mobileMenu.style.display = 'block'; | ||
document.getElementsByTagName('body')[0].style['overflow-y'] = 'hidden'; | ||
var processLink = function(link, url) { | ||
if (url.charAt(0) !== '.') { | ||
let prefix = ''; | ||
switch(COMPODOC_CURRENT_PAGE_DEPTH) { | ||
case 5: | ||
prefix = '../../../../../'; | ||
break; | ||
case 4: | ||
prefix = '../../../../'; | ||
break; | ||
case 3: | ||
prefix = '../../../'; | ||
break; | ||
case 2: | ||
prefix = '../../'; | ||
break; | ||
case 1: | ||
prefix = '../'; | ||
break; | ||
case 0: | ||
prefix = './'; | ||
break; | ||
} | ||
link.setAttribute('href', prefix + url); | ||
} | ||
menuCollapsed = !menuCollapsed; | ||
}); | ||
} | ||
// collapse menu | ||
var classnameMenuToggler = document.getElementsByClassName('menu-toggler'), | ||
faAngleUpClass = 'fa-angle-up', | ||
faAngleDownClass = 'fa-angle-down', | ||
toggleItemMenu = function(e) { | ||
var element = $(e.target), | ||
parent = element[0].parentNode, | ||
parentLink, | ||
elementIconChild; | ||
if (parent) { | ||
if (!$(parent).hasClass('linked')) { | ||
e.preventDefault(); | ||
} else { | ||
parentLink = parent.parentNode; | ||
if (parentLink && element.hasClass('link-name')) { | ||
$(parentLink).trigger('click'); | ||
var processMenuLinks = function(links, dontAddClass) { | ||
for (var i = 0; i < links.length; i++) { | ||
var link = links[i]; | ||
var linkHref = link.getAttribute('href'); | ||
if (linkHref.toLowerCase().indexOf(COMPODOC_CURRENT_PAGE_URL.toLowerCase()) !== -1 && link.innerHTML.indexOf('Getting started') == -1 && !dontAddClass) { | ||
link.classList.add('active'); | ||
} | ||
processLink(link, linkHref); | ||
} | ||
} | ||
var chapterLinks = document.querySelectorAll('[data-type="chapter-link"]'); | ||
processMenuLinks(chapterLinks); | ||
var entityLinks = document.querySelectorAll('[data-type="entity-link"]'); | ||
processMenuLinks(entityLinks); | ||
var indexLinks = document.querySelectorAll('[data-type="index-link"]'); | ||
processMenuLinks(indexLinks, true); | ||
var entityLogos = document.querySelectorAll('[data-type="compodoc-logo"]'); | ||
var processLogos = function(entityLogo) { | ||
for (var i = 0; i < entityLogos.length; i++) { | ||
var entityLogo = entityLogos[i]; | ||
if (entityLogo) { | ||
var url = entityLogo.getAttribute('data-src'); | ||
if (url.charAt(0) !== '.') { | ||
let prefix = ''; | ||
switch(COMPODOC_CURRENT_PAGE_DEPTH) { | ||
case 5: | ||
prefix = '../../../../../'; | ||
break; | ||
case 4: | ||
prefix = '../../../../'; | ||
break; | ||
case 3: | ||
prefix = '../../../'; | ||
break; | ||
case 2: | ||
prefix = '../../'; | ||
break; | ||
case 1: | ||
prefix = '../'; | ||
break; | ||
case 0: | ||
prefix = './'; | ||
break | ||
} | ||
entityLogo.src = prefix + url; | ||
} | ||
elementIconChild = parent.getElementsByClassName(faAngleUpClass)[0]; | ||
if (!elementIconChild) { | ||
elementIconChild = parent.getElementsByClassName(faAngleDownClass)[0]; | ||
} | ||
if (elementIconChild) { | ||
elementIconChild = $(elementIconChild) | ||
if (elementIconChild.hasClass(faAngleUpClass)) { | ||
elementIconChild.addClass(faAngleDownClass); | ||
elementIconChild.removeClass(faAngleUpClass); | ||
} | ||
} | ||
} | ||
processLogos(entityLogos); | ||
setTimeout(function() { | ||
document.getElementById('btn-menu').addEventListener('click', function() { | ||
if (menuCollapsed) { | ||
mobileMenu.style.display = 'none'; | ||
} else { | ||
mobileMenu.style.display = 'block'; | ||
document.getElementsByTagName('body')[0].style['overflow-y'] = 'hidden'; | ||
} | ||
menuCollapsed = !menuCollapsed; | ||
}); | ||
// collapse menu | ||
var classnameMenuToggler = document.getElementsByClassName('menu-toggler'), | ||
faAngleUpClass = 'fa-angle-up', | ||
faAngleDownClass = 'fa-angle-down', | ||
toggleItemMenu = function(e) { | ||
var element = $(e.target), | ||
parent = element[0].parentNode, | ||
parentLink, | ||
elementIconChild; | ||
if (parent) { | ||
if (!$(parent).hasClass('linked')) { | ||
e.preventDefault(); | ||
} else { | ||
elementIconChild.addClass(faAngleUpClass); | ||
elementIconChild.removeClass(faAngleDownClass); | ||
parentLink = parent.parentNode; | ||
if (parentLink && element.hasClass('link-name')) { | ||
$(parentLink).trigger('click'); | ||
} | ||
} | ||
elementIconChild = parent.getElementsByClassName(faAngleUpClass)[0]; | ||
if (!elementIconChild) { | ||
elementIconChild = parent.getElementsByClassName(faAngleDownClass)[0]; | ||
} | ||
if (elementIconChild) { | ||
elementIconChild = $(elementIconChild) | ||
if (elementIconChild.hasClass(faAngleUpClass)) { | ||
elementIconChild.addClass(faAngleDownClass); | ||
elementIconChild.removeClass(faAngleUpClass); | ||
} else { | ||
elementIconChild.addClass(faAngleUpClass); | ||
elementIconChild.removeClass(faAngleDownClass); | ||
} | ||
} | ||
} | ||
} | ||
}; | ||
}; | ||
for (var i = 0; i < classnameMenuToggler.length; i++) { | ||
classnameMenuToggler[i].addEventListener('click', toggleItemMenu, false); | ||
} | ||
for (var i = 0; i < classnameMenuToggler.length; i++) { | ||
classnameMenuToggler[i].addEventListener('click', toggleItemMenu, false); | ||
} | ||
// Scroll to active link | ||
var menus = document.querySelectorAll('.menu'), | ||
i = 0, | ||
len = menus.length, | ||
activeMenu, | ||
activeMenuClass, | ||
activeLink; | ||
// Scroll to active link | ||
var menus = document.querySelectorAll('.menu'), | ||
i = 0, | ||
len = menus.length, | ||
activeMenu, | ||
activeMenuClass, | ||
activeLink; | ||
for (i; i<len; i++) { | ||
if (getComputedStyle(menus[i]).display != 'none') { | ||
activeMenu = menus[i]; | ||
activeMenuClass = activeMenu.getAttribute('class').split(' ')[0]; | ||
for (i; i<len; i++) { | ||
if (getComputedStyle(menus[i]).display != 'none') { | ||
activeMenu = menus[i]; | ||
activeMenuClass = activeMenu.getAttribute('class').split(' ')[0]; | ||
} | ||
} | ||
} | ||
if (activeMenu) { | ||
activeLink = document.querySelector('.' + activeMenuClass + ' .active'); | ||
if (activeLink) { | ||
var linkType = activeLink.getAttribute('data-type'); | ||
var linkContext = activeLink.getAttribute('data-context'); | ||
if (linkType === 'entity-link') { | ||
var parentLi = activeLink.parentNode, | ||
parentUl, | ||
parentChapterMenu; | ||
if (parentLi) { | ||
parentUl = parentLi.parentNode; | ||
if (parentUl) { | ||
parentChapterMenu = parentUl.parentNode; | ||
if (parentChapterMenu) { | ||
var toggler = parentChapterMenu.querySelector('.menu-toggler'), | ||
elementIconChild = toggler.getElementsByClassName(faAngleUpClass)[0]; | ||
if (toggler && !elementIconChild) { | ||
toggler.click(); | ||
if (activeMenu) { | ||
activeLink = document.querySelector('.' + activeMenuClass + ' .active'); | ||
if (activeLink) { | ||
var linkType = activeLink.getAttribute('data-type'); | ||
var linkContext = activeLink.getAttribute('data-context'); | ||
if (linkType === 'entity-link') { | ||
var parentLi = activeLink.parentNode, | ||
parentUl, | ||
parentChapterMenu; | ||
if (parentLi) { | ||
parentUl = parentLi.parentNode; | ||
if (parentUl) { | ||
parentChapterMenu = parentUl.parentNode; | ||
if (parentChapterMenu) { | ||
var toggler = parentChapterMenu.querySelector('.menu-toggler'), | ||
elementIconChild = toggler.getElementsByClassName(faAngleUpClass)[0]; | ||
if (toggler && !elementIconChild) { | ||
toggler.click(); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
if (linkContext && linkContext === 'sub-entity') { | ||
// Toggle also the master parent menu | ||
var linkContextId = activeLink.getAttribute('data-context-id'); | ||
var toggler = activeMenu.querySelector('.chapter.' + linkContextId + ' a .menu-toggler'); | ||
if (linkContext && linkContext === 'sub-entity') { | ||
// Toggle also the master parent menu | ||
var linkContextId = activeLink.getAttribute('data-context-id'); | ||
var toggler = activeMenu.querySelector('.chapter.' + linkContextId + ' a .menu-toggler'); | ||
if (toggler) { | ||
toggler.click(); | ||
} | ||
} | ||
} else if (linkType === 'chapter-link') { | ||
var toggler = activeLink.querySelector('.menu-toggler'); | ||
if (toggler) { | ||
@@ -104,16 +190,11 @@ toggler.click(); | ||
} | ||
} else if (linkType === 'chapter-link') { | ||
var toggler = activeLink.querySelector('.menu-toggler'); | ||
if (toggler) { | ||
toggler.click(); | ||
} | ||
setTimeout(function() { | ||
activeMenu.scrollTop = activeLink.offsetTop; | ||
if (activeLink.innerHTML.toLowerCase().indexOf('readme') != -1 || activeLink.innerHTML.toLowerCase().indexOf('overview') != -1) { | ||
activeMenu.scrollTop = 0; | ||
} | ||
}, 300); | ||
} | ||
setTimeout(function() { | ||
activeMenu.scrollTop = activeLink.offsetTop; | ||
if (activeLink.innerHTML.toLowerCase().indexOf('readme') != -1 || activeLink.innerHTML.toLowerCase().indexOf('overview') != -1) { | ||
activeMenu.scrollTop = 0; | ||
} | ||
}, 300); | ||
} | ||
} | ||
}, 0); | ||
}); |
@@ -82,3 +82,4 @@ import * as util from 'util'; | ||
imports[i].name.indexOf('RouterModule.forChild') !== -1 || | ||
imports[i].name.indexOf('RouterModule.forRoot') !== -1 | ||
imports[i].name.indexOf('RouterModule.forRoot') !== -1 || | ||
imports[i].name.indexOf('RouterModule') !== -1 | ||
) { | ||
@@ -617,5 +618,7 @@ return true; | ||
} | ||
propertyAccessExpression.replaceWithText( | ||
referencedDeclaration.getInitializerOrThrow().getText() | ||
); | ||
if (typeof referencedDeclaration.getInitializerOrThrow !== 'undefined') { | ||
propertyAccessExpression.replaceWithText( | ||
referencedDeclaration.getInitializerOrThrow().getText() | ||
); | ||
} | ||
} | ||
@@ -627,2 +630,29 @@ | ||
/** | ||
* replace callexpressions with string : utils.doWork() -> 'utils.doWork()' doWork() -> 'doWork()' | ||
* @param sourceFile ts.SourceFile | ||
*/ | ||
public cleanCallExpressions(sourceFile: SourceFile): SourceFile { | ||
let file = sourceFile; | ||
const variableStatements = sourceFile.getVariableDeclaration((v) => { | ||
let result = false; | ||
if (typeof v.compilerNode.type !== 'undefined') { | ||
result = v.compilerNode.type.typeName.text === 'Routes'; | ||
} | ||
return result; | ||
}); | ||
const initializer = variableStatements.getInitializer(); | ||
for (const callExpr of initializer.getDescendantsOfKind(SyntaxKind.CallExpression)) { | ||
if (callExpr.wasForgotten()) { | ||
continue; | ||
} | ||
callExpr.replaceWithText(writer => writer.quote(callExpr.getText())); | ||
} | ||
return file; | ||
} | ||
/** | ||
* Clean routes definition with imported data, for example path, children, or dynamic stuff inside data | ||
@@ -629,0 +659,0 @@ * |
@@ -118,11 +118,11 @@ import * as path from 'path'; | ||
let result = []; | ||
let i = 0; | ||
let len = methods.length; | ||
for (i; i < len; i++) { | ||
if (!(methods[i].name in AngularLifecycleHooks)) { | ||
result.push(methods[i]); | ||
if (typeof methods !== 'undefined') { | ||
let i = 0; | ||
let len = methods.length; | ||
for (i; i < len; i++) { | ||
if (!(methods[i].name in AngularLifecycleHooks)) { | ||
result.push(methods[i]); | ||
} | ||
} | ||
} | ||
return result; | ||
@@ -129,0 +129,0 @@ } |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
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
Sorry, the diff of this file is not supported yet
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
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
6766270
54972
+ Addedalign-text@0.1.4(transitive)
+ Addedamdefine@1.0.1(transitive)
+ Addedasync@1.5.2(transitive)
+ Addedcamelcase@1.2.1(transitive)
+ Addedcenter-align@0.1.3(transitive)
+ Addedcliui@2.1.0(transitive)
+ Addedcode-block-writer@6.13.0(transitive)
+ Addeddecamelize@1.2.0(transitive)
+ Addedhandlebars@4.0.10(transitive)
+ Addedlazy-cache@1.0.4(transitive)
+ Addedlongest@1.0.1(transitive)
+ Addedminimist@0.0.10(transitive)
+ Addedoptimist@0.6.1(transitive)
+ Addedright-align@0.1.3(transitive)
+ Addedsource-map@0.4.4(transitive)
+ Addedts-simple-ast@10.2.0(transitive)
+ Addeduglify-js@2.8.29(transitive)
+ Addeduglify-to-browserify@1.0.2(transitive)
+ Addedwindow-size@0.1.0(transitive)
+ Addedwordwrap@0.0.20.0.3(transitive)
+ Addedyargs@3.10.0(transitive)
- Removedcode-block-writer@6.14.0(transitive)
- Removedhandlebars@4.7.8(transitive)
- Removedneo-async@2.6.2(transitive)
- Removedsource-map@0.6.1(transitive)
- Removedts-simple-ast@10.0.1(transitive)
- Removeduglify-js@3.19.3(transitive)
- Removedwordwrap@1.0.0(transitive)
Updatedhandlebars@4.0.10
Updatedts-simple-ast@10.2.0