dgeni-packages
Advanced tools
Comparing version 0.10.3 to 0.10.4
@@ -13,3 +13,3 @@ var _ = require('lodash'); | ||
pathVariants: ['', '/', '.html', '/index.html'], | ||
checkDoc: function(doc) { return path.extname(doc.outputPath) === '.html'; }, | ||
checkDoc: function(doc) { return doc.path && path.extname(doc.outputPath) === '.html'; }, | ||
base: null, | ||
@@ -89,3 +89,5 @@ webRoot: '/', | ||
var normalizedLink = path.join(webRoot, resolveUrl(linkInfo.path, link, base)); | ||
if (!allValidReferences[normalizedLink]) { | ||
if ( !_.any(pathVariants, function(pathVariant) { | ||
return allValidReferences[normalizedLink + pathVariant]; | ||
}) ) { | ||
unmatchedLinks.push(link); | ||
@@ -92,0 +94,0 @@ } |
@@ -39,5 +39,6 @@ var path = require('canonical-path'); | ||
it("should skip files that are not in the `filesToCheck` property", function() { | ||
it("should not warn if the link matches a path after it has been modified with a path variant", function() { | ||
processor.$process([ | ||
{ renderedContent: '<a href="/foo"></a>', outputPath: 'x.js', path: 'x' } | ||
{ renderedContent: '<a href="/foo"></a>', outputPath: 'doc/path.html', path: 'doc/path' }, | ||
{ renderedContent: 'CONTENT OF FOO', outputPath: 'foo.html', path: 'foo/' } | ||
]); | ||
@@ -47,2 +48,10 @@ expect(mockLog.warn).not.toHaveBeenCalled(); | ||
it("should skip files that do not pass the `checkDoc` method", function() { | ||
processor.$process([ | ||
{ renderedContent: '<a href="/foo"></a>', outputPath: 'x.js', path: 'x' }, | ||
{ renderedContent: '<a href="/foo"></a>', outputPath: 'x.html' } | ||
]); | ||
expect(mockLog.warn).not.toHaveBeenCalled(); | ||
}); | ||
it("should skip links that match the `ignoredLinks` property", function() { | ||
@@ -49,0 +58,0 @@ processor.$process([ |
# Changelog | ||
## v0.10.4 15th October 2014 | ||
* fix(base/checkAnchorLinks): match links using pathVariants ff903657 | ||
* fix(jsdoc/jsdocFileReader): provide file information in JS parse error 69680361 | ||
## v0.10.3 9th October 2014 | ||
@@ -4,0 +10,0 @@ |
@@ -10,3 +10,3 @@ var _ = require('lodash'); | ||
*/ | ||
module.exports = function jsdocFileReader() { | ||
module.exports = function jsdocFileReader(log) { | ||
return { | ||
@@ -17,6 +17,12 @@ name: 'jsdocFileReader', | ||
fileInfo.ast = esprima.parse(fileInfo.content, { | ||
loc: true, | ||
attachComment: true | ||
}); | ||
try { | ||
fileInfo.ast = esprima.parse(fileInfo.content, { | ||
loc: true, | ||
attachComment: true | ||
}); | ||
} catch(ex) { | ||
ex.file = fileInfo.filePath; | ||
throw new Error( | ||
_.template('JavaScript error in file "${file}"" [line ${lineNumber}, column ${column}]: "${description}"', ex)); | ||
} | ||
@@ -23,0 +29,0 @@ return [{ |
var path = require('canonical-path'); | ||
var fileReaderFactory = require('./jsdoc'); | ||
var mockLog = require('dgeni/lib/mocks/log')(); | ||
@@ -25,3 +26,3 @@ var srcJsContent = require('../mocks/_test-data/srcJsFile.js'); | ||
beforeEach(function() { | ||
fileReader = fileReaderFactory(); | ||
fileReader = fileReaderFactory(mockLog); | ||
}); | ||
@@ -58,3 +59,26 @@ | ||
it("should cope with invalid JavaScript", function() { | ||
var fileInfo = createFileInfo( | ||
'some/file.js', | ||
"var _parameters={\n" + | ||
" QueryTemplate:'ArlaPS_CheckIn/UpdateStaffUsersCMD',\n" + | ||
" 'Param.1':$('staff_no').value,\n" + | ||
" 'Param.2':$('init').value,\n" + | ||
" 'Param.3':$('firstname').value,\n" + | ||
" 'Param.4':$('surname').value,\n" + | ||
" 'Param.5':$('tlf').value,\n" + | ||
" 'Param.6':$('titel').value,\n" + | ||
" 'Param.7':$('desc').value ,\n" + | ||
" 'Param.8':$('pass').value ,\n" + | ||
" 'Param.9':$('old_staff_no').value ,\n" + | ||
" 'Param.10':$('evac').checked // <--- Missing comma\n" + | ||
" sync:true\n" + | ||
"}\n", | ||
'.'); | ||
expect(function() { | ||
var docs = fileReader.getDocs(fileInfo); | ||
}).toThrowError('JavaScript error in file "some/file.js"" [line 13, column 3]: "Unexpected identifier"') | ||
}); | ||
}); | ||
}); |
{ | ||
"name": "dgeni-packages", | ||
"version": "0.10.3", | ||
"version": "0.10.4", | ||
"description": "A collection of dgeni packages for generating documentation from source code", | ||
@@ -5,0 +5,0 @@ "scripts": { |
320765
6080
230