Skip to content

Commit 59325ea

Browse files
author
lcharbon
committed
fix: Update scope to default to static when memberof
fix documentationjs#197
1 parent 372c8ca commit 59325ea

File tree

4 files changed

+60
-3
lines changed

4 files changed

+60
-3
lines changed

__tests__/__snapshots__/bin-readme.js.snap

+36
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,42 @@ A second function with docs
3636
"
3737
`;
3838

39+
exports[`readme command --diff-only: changes needed 1`] = `
40+
"# A title
41+
42+
# API
43+
44+
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->
45+
46+
### Table of Contents
47+
48+
- [foo](#foo)
49+
- [Parameters](#parameters)
50+
- [bar](#bar)
51+
- [Parameters](#parameters-1)
52+
53+
## foo
54+
55+
A function with documentation.
56+
57+
### Parameters
58+
59+
- \`a\` {string} blah
60+
61+
Returns **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** answer
62+
63+
## bar
64+
65+
A second function with docs
66+
67+
### Parameters
68+
69+
- \`b\`
70+
71+
# Another section
72+
"
73+
`;
74+
3975
exports[`readme command --readme-file 1`] = `
4076
"# A title
4177

__tests__/__snapshots__/test.js.snap

+6-3
Original file line numberDiff line numberDiff line change
@@ -22680,7 +22680,7 @@ Array [
2268022680
"static": Array [],
2268122681
},
2268222682
"name": "getFoo",
22683-
"namespace": "MyClass#getFoo",
22683+
"namespace": ".MyClass#getFoo",
2268422684
"params": Array [
2268522685
Object {
2268622686
"description": Object {
@@ -22748,6 +22748,7 @@ Array [
2274822748
Object {
2274922749
"kind": "class",
2275022750
"name": "MyClass",
22751+
"scope": "static",
2275122752
},
2275222753
Object {
2275322754
"kind": "function",
@@ -22933,12 +22934,13 @@ Array [
2293322934
"static": Array [],
2293422935
},
2293522936
"name": "getUndefined",
22936-
"namespace": "MyClass.getUndefined",
22937+
"namespace": ".MyClass.getUndefined",
2293722938
"params": Array [],
2293822939
"path": Array [
2293922940
Object {
2294022941
"kind": "class",
2294122942
"name": "MyClass",
22943+
"scope": "static",
2294222944
},
2294322945
Object {
2294422946
"kind": "function",
@@ -23025,12 +23027,13 @@ Array [
2302523027
],
2302623028
},
2302723029
"name": "MyClass",
23028-
"namespace": "MyClass",
23030+
"namespace": ".MyClass",
2302923031
"params": Array [],
2303023032
"path": Array [
2303123033
Object {
2303223034
"kind": "class",
2303323035
"name": "MyClass",
23036+
"scope": "static",
2303423037
},
2303523038
],
2303623039
"properties": Array [],

__tests__/lib/hierarchy.js

+16
Original file line numberDiff line numberDiff line change
@@ -184,3 +184,19 @@ test('hierarchy - object prototype member names', function() {
184184
'otherMethod'
185185
]);
186186
});
187+
188+
test('hierarchy - member namespace defaults to static', function() {
189+
const comments = evaluate(function() {
190+
/**
191+
* @namespace fooNamespace
192+
*/
193+
/**
194+
* @class BarClass
195+
* @memberof fooNamespace
196+
*/
197+
});
198+
199+
expect(comments[0].members.static[0].namespace).toEqual(
200+
'fooNamespace.BarClass'
201+
);
202+
});

src/hierarchy.js

+2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ function pick(comment) {
3939

4040
if (comment.scope) {
4141
item.scope = comment.scope;
42+
} else if (comment.memberof) {
43+
item.scope = 'static';
4244
}
4345

4446
return item;

0 commit comments

Comments
 (0)