forked from thlorenz/jsdoc-githubify
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
getting github info needed to adapt links
- Loading branch information
Showing
3 changed files
with
93 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
'use strict'; | ||
|
||
var resolveBranch = require('resolve-git-branch') | ||
, resolveRemote = require('resolve-git-remote') | ||
, asyncreduce = require('asyncreduce') | ||
|
||
function githubInfo(cb) { | ||
asyncreduce( | ||
[ [ 'remote', resolveRemote ], [ 'branch', resolveBranch ] ] | ||
, {} | ||
, function (acc, tuple, cb_) { | ||
tuple[1](function (err, res) { | ||
if (err) return cb_(err); | ||
acc[tuple[0]] = res; | ||
cb_(null, acc); | ||
}); | ||
} | ||
, function (err, res) { | ||
if (err) return cb(err); | ||
res.blobRoot = 'https://github.com/' + res.remote + '/blob/' + res.branch + '/'; | ||
cb(null, res); | ||
} | ||
); | ||
} | ||
|
||
var go = module.exports = function (cb) { | ||
githubInfo(function (err, ghinfo) { | ||
if (err) return cb(err); | ||
|
||
}); | ||
}; | ||
|
||
// Test | ||
|
||
function inspect(obj, depth) { | ||
console.error(require('util').inspect(obj, false, depth || 5, true)); | ||
} | ||
|
||
if (!module.parent) { | ||
var html = [ | ||
'<article>' | ||
, ' <div class="container-overview">' | ||
, ' <div class="description"><p>Public wicked API</p></div>' | ||
, '<dl class="details">' | ||
, ' <dt class="tag-source">Source:</dt>' | ||
, ' <dd class="tag-source"><ul class="dummy"><li>' | ||
, ' util/helper.js, line 3' | ||
, ' </li></ul></dd>' | ||
, '</dl>' | ||
, ' </div>' | ||
, ' </article>'].join('\n'); | ||
|
||
githubInfo(function (err, res) { | ||
if (err) return console.error(err); | ||
inspect(res) | ||
}); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
'use strict'; | ||
|
||
var test = require('tap').test | ||
, applyTransform = require('apply-transform') | ||
, transform = require('../') | ||
|
||
var html = [ | ||
'<article>' | ||
, ' <div class="container-overview">' | ||
, ' <div class="description"><p>Public wicked API</p></div>' | ||
, '<dl class="details">' | ||
, ' <dt class="tag-source">Source:</dt>' | ||
, ' <dd class="tag-source"><ul class="dummy"><li>' | ||
, ' util/helper.js, line 3' | ||
, ' </li></ul></dd>' | ||
, '</dl>' | ||
, ' </div>' | ||
, ' </article>'].join('\n'); | ||
|
||
function inspect(obj, depth) { | ||
console.error(require('util').inspect(obj, false, depth || 5, true)); | ||
} | ||
|
||
test('\nhtml with multiple links without repo or branch override', function (t) { | ||
applyTransform(transform(), html, function (err, res) { | ||
if (err) { t.fail(err); return t.end() } | ||
inspect(res.split('\n')); | ||
t.end() | ||
}); | ||
}) |