Skip to content

Commit 171b7d7

Browse files
committed
Improve internal documentation
1 parent 2ea79c0 commit 171b7d7

File tree

4 files changed

+36
-0
lines changed

4 files changed

+36
-0
lines changed

lib/git/url_prefix.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@ var path = require('path');
33
var urlFromGit = require('github-url-from-git');
44
var getRemoteOrigin = require('remote-origin-url');
55

6+
/**
7+
* Given a a root directory, find its git configuration and figure out
8+
* the HTTPS URL at the base of that GitHub repository.
9+
*
10+
* @param {string} root path at the base of this local repo
11+
* @returns {string} base HTTPS url of the GitHub repository
12+
* @throws {Error} if the root is not a git repo
13+
*/
614
function getGithubURLPrefix(root) {
715
return urlFromGit(getRemoteOrigin.sync(root)) + '/blob/' +
816
fs.readFileSync(path.join(root, '.git',

lib/output/markdown_ast.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,25 @@ function identity(x) {
77
return x;
88
}
99

10+
/**
11+
* Given a hierarchy-nested set of comments, generate an mdast-compatible
12+
* Abstract Syntax Usable for generating Markdown output
13+
*
14+
* @param {Array<Object>} comments nested comment
15+
* @param {Object} opts currently none accepted
16+
* @param {Function} callback called with AST
17+
* @returns {undefined} calls callback
18+
*/
1019
function commentsToAST(comments, opts, callback) {
20+
21+
/**
22+
* Generate an AST chunk for a comment at a given depth: this is
23+
* split from the main function to handle hierarchially nested comments
24+
*
25+
* @param {number} depth nesting of the comment, starting at 1
26+
* @param {Object} comment a single comment
27+
* @returns {Object} mdast-compatible AST
28+
*/
1129
function generate(depth, comment) {
1230

1331
function paramList(params) {

lib/walk.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
/**
2+
* Apply a function to all comments within a hierarchy: this iterates
3+
* through children in the 'members' property.
4+
*
5+
* @param {Array<Object>} comments an array of nested comments
6+
* @param {Function} fn a walker function
7+
* @returns {undefined} calls fn
8+
*/
19
function walk(comments, fn) {
210
return comments.map(function (comment) {
311
comment.members.instance = walk(comment.members.instance, fn);

test/bin.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ function documentation(args, options, callback, parseJSON) {
1616
options.cwd = __dirname;
1717
}
1818

19+
options.maxBuffer = 1024 * 1024;
20+
1921
args.unshift(path.join(__dirname, '../bin/documentation.js'));
2022

2123
exec(args.join(' '), options, function (err, stdout, stderr) {

0 commit comments

Comments
 (0)