@@ -10,7 +10,7 @@ var urljoin = require('urljoin')
1010var slugs = require('github-slugger')()
1111var xtend = require('xtend/mutable.js')
1212
13−/* Optional Node dependencies. */
13+// Optional Node dependencies.
1414var fs
1515var path
1616
@@ -56,8 +56,7 @@ function validateLinks(options, fileSet) {
5656 var info
5757 var pack
5858
59− /* Try to get the repo from `package.json` when not
60− * given. */
59+ // Try to get the repo from `package.json` when not given.
6160 if (!repo && fs && fileSet) {
6261 try {
6362 pack = fileSet.files[0].cwd
@@ -83,10 +82,10 @@ function validateLinks(options, fileSet) {
8382 }
8483 }
8584
86− /* Attach a plugin that adds our transformer after it. */
85+ // Attach a plugin that adds our transformer after it.
8786 this.use(subplugin)
8887
89− /* Attach a `completer`. */
88+ // Attach a `completer`.
9089 if (fileSet) {
9190 fileSet.use(cliCompleter)
9291 } else {
@@ -94,12 +93,12 @@ function validateLinks(options, fileSet) {
9493 }
9594
9695 function subplugin() {
97− /* Expose transformer. */
96+ // Expose transformer.
9897 return transformerFactory(fileSet, info)
9998 }
10099}
101100
102−/* Completer for the API (one file, only headings are checked). */
101+// Completer for the API (one file, only headings are checked).
103102function apiCompleter() {
104103 return apiTransform
105104}
@@ -108,7 +107,7 @@ function apiTransform(tree, file) {
108107 checkFactory(file.data[landmarkId])(file)
109108}
110109
111−/* Completer for the CLI (multiple files, and support to add more). */
110+// Completer for the CLI (multiple files, and support to add more).
112111function cliCompleter(set, done) {
113112 var exposed = {}
114113
@@ -136,12 +135,11 @@ function checkFactory(exposed) {
136135 }
137136}
138137
139−/* Factory to create a transformer based on the given
140− * info and set. */
138+// Factory to create a transformer based on the given info and set.
141139function transformerFactory(fileSet, info) {
142140 return transformer
143141
144− /* Transformer. Adds references files to the set. */
142+ // Transformer. Adds references files to the set.
145143 function transformer(ast, file) {
146144 var filePath = file.path
147145 var space = file.data
@@ -199,7 +197,7 @@ function transformerFactory(fileSet, info) {
199197 }
200198}
201199
202−/* Check if `file` references headings or files not in `exposed`. */
200+// Check if `file` references headings or files not in `exposed`.
203201function validate(exposed, file) {
204202 var references = file.data[referenceId]
205203 var filePath = file.path
@@ -217,11 +215,10 @@ function validate(exposed, file) {
217215 real = exposed[reference]
218216 hash = getHash(reference)
219217
220− /* Check if files without `hash` can be linked to.
221− * Because there’s no need to inspect those files
222− * for headings they are not added to remark. This
223− * is especially useful because they might be
224− * non-markdown files. Here we check if they exist. */
218+ // Check if files without `hash` can be linked to. Because there’s no need
219+ // to inspect those files for headings they are not added to remark. This
220+ // is especially useful because they might be non-markdown files. Here we
221+ // check if they exist.
225222 if ((real === undefined || real === null) && !hash && fs) {
226223 real = fs.existsSync(reference)
227224 references[reference] = real
@@ -255,8 +252,7 @@ function validate(exposed, file) {
255252 }
256253}
257254
258−/* Gather references: a map of file-paths references
259− * to be one or more nodes. */
255+// Gather references: a map of file-paths references to be one or more nodes.
260256function gatherReferences(file, tree, info, fileSet) {
261257 var cache = {}
262258 var getDefinition = definitions(tree)
@@ -278,7 +274,7 @@ function gatherReferences(file, tree, info, fileSet) {
278274
279275 return cache
280276
281− /* Handle new links. */
277+ // Handle new links.
282278 function onlink(node) {
283279 var link = node.url
284280 var definition
@@ -287,13 +283,13 @@ function gatherReferences(file, tree, info, fileSet) {
287283 var pathname
288284 var hash
289285
290− /* Handle link-references. */
286+ // Handle link-references.
291287 if (node.identifier) {
292288 definition = getDefinition(node.identifier)
293289 link = definition && definition.url
294290 }
295291
296− /* Ignore definitions without link. */
292+ // Ignore definitions without link.
297293 if (!link) {
298294 return
299295 }
@@ -309,7 +305,7 @@ function gatherReferences(file, tree, info, fileSet) {
309305 uri.hash = ''
310306 }
311307
312− /* Handle hashes, or relative files. */
308+ // Handle hashes, or relative files.
313309 if (!uri.pathname && uri.hash) {
314310 link = file.path + uri.hash
315311 uri = parse(link)
@@ -324,7 +320,7 @@ function gatherReferences(file, tree, info, fileSet) {
324320 }
325321 }
326322
327− /* Handle full links. */
323+ // Handle full links.
328324 if (uri.hostname) {
329325 if (!prefix || !fileSet) {
330326 return
@@ -339,18 +335,14 @@ function gatherReferences(file, tree, info, fileSet) {
339335
340336 link = uri.pathname.slice(prefix.length) + (uri.hash || '')
341337
342− /* Things get interesting here: branches.
343− * `foo/bar/baz` could be `baz` on the
344− * `foo/bar` branch. Or, `baz` in the `bar`
345− * directory on the `foo` branch.
346− *
347− * Currently, I’m ignoring this and just not
348− * supporting branches. */
338+ // Things get interesting here: branches: `foo/bar/baz` could be `baz` on
339+ // the `foo/bar` branch, or, `baz` in the `bar` directory on the `foo`
340+ // branch.
341+ // Currently, we’re ignoring this and just not supporting branches.
349342 link = link.slice(link.indexOf('/') + 1)
350343 }
351344
352− /* Handle file links, or combinations of files
353− * and hashes. */
345+ // Handle file links, or combinations of files and hashes.
354346 index = link.indexOf(headingPrefix)
355347
356348 if (index === -1) {
@@ -383,7 +375,7 @@ function gatherReferences(file, tree, info, fileSet) {
383375 }
384376}
385377
386−/* Utility to warn `reason` for each node in `nodes` on `file`. */
378+// Utility to warn `reason` for each node in `nodes` on `file`.
387379function warnAll(file, nodes, reason, ruleId) {
388380 nodes.forEach(one)
389381
@@ -392,7 +384,7 @@ function warnAll(file, nodes, reason, ruleId) {
392384 }
393385}
394386
395−/* Suggest a possible similar reference. */
387+// Suggest a possible similar reference.
396388function getClosest(pathname, references) {
397389 var hash = getHash(pathname)
398390 var base = getPathname(pathname)
@@ -417,13 +409,13 @@ function getClosest(pathname, references) {
417409 return propose(hash ? hash : base, dictionary, {threshold: 0.7})
418410}
419411
420−/* Get the `hash` of `uri`, if applicable. */
412+// Get the `hash` of `uri`, if applicable.
421413function getHash(uri) {
422414 var hash = parse(uri).hash
423415 return hash ? hash.slice(1) : null
424416}
425417
426−/* Get the `pathname` of `uri`, if applicable. */
418+// Get the `pathname` of `uri`, if applicable.
427419function getPathname(uri) {
428420 return parse(uri).pathname
429421}