@@ -55,6 +55,28 @@ function LinkerStack(config) {
55
55
this . link = this . link . bind ( this ) ;
56
56
}
57
57
58
+ /**
59
+ * Given that the linker stack is a stack of functions, each of which might
60
+ * be able to resolve the URL target of a given namespace, namespaceResolver
61
+ * adds a function to the stack. You give it a list of comments and it
62
+ * adds a function that, if it matches a namespace to a comment, runs
63
+ * `resolver` on that comment's namespace in order to get a URL. This makes
64
+ * it possible for themes to put each function on a separate page, or at
65
+ * different anchors on the same page, and the resolver does stuff like
66
+ * adding '#' in front of the namespace or turning the namespace into a URL
67
+ * path.
68
+ *
69
+ * @param {Array<Object> } comments a list of comments
70
+ * @param {Function } a method that turns a namespace into a URL
71
+ * @returns {LinkerStack } returns this
72
+ * @private
73
+ * @example
74
+ * var linkerStack = createLinkerStack(options)
75
+ * .namespaceResolver(comments, function (namespace) {
76
+ * var slugger = new GithubSlugger();
77
+ * return '#' + slugger.slug(namespace);
78
+ * });
79
+ */
58
80
LinkerStack . prototype . namespaceResolver = function ( comments , resolver ) {
59
81
var namespaces = { } ;
60
82
walk ( comments , function ( comment ) {
@@ -68,6 +90,15 @@ LinkerStack.prototype.namespaceResolver = function (comments, resolver) {
68
90
return this ;
69
91
} ;
70
92
93
+ /**
94
+ * Now that you've configured the LinkerStack with `namespaceResolver`
95
+ * and a configuration, run it against a namepath. Might return a URL if
96
+ * it can resolve a target, otherwise returns undefined.
97
+ *
98
+ * @param {string } namepath the namepath of a comment
99
+ * @returns {string? } URL target or maybe undefined
100
+ * @private
101
+ */
71
102
LinkerStack . prototype . link = function ( namepath ) {
72
103
return firstPass ( this . stack , namepath ) ;
73
104
} ;
0 commit comments