Skip to content

Commit 6e9b894

Browse files
committed
Fix #4 parse members and free functions in default namespace
Fix #5 add expanded enum parsing Fix #13 and #11 improve error handling Add --noindex option to disable index generation Add internal link anchors to all member types
1 parent e7b2216 commit 6e9b894

20 files changed

+293
-139
lines changed

TODO.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
test free function
2+
3+
add links to all member entities in index
4+
Add tidy-markdown when stable (2.0.5 is broken)
5+
6+
7+
DONE

bin/moxygen.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ var app = require('../index.js');
99

1010
program.version(pjson.version)
1111
.usage('[options] <doxygen directory>')
12-
.option('-a, --anchors', 'add anchors to internal links', false)
13-
.option('-g, --groups', 'output doxygen groups into separate files', false)
1412
.option('-o, --output <file>', 'output file (must contain %s when using groups)', String, 'api.md')
13+
.option('-g, --groups', 'output doxygen groups into separate files', false)
14+
.option('-n, --noindex', 'disable generation of the index (no effect with `groups` option', false)
15+
.option('-a, --anchors', 'add anchors to internal links', false)
1516
.option('-l, --language <lang>', 'programming language', String, 'cpp')
1617
.option('-t, --templates <dir>', 'custom templates directory', String, 'templates')
1718
.option('-q, --quiet', 'quiet mode', false)
@@ -24,11 +25,12 @@ if (!program.quiet) {
2425
if (program.args.length) {
2526
app.run(assign({}, app.defaultOptions, {
2627
directory: program.args[0],
27-
anchors: program.anchors,
28+
output: program.output,
2829
groups: program.groups,
30+
noindex: program.noindex,
31+
anchors: program.anchors,
2932
language: program.language,
30-
templates: program.templates,
31-
output: program.output
33+
templates: program.templates
3234
}));
3335
}
3436
else {

example/doc/api-bicycle.md

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
1-
# Module <!-- group --> `bicycle`
1+
# group `bicycle` {#group__bicycle}
22

3-
Bicycle module contains the bycicle class. Bicycles are a useful way of transporting oneself, without too much effort).
3+
Bicycle module contains the bycicle class. Bicycles are a useful way of transporting oneself, without too much effort.
44

55
## Summary
66

77
Members | Descriptions
88
--------------------------------|---------------------------------------------
9-
`class `[`transport::Bicycle`](#classtransport_1_1Bicycle) |
10-
# class `transport::Bicycle`
11-
12-
9+
`class `[`transport::Bicycle`](doc/api-bicycle.md#classtransport_1_1Bicycle) | Standard bicycle class.
1310

11+
# class `transport::Bicycle` {#classtransport_1_1Bicycle}
1412

1513
Standard bicycle class.
1614

@@ -20,29 +18,23 @@ Standard bicycle class.
2018

2119
Members | Descriptions
2220
--------------------------------|---------------------------------------------
23-
`public virtual void PedalHarder()` | PedalHarder makes you go faster (usually).
24-
`public virtual void RingBell()` |
25-
`public virtual ~Bicycle()` | Default destructor.
21+
`public virtual void `[`PedalHarder`](#classtransport_1_1Bicycle_1a7df6cce8f18012fb07bef5be9dadd8ef)`()` | PedalHarder makes you go faster (usually).
22+
`public virtual void `[`RingBell`](#classtransport_1_1Bicycle_1a7d2be572f09c78b4d4ae38ef22f3e98b)`()` | Ring bell on the bike.
23+
`public virtual `[`~Bicycle`](#classtransport_1_1Bicycle_1a5f62d09b772a7705634bfb3551803c25)`()` | Default destructor.
2624

2725
## Members
2826

29-
#### `public virtual void PedalHarder()`
27+
#### `public virtual void `[`PedalHarder`](#classtransport_1_1Bicycle_1a7df6cce8f18012fb07bef5be9dadd8ef)`()` {#classtransport_1_1Bicycle_1a7df6cce8f18012fb07bef5be9dadd8ef}
3028

3129
PedalHarder makes you go faster (usually).
3230

33-
34-
35-
#### `public virtual void RingBell()`
36-
37-
31+
#### `public virtual void `[`RingBell`](#classtransport_1_1Bicycle_1a7d2be572f09c78b4d4ae38ef22f3e98b)`()` {#classtransport_1_1Bicycle_1a7d2be572f09c78b4d4ae38ef22f3e98b}
3832

3933
Ring bell on the bike.
4034

4135
RingBell rings the bell on the bike. Note that not all bikes have bells.
4236

43-
#### `public virtual ~Bicycle()`
37+
#### `public virtual `[`~Bicycle`](#classtransport_1_1Bicycle_1a5f62d09b772a7705634bfb3551803c25)`()` {#classtransport_1_1Bicycle_1a5f62d09b772a7705634bfb3551803c25}
4438

4539
Default destructor.
4640

47-
48-

example/doc/api-mountainbike.md

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
1-
# Module <!-- group --> `mountainbike`
1+
# group `mountainbike` {#group__mountainbike}
22

33
Mountain bike module contains the `MountainBike` class. Mountain bikes are a kind of bike for cycling on rough terrain.
44

55
## Summary
66

77
Members | Descriptions
88
--------------------------------|---------------------------------------------
9-
`class `[`transport::MountainBike`](#classtransport_1_1MountainBike) |
10-
# class `transport::MountainBike`
9+
`class `[`transport::MountainBike`](doc/api-mountainbike.md#classtransport_1_1MountainBike) | Mountain bike implementation of a `[Bicycle](doc/api-bicycle.md#classtransport_1_1Bicycle)`.
10+
11+
# class `transport::MountainBike` {#classtransport_1_1MountainBike}
1112

1213
```
1314
class transport::MountainBike
1415
: public transport::Bicycle
1516
```
1617

17-
18-
1918
Mountain bike implementation of a `[Bicycle](#classtransport_1_1Bicycle)`.
2019

2120
[MountainBike](#classtransport_1_1MountainBike) is an implementation of a [Bicycle](#classtransport_1_1Bicycle) providing a bike for cycling on rough terrain. Mountain bikes are pretty cool because they have stuff like **Suspension** (and you can even adjust it using SetSuspension). If you're looking for a bike for use on the road, you might be better off using a [RacingBike](#classtransport_1_1RacingBike) though.
@@ -24,32 +23,26 @@ Mountain bike implementation of a `[Bicycle](#classtransport_1_1Bicycle)`.
2423

2524
Members | Descriptions
2625
--------------------------------|---------------------------------------------
27-
`public bool SetSuspension(double stiffness)` |
28-
`public template<typename BreakType>` <br/>`inline bool ChangeBreak(BreakType breakType)` |
26+
`public bool `[`SetSuspension`](#classtransport_1_1MountainBike_1a04caecd7e5ff7572b6ac1dc283510301)`(double stiffness)` | Set suspension stiffness. the suspension stiffness.
27+
`public template<typename BreakType>` <br/>`inline bool `[`ChangeBreak`](#classtransport_1_1MountainBike_1afd02513876a196e98acaacdc555aeb52)`(BreakType breakType)` | Change the break type. the break type. the type of the break.
2928

3029
## Members
3130

32-
#### `public bool SetSuspension(double stiffness)`
33-
34-
31+
#### `public bool `[`SetSuspension`](#classtransport_1_1MountainBike_1a04caecd7e5ff7572b6ac1dc283510301)`(double stiffness)` {#classtransport_1_1MountainBike_1a04caecd7e5ff7572b6ac1dc283510301}
3532

3633
Set suspension stiffness. the suspension stiffness.
3734

3835
SetSuspension changes the stiffness of the suspension on the bike. The method will return false if the stiffness could not be adjusted.
3936

40-
4137
#### Returns
4238
true if the suspension was adjusted successfully, false otherwise.
4339

44-
#### `public template<typename BreakType>` <br/>`inline bool ChangeBreak(BreakType breakType)`
45-
46-
40+
#### `public template<typename BreakType>` <br/>`inline bool `[`ChangeBreak`](#classtransport_1_1MountainBike_1afd02513876a196e98acaacdc555aeb52)`(BreakType breakType)` {#classtransport_1_1MountainBike_1afd02513876a196e98acaacdc555aeb52}
4741

4842
Change the break type. the break type. the type of the break.
4943

5044
ChangesBreak changes the type of break fitted to the bike. The method will return false if the break type could not be fitted.
5145

52-
5346
#### Returns
5447
true if the break was adjusted successfully. false otherise
5548

example/doc/api-racingbike.md

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
1-
# Module <!-- group --> `racingbike`
1+
# group `racingbike` {#group__racingbike}
22

33
Racing bike module contains the `RacingBike` class. Racing bikes are a special kind of bike which can go much faster on the road, with much less effort.
44

55
## Summary
66

77
Members | Descriptions
88
--------------------------------|---------------------------------------------
9-
`class `[`transport::RacingBike`](#classtransport_1_1RacingBike) |
10-
# class `transport::RacingBike`
9+
`class `[`transport::RacingBike`](doc/api-racingbike.md#classtransport_1_1RacingBike) | Racing bike class.
10+
11+
# class `transport::RacingBike` {#classtransport_1_1RacingBike}
1112

1213
```
1314
class transport::RacingBike
1415
: public transport::Bicycle
1516
```
1617

17-
18-
1918
Racing bike class.
2019

2120
[RacingBike](#classtransport_1_1RacingBike) is a special kind of bike which can go much faster on the road, with much less effort (even uphill!). It doesn't make sense to call `RingBell` on a racing bike for they don't have bells.
@@ -24,20 +23,16 @@ Racing bike class.
2423

2524
Members | Descriptions
2625
--------------------------------|---------------------------------------------
27-
`public virtual void PedalHarder()` | PedalHarder makes you go faster (usually).
28-
`public virtual void RingBell()` |
26+
`public virtual void `[`PedalHarder`](#classtransport_1_1RacingBike_1ab557c5727daa07a5001782d5dcd46c5b)`()` | PedalHarder makes you go faster (usually).
27+
`public virtual void `[`RingBell`](#classtransport_1_1RacingBike_1ad32dc3b06a453fba3e20329842bb318b)`()` | Ring bell on the bike.
2928

3029
## Members
3130

32-
#### `public virtual void PedalHarder()`
31+
#### `public virtual void `[`PedalHarder`](#classtransport_1_1RacingBike_1ab557c5727daa07a5001782d5dcd46c5b)`()` {#classtransport_1_1RacingBike_1ab557c5727daa07a5001782d5dcd46c5b}
3332

3433
PedalHarder makes you go faster (usually).
3534

36-
37-
38-
#### `public virtual void RingBell()`
39-
40-
35+
#### `public virtual void `[`RingBell`](#classtransport_1_1RacingBike_1ad32dc3b06a453fba3e20329842bb318b)`()` {#classtransport_1_1RacingBike_1ad32dc3b06a453fba3e20329842bb318b}
4136

4237
Ring bell on the bike.
4338

example/src/transport.h

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
/** @defgroup bicycle Bycicle module
55
*
66
* Bicycle module contains the bycicle class. Bicycles are a useful way of
7-
* transporting oneself, without too much effort).
7+
* transporting oneself, without too much effort.
88
*/
99

1010
#include <transport/bicycle.h>
@@ -26,4 +26,24 @@
2626

2727
#include <transport/mountainbike.h>
2828

29+
/**
30+
* Enum class for transport types.
31+
*
32+
* This definition exists in the default namespace and is ungrouped.
33+
* It will *not* be displayed if the `groups` options is used.
34+
*/
35+
enum class TransportType {
36+
Bycicle, /*!< Bycicle type */
37+
RacingBike, /*!< Racing bike type */
38+
RacingBike /*!< Mountain bike type */
39+
};
40+
41+
/**
42+
* The modifier value if pedal power is used.
43+
*
44+
* This definition exists in the default namespace and is ungrouped.
45+
* It will *not* be displayed if the `groups` options is used.
46+
*/
47+
#define PEDAL_POWER_MODIFIER 9000
48+
2949
#endif /* __TRANSPORT_H__ */

example/xml/group__bicycle.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
<briefdescription>
88
</briefdescription>
99
<detaileddescription>
10-
<para>Bicycle module contains the bycicle class. Bicycles are a useful way of transporting oneself, without too much effort). </para> </detaileddescription>
10+
<para>Bicycle module contains the bycicle class. Bicycles are a useful way of transporting oneself, without too much effort. </para> </detaileddescription>
1111
</compounddef>
1212
</doxygen>

example/xml/index.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@
2828
<compound refid="racingbike_8h" kind="file"><name>racingbike.h</name>
2929
</compound>
3030
<compound refid="transport_8h" kind="file"><name>transport.h</name>
31+
<member refid="transport_8h_1afbbb18ca59257b9b19eced9dcb7c7973" kind="define"><name>PEDAL_POWER_MODIFIER</name></member>
32+
<member refid="transport_8h_1aca1e72535e7f260e54ed8bbf984dade9" kind="enum"><name>TransportType</name></member>
33+
<member refid="transport_8h_1aca1e72535e7f260e54ed8bbf984dade9a8e8125cebd24bc06c2dbc178336da70f" kind="enumvalue"><name>Bycicle</name></member>
34+
<member refid="transport_8h_1aca1e72535e7f260e54ed8bbf984dade9ac34fdf94888bac1e847f369e76c9d15b" kind="enumvalue"><name>RacingBike</name></member>
35+
<member refid="transport_8h_1aca1e72535e7f260e54ed8bbf984dade9ac34fdf94888bac1e847f369e76c9d15b" kind="enumvalue"><name>RacingBike</name></member>
3136
</compound>
3237
<compound refid="group__bicycle" kind="group"><name>bicycle</name>
3338
</compound>

example/xml/transport_8h.xml

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,52 @@
2626
<label>transport/bicycle.h</label>
2727
</node>
2828
</incdepgraph>
29+
<sectiondef kind="define">
30+
<memberdef kind="define" id="transport_8h_1afbbb18ca59257b9b19eced9dcb7c7973" prot="public" static="no">
31+
<name>PEDAL_POWER_MODIFIER</name>
32+
<initializer>9000</initializer>
33+
<briefdescription>
34+
</briefdescription>
35+
<detaileddescription>
36+
<para>The modifier value if pedal power is used.</para><para>This definition exists in the default namespace and is ungrouped. It will <emphasis>not</emphasis> be displayed if the <computeroutput>groups</computeroutput> options is used. </para> </detaileddescription>
37+
<inbodydescription>
38+
</inbodydescription>
39+
<location file="src/transport.h" line="47" column="9" bodyfile="src/transport.h" bodystart="47" bodyend="-1"/>
40+
</memberdef>
41+
</sectiondef>
42+
<sectiondef kind="enum">
43+
<memberdef kind="enum" id="transport_8h_1aca1e72535e7f260e54ed8bbf984dade9" prot="public" static="no">
44+
<name>TransportType</name>
45+
<enumvalue id="transport_8h_1aca1e72535e7f260e54ed8bbf984dade9a8e8125cebd24bc06c2dbc178336da70f" prot="public">
46+
<name>Bycicle</name>
47+
<briefdescription>
48+
</briefdescription>
49+
<detaileddescription>
50+
<para>Bycicle type </para> </detaileddescription>
51+
</enumvalue>
52+
<enumvalue id="transport_8h_1aca1e72535e7f260e54ed8bbf984dade9ac34fdf94888bac1e847f369e76c9d15b" prot="public">
53+
<name>RacingBike</name>
54+
<briefdescription>
55+
</briefdescription>
56+
<detaileddescription>
57+
<para>Racing bike type </para> </detaileddescription>
58+
</enumvalue>
59+
<enumvalue id="transport_8h_1aca1e72535e7f260e54ed8bbf984dade9ac34fdf94888bac1e847f369e76c9d15b" prot="public">
60+
<name>RacingBike</name>
61+
<briefdescription>
62+
</briefdescription>
63+
<detaileddescription>
64+
<para>Mountain bike type </para> </detaileddescription>
65+
</enumvalue>
66+
<briefdescription>
67+
</briefdescription>
68+
<detaileddescription>
69+
<para>Enum class for transport types.</para><para>This definition exists in the default namespace and is ungrouped. It will <emphasis>not</emphasis> be displayed if the <computeroutput>groups</computeroutput> options is used. </para> </detaileddescription>
70+
<inbodydescription>
71+
</inbodydescription>
72+
<location file="src/transport.h" line="35" column="1" bodyfile="src/transport.h" bodystart="35" bodyend="39"/>
73+
</memberdef>
74+
</sectiondef>
2975
<briefdescription>
3076
</briefdescription>
3177
<detaileddescription>
@@ -40,7 +86,15 @@
4086
<codeline lineno="20"><highlight class="normal"></highlight></codeline>
4187
<codeline lineno="27"><highlight class="preprocessor">#include<sp/>&lt;transport/mountainbike.h&gt;</highlight><highlight class="normal"></highlight></codeline>
4288
<codeline lineno="28"><highlight class="normal"></highlight></codeline>
43-
<codeline lineno="29"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>__TRANSPORT_H__<sp/>*/</highlight><highlight class="preprocessor"></highlight></codeline>
89+
<codeline lineno="35"><highlight class="keyword">enum<sp/>class</highlight><highlight class="normal"><sp/>TransportType<sp/>{</highlight></codeline>
90+
<codeline lineno="36"><highlight class="normal"><sp/><sp/>Bycicle,<sp/></highlight></codeline>
91+
<codeline lineno="37"><highlight class="normal"><sp/><sp/>RacingBike,<sp/></highlight></codeline>
92+
<codeline lineno="38"><highlight class="normal"><sp/><sp/>RacingBike<sp/></highlight></codeline>
93+
<codeline lineno="39"><highlight class="normal">};</highlight></codeline>
94+
<codeline lineno="40"><highlight class="normal"></highlight></codeline>
95+
<codeline lineno="47"><highlight class="preprocessor">#define<sp/>PEDAL_POWER_MODIFIER<sp/>9000</highlight><highlight class="normal"></highlight></codeline>
96+
<codeline lineno="48"><highlight class="normal"></highlight></codeline>
97+
<codeline lineno="49"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>__TRANSPORT_H__<sp/>*/</highlight><highlight class="preprocessor"></highlight></codeline>
4498
</programlisting>
4599
<location file="src/transport.h"/>
46100
</compounddef>

index.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,20 @@ module.exports = {
2121
defaultOptions: {
2222

2323
directory: null, /** Location of the doxygen files **/
24-
anchors: true, /** Generate anchors for internal links **/
24+
output: 'api.md', /** Output file **/
2525
groups: false, /** Output doxygen groups separately **/
26+
noindex: false, /** Disable generation of the index. Does not work with `groups` option **/
27+
anchors: true, /** Generate anchors for internal links **/
2628
language: 'cpp', /** Programming language **/
2729
templates: 'templates', /** Templates directory **/
28-
output: 'api.md', /** Output file **/
2930

3031
filters: {
3132
members: [
33+
'define',
34+
'enum',
35+
// 'enumvalue',
36+
'func',
37+
// 'variable',
3238
'public-attrib',
3339
'public-func',
3440
'protected-attrib',
@@ -39,7 +45,8 @@ module.exports = {
3945
'class',
4046
'struct',
4147
'union',
42-
'typedef'
48+
'typedef',
49+
// 'file'
4350
]
4451
}
4552
},
@@ -63,6 +70,8 @@ module.exports = {
6370

6471
// Parse files
6572
doxyparser.loadIndex(options, function (err, root) {
73+
if (err)
74+
throw err;
6675

6776
// Output groups
6877
if (options.groups) {
@@ -86,6 +95,8 @@ module.exports = {
8695
root.filterChildren(options.filters);
8796

8897
var compounds = root.toFilteredArray('compounds');
98+
if (!options.noindex)
99+
compounds.unshift(root); // insert root at top if index is enabled
89100
var contents = templates.renderArray(compounds);
90101
helpers.writeFile(options.output, contents);
91102
}

0 commit comments

Comments
 (0)