Skip to content

Commit

Permalink
Make "fallback" version configurable
Browse files Browse the repository at this point in the history
In situations where a block does not define a version explicitly apidocsjs falls back to '0.0.0'.
With this patch the default version can be configured using 'defaultVersion' property in apidoc.json
  • Loading branch information
jharting committed Aug 26, 2016
1 parent a12de92 commit a73fe21
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 14 deletions.
3 changes: 2 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ var defaultPackageInfos = {
description: '',
name : '',
sampleUrl : false,
version : '0.0.0'
version : '0.0.0',
defaultVersion: '0.0.0'
};

// Simple logger interace
Expand Down
2 changes: 1 addition & 1 deletion lib/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ Worker.prototype.process = function(parsedFiles, parsedFilenames, packageInfos)
block.local.url = '';

if ( ! block.local.version)
block.local.version = '0.0.0';
block.local.version = packageInfos.defaultVersion;

if ( ! block.local.filename)
block.local.filename = parsedFilenames[fileIndex];
Expand Down
6 changes: 3 additions & 3 deletions lib/workers/api_group.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function preProcess(parsedFiles, filenames, packageInfos, target) {
parsedFile.forEach(function(block) {
if (block.global[source]) {
var name = block.global[source].name;
var version = block.version || '0.0.0';
var version = block.version || packageInfos.defaultVersion;

if ( ! result[target][name])
result[target][name] = {};
Expand Down Expand Up @@ -94,7 +94,7 @@ function postProcess(parsedFiles, filenames, preProcess, packageInfos, source, t
return;

var name = block.local[target];
var version = block.version || '0.0.0';
var version = block.version || packageInfos.defaultVersion;
var matchedData = {};

if ( ! preProcess[source] || ! preProcess[source][name]) {
Expand Down Expand Up @@ -127,7 +127,7 @@ else {
} else {
// find nearest matching version
var foundIndex = -1;
var lastVersion = '0.0.0';
var lastVersion = packageInfos.defaultVersion;

var versionKeys = Object.keys(preProcess[source][name]);
versionKeys.forEach(function(currentVersion, versionIndex) {
Expand Down
6 changes: 3 additions & 3 deletions lib/workers/api_param_title.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function preProcess(parsedFiles, filenames, packageInfos, target) {
parsedFile.forEach(function(block) {
if (block.global[source]) {
var name = block.global[source].name;
var version = block.version || '0.0.0';
var version = block.version || packageInfos.defaultVersion;

if ( ! result[target][name])
result[target][name] = {};
Expand Down Expand Up @@ -76,7 +76,7 @@ function postProcess(parsedFiles, filenames, preProcess, packageInfos, source, t

params.forEach(function(definition) {
var name = definition.group;
var version = block.version || '0.0.0';
var version = block.version || packageInfos.defaultVersion;
var matchedData = {};

if ( ! preProcess[source] || ! preProcess[source][name]) {
Expand Down Expand Up @@ -109,7 +109,7 @@ else {
} else {
// find nearest matching version
var foundIndex = -1;
var lastVersion = '0.0.0';
var lastVersion = packageInfos.defaultVersion;

var versionKeys = Object.keys(preProcess[source][name]);
versionKeys.forEach(function(currentVersion, versionIndex) {
Expand Down
6 changes: 3 additions & 3 deletions lib/workers/api_permission.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function preProcess(parsedFiles, filenames, packageInfos, target) {
parsedFile.forEach(function(block) {
if (block.global[source]) {
var name = block.global[source].name;
var version = block.version || '0.0.0';
var version = block.version || packageInfos.defaultVersion;

if ( ! result[target][name])
result[target][name] = {};
Expand Down Expand Up @@ -71,7 +71,7 @@ function postProcess(parsedFiles, filenames, preProcess, packageInfos, source, t
var newPermissions = [];
block.local[target].forEach(function(definition) {
var name = definition.name;
var version = block.version || '0.0.0';
var version = block.version || packageInfos.defaultVersion;
var matchedData = {};

if ( ! preProcess[source] || ! preProcess[source][name]) {
Expand Down Expand Up @@ -105,7 +105,7 @@ else {
} else {
// find nearest matching version
var foundIndex = -1;
var lastVersion = '0.0.0';
var lastVersion = packageInfos.defaultVersion;

var versionKeys = Object.keys(preProcess[source][name]);
versionKeys.forEach(function(currentVersion, versionIndex) {
Expand Down
6 changes: 3 additions & 3 deletions lib/workers/api_use.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function preProcess(parsedFiles, filenames, packageInfos, target) {
parsedFile.forEach(function(block) {
if (block.global[source]) {
var name = block.global[source].name;
var version = block.version || '0.0.0';
var version = block.version || packageInfos.defaultVersion;

if ( ! result[target][name])
result[target][name] = {};
Expand Down Expand Up @@ -71,7 +71,7 @@ function postProcess(parsedFiles, filenames, preProcess, packageInfos, source, t

block.local[target].forEach(function(definition) {
var name = definition.name;
var version = block.version || '0.0.0';
var version = block.version || packageInfos.defaultVersion;

if ( ! preProcess[source] || ! preProcess[source][name]) {
throw new WorkerError('Referenced groupname does not exist / it is not defined with @apiDefine.',
Expand All @@ -93,7 +93,7 @@ function postProcess(parsedFiles, filenames, preProcess, packageInfos, source, t
} else {
// find nearest matching version
var foundIndex = -1;
var lastVersion = '0.0.0';
var lastVersion = packageInfos.defaultVersion;

var versionKeys = Object.keys(preProcess[source][name]);
versionKeys.forEach(function(currentVersion, versionIndex) {
Expand Down

0 comments on commit a73fe21

Please sign in to comment.