Skip to content

Commit

Permalink
fix: Update scope for a comment that is memberof an other to defaults…
Browse files Browse the repository at this point in the history
… to static.

fix documentationjs#197
  • Loading branch information
lcharbon committed Oct 12, 2018
1 parent 372c8ca commit 97a22a0
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 3 deletions.
36 changes: 36 additions & 0 deletions __tests__/__snapshots__/bin-readme.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,42 @@ A second function with docs
"
`;

exports[`readme command --diff-only: changes needed 1`] = `
"# A title
# API
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->
### Table of Contents
- [foo](#foo)
- [Parameters](#parameters)
- [bar](#bar)
- [Parameters](#parameters-1)
## foo
A function with documentation.
### Parameters
- \`a\` {string} blah
Returns **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** answer
## bar
A second function with docs
### Parameters
- \`b\`
# Another section
"
`;

exports[`readme command --readme-file 1`] = `
"# A title
Expand Down
9 changes: 6 additions & 3 deletions __tests__/__snapshots__/test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -22680,7 +22680,7 @@ Array [
"static": Array [],
},
"name": "getFoo",
"namespace": "MyClass#getFoo",
"namespace": ".MyClass#getFoo",
"params": Array [
Object {
"description": Object {
Expand Down Expand Up @@ -22748,6 +22748,7 @@ Array [
Object {
"kind": "class",
"name": "MyClass",
"scope": "static",
},
Object {
"kind": "function",
Expand Down Expand Up @@ -22933,12 +22934,13 @@ Array [
"static": Array [],
},
"name": "getUndefined",
"namespace": "MyClass.getUndefined",
"namespace": ".MyClass.getUndefined",
"params": Array [],
"path": Array [
Object {
"kind": "class",
"name": "MyClass",
"scope": "static",
},
Object {
"kind": "function",
Expand Down Expand Up @@ -23025,12 +23027,13 @@ Array [
],
},
"name": "MyClass",
"namespace": "MyClass",
"namespace": ".MyClass",
"params": Array [],
"path": Array [
Object {
"kind": "class",
"name": "MyClass",
"scope": "static",
},
],
"properties": Array [],
Expand Down
16 changes: 16 additions & 0 deletions __tests__/lib/hierarchy.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,3 +184,19 @@ test('hierarchy - object prototype member names', function() {
'otherMethod'
]);
});

test('hierarchy - member namespace defaults to static', function() {
const comments = evaluate(function() {
/**
* @namespace fooNamespace
*/
/**
* @class BarClass
* @memberof fooNamespace
*/
});

expect(comments[0].members.static[0].namespace).toEqual(
'fooNamespace.BarClass'
);
});
2 changes: 2 additions & 0 deletions src/hierarchy.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ function pick(comment) {

if (comment.scope) {
item.scope = comment.scope;
} else if (comment.memberof) {
item.scope = 'static';
}

return item;
Expand Down

0 comments on commit 97a22a0

Please sign in to comment.