Skip to content

Commit 1bae7fd

Browse files
codebase refactoring and minor improvements, closes #1
* simplified converting methods * test coverage for new sources parser and generator * fix failing tests * updated readme
1 parent b67b37d commit 1bae7fd

22 files changed

+849
-1039
lines changed

README.md

Lines changed: 43 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,20 +83,44 @@ To use `doxyjs` with Doxygen you must make few changes to your Doxyfile.
8383
8484
## Documenting code
8585
86+
### Files
87+
88+
It's pretty straightforward:
89+
90+
```javascript
91+
/*!
92+
* @file FileName.js
93+
* @brief File description goes here
94+
*/
95+
```
96+
97+
will produce:
98+
99+
```c++
100+
/*!
101+
* @file FileName.js
102+
* @brief File description goes here
103+
*/
104+
```
105+
86106
### Variables
87107

88108
`doxyjs` will use `var` as default variable's type, but you can override it with `type:<YourTypeHere>`.
89109

90110
```javascript
91-
//! type:String This is variable
92-
var a = 'some string value';
111+
//! This is variable
112+
var a = 42;
113+
//! type:String This is string variable
114+
var b = 'some string value';
93115
```
94116

95117
Code above will transform into:
96118

97119
```c++
98120
//! This is variable
99-
String a;
121+
var a;
122+
//! This is string variable
123+
String b;
100124
```
101125

102126
However, you can omit any type definitions. Then default type `var` will be used.
@@ -106,6 +130,10 @@ However, you can omit any type definitions. Then default type `var` will be used
106130
Type definition for function arguments done the same way as for variables. Also you're able define functions's return type, however, this is still optional.
107131

108132
```javascript
133+
//! Short function description
134+
function foo(args) {
135+
}
136+
109137
/*!
110138
* @brief Test Function
111139
* @param type:Object param1 first parameter
@@ -120,6 +148,11 @@ function global_function_with_args(param1, param2) {
120148
Resulting pseudo C++:
121149

122150
```c++
151+
/*!
152+
* @brief Short function description
153+
*/
154+
void foo(var args);
155+
123156
/*!
124157
* @brief Test Function
125158
* @param param1 first parameter
@@ -134,16 +167,18 @@ For functions without return value, just omit `@return` comment section:
134167
```javascript
135168
/*!
136169
* @brief Test Function
170+
* @param type:Date foo parameter description
137171
*/
138-
function global_function_without_arg() {
172+
function global_function_without_arg(var foo) {
139173
}
140174
```
141175

142176
```c++
143177
/*!
144178
* @brief Test Function
179+
* @param foo parameter description
145180
*/
146-
void global_function_without_arg();
181+
void global_function_without_arg(Date foo);
147182
```
148183
149184
### Classes
@@ -268,7 +303,7 @@ Here some things to notice:
268303
269304
Here `Argument` will be used as base class of `Event`.
270305
271-
* Classes brief description and constructor's parameters are extracted from next comment:
306+
* Class'es brief description and constructor's parameters are extracted from next comment:
272307
273308
```javascript
274309
/*!
@@ -281,6 +316,8 @@ Here some things to notice:
281316
282317
Here `@brief` is used for class description, and `@param` is used for constructor's parameters documentation.
283318
319+
* Docs for class methods done the same way as for global functions.
320+
284321
## CHANGELOG
285322
286323
[CHANGELOG](./CHANGELOG.md)

__tests__/doxyjs.test.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
const localize = require('localize');
2+
const ts = require('../translations/translations.json');
3+
4+
const commentSeeds = require('./seeds/commentSeeds');
5+
const variableSeeds = require('./seeds/variableSeeds');
6+
const functionSeeds = require('./seeds/functionSeeds');
7+
const classSeeds = require('./seeds/classSeeds');
8+
9+
const doxyjs = require('../doxyjs');
10+
11+
const translator = new localize(ts);
12+
const linebreak = '\n';
13+
14+
describe('doxyjs', () => {
15+
const testSeeds = seed => {
16+
seed.input.forEach((input, index) => {
17+
expect(doxyjs(input, linebreak, translator)).toEqual(seed.output[index]);
18+
});
19+
};
20+
21+
it('converts comments', () => {
22+
testSeeds(commentSeeds);
23+
});
24+
25+
it('converts variables', () => {
26+
testSeeds(variableSeeds);
27+
});
28+
29+
it('converts functions', () => {
30+
testSeeds(functionSeeds);
31+
});
32+
33+
it('converts classes', () => {
34+
testSeeds(classSeeds);
35+
});
36+
});

__tests__/extractToken.test.js

Lines changed: 0 additions & 189 deletions
This file was deleted.

__tests__/reduceToken.test.js

Lines changed: 0 additions & 62 deletions
This file was deleted.

0 commit comments

Comments
 (0)