Skip to content

Commit

Permalink
Fix #4 parse members and free functions in default namespace
Browse files Browse the repository at this point in the history
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
  • Loading branch information
auscaster committed May 19, 2017
1 parent e7b2216 commit 6e9b894
Show file tree
Hide file tree
Showing 20 changed files with 293 additions and 139 deletions.
7 changes: 7 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
test free function

add links to all member entities in index
Add tidy-markdown when stable (2.0.5 is broken)


DONE
12 changes: 7 additions & 5 deletions bin/moxygen.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ var app = require('../index.js');

program.version(pjson.version)
.usage('[options] <doxygen directory>')
.option('-a, --anchors', 'add anchors to internal links', false)
.option('-g, --groups', 'output doxygen groups into separate files', false)
.option('-o, --output <file>', 'output file (must contain %s when using groups)', String, 'api.md')
.option('-g, --groups', 'output doxygen groups into separate files', false)
.option('-n, --noindex', 'disable generation of the index (no effect with `groups` option', false)
.option('-a, --anchors', 'add anchors to internal links', false)
.option('-l, --language <lang>', 'programming language', String, 'cpp')
.option('-t, --templates <dir>', 'custom templates directory', String, 'templates')
.option('-q, --quiet', 'quiet mode', false)
Expand All @@ -24,11 +25,12 @@ if (!program.quiet) {
if (program.args.length) {
app.run(assign({}, app.defaultOptions, {
directory: program.args[0],
anchors: program.anchors,
output: program.output,
groups: program.groups,
noindex: program.noindex,
anchors: program.anchors,
language: program.language,
templates: program.templates,
output: program.output
templates: program.templates
}));
}
else {
Expand Down
28 changes: 10 additions & 18 deletions example/doc/api-bicycle.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
# Module <!-- group --> `bicycle`
# group `bicycle` {#group__bicycle}

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

## Summary

Members | Descriptions
--------------------------------|---------------------------------------------
`class `[`transport::Bicycle`](#classtransport_1_1Bicycle) |
# class `transport::Bicycle`


`class `[`transport::Bicycle`](doc/api-bicycle.md#classtransport_1_1Bicycle) | Standard bicycle class.

# class `transport::Bicycle` {#classtransport_1_1Bicycle}

Standard bicycle class.

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

Members | Descriptions
--------------------------------|---------------------------------------------
`public virtual void PedalHarder()` | PedalHarder makes you go faster (usually).
`public virtual void RingBell()` |
`public virtual ~Bicycle()` | Default destructor.
`public virtual void `[`PedalHarder`](#classtransport_1_1Bicycle_1a7df6cce8f18012fb07bef5be9dadd8ef)`()` | PedalHarder makes you go faster (usually).
`public virtual void `[`RingBell`](#classtransport_1_1Bicycle_1a7d2be572f09c78b4d4ae38ef22f3e98b)`()` | Ring bell on the bike.
`public virtual `[`~Bicycle`](#classtransport_1_1Bicycle_1a5f62d09b772a7705634bfb3551803c25)`()` | Default destructor.

## Members

#### `public virtual void PedalHarder()`
#### `public virtual void `[`PedalHarder`](#classtransport_1_1Bicycle_1a7df6cce8f18012fb07bef5be9dadd8ef)`()` {#classtransport_1_1Bicycle_1a7df6cce8f18012fb07bef5be9dadd8ef}

PedalHarder makes you go faster (usually).



#### `public virtual void RingBell()`


#### `public virtual void `[`RingBell`](#classtransport_1_1Bicycle_1a7d2be572f09c78b4d4ae38ef22f3e98b)`()` {#classtransport_1_1Bicycle_1a7d2be572f09c78b4d4ae38ef22f3e98b}

Ring bell on the bike.

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

#### `public virtual ~Bicycle()`
#### `public virtual `[`~Bicycle`](#classtransport_1_1Bicycle_1a5f62d09b772a7705634bfb3551803c25)`()` {#classtransport_1_1Bicycle_1a5f62d09b772a7705634bfb3551803c25}

Default destructor.



23 changes: 8 additions & 15 deletions example/doc/api-mountainbike.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
# Module <!-- group --> `mountainbike`
# group `mountainbike` {#group__mountainbike}

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

## Summary

Members | Descriptions
--------------------------------|---------------------------------------------
`class `[`transport::MountainBike`](#classtransport_1_1MountainBike) |
# class `transport::MountainBike`
`class `[`transport::MountainBike`](doc/api-mountainbike.md#classtransport_1_1MountainBike) | Mountain bike implementation of a `[Bicycle](doc/api-bicycle.md#classtransport_1_1Bicycle)`.

# class `transport::MountainBike` {#classtransport_1_1MountainBike}

```
class transport::MountainBike
: public transport::Bicycle
```



Mountain bike implementation of a `[Bicycle](#classtransport_1_1Bicycle)`.

[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.
Expand All @@ -24,32 +23,26 @@ Mountain bike implementation of a `[Bicycle](#classtransport_1_1Bicycle)`.

Members | Descriptions
--------------------------------|---------------------------------------------
`public bool SetSuspension(double stiffness)` |
`public template<typename BreakType>` <br/>`inline bool ChangeBreak(BreakType breakType)` |
`public bool `[`SetSuspension`](#classtransport_1_1MountainBike_1a04caecd7e5ff7572b6ac1dc283510301)`(double stiffness)` | Set suspension stiffness. the suspension stiffness.
`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.

## Members

#### `public bool SetSuspension(double stiffness)`


#### `public bool `[`SetSuspension`](#classtransport_1_1MountainBike_1a04caecd7e5ff7572b6ac1dc283510301)`(double stiffness)` {#classtransport_1_1MountainBike_1a04caecd7e5ff7572b6ac1dc283510301}

Set suspension stiffness. the suspension stiffness.

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


#### Returns
true if the suspension was adjusted successfully, false otherwise.

#### `public template<typename BreakType>` <br/>`inline bool ChangeBreak(BreakType breakType)`


#### `public template<typename BreakType>` <br/>`inline bool `[`ChangeBreak`](#classtransport_1_1MountainBike_1afd02513876a196e98acaacdc555aeb52)`(BreakType breakType)` {#classtransport_1_1MountainBike_1afd02513876a196e98acaacdc555aeb52}

Change the break type. the break type. the type of the break.

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


#### Returns
true if the break was adjusted successfully. false otherise

21 changes: 8 additions & 13 deletions example/doc/api-racingbike.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
# Module <!-- group --> `racingbike`
# group `racingbike` {#group__racingbike}

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.

## Summary

Members | Descriptions
--------------------------------|---------------------------------------------
`class `[`transport::RacingBike`](#classtransport_1_1RacingBike) |
# class `transport::RacingBike`
`class `[`transport::RacingBike`](doc/api-racingbike.md#classtransport_1_1RacingBike) | Racing bike class.

# class `transport::RacingBike` {#classtransport_1_1RacingBike}

```
class transport::RacingBike
: public transport::Bicycle
```



Racing bike class.

[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.
Expand All @@ -24,20 +23,16 @@ Racing bike class.

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

## Members

#### `public virtual void PedalHarder()`
#### `public virtual void `[`PedalHarder`](#classtransport_1_1RacingBike_1ab557c5727daa07a5001782d5dcd46c5b)`()` {#classtransport_1_1RacingBike_1ab557c5727daa07a5001782d5dcd46c5b}

PedalHarder makes you go faster (usually).



#### `public virtual void RingBell()`


#### `public virtual void `[`RingBell`](#classtransport_1_1RacingBike_1ad32dc3b06a453fba3e20329842bb318b)`()` {#classtransport_1_1RacingBike_1ad32dc3b06a453fba3e20329842bb318b}

Ring bell on the bike.

Expand Down
22 changes: 21 additions & 1 deletion example/src/transport.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/** @defgroup bicycle Bycicle module
*
* Bicycle module contains the bycicle class. Bicycles are a useful way of
* transporting oneself, without too much effort).
* transporting oneself, without too much effort.
*/

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

#include <transport/mountainbike.h>

/**
* Enum class for transport types.
*
* This definition exists in the default namespace and is ungrouped.
* It will *not* be displayed if the `groups` options is used.
*/
enum class TransportType {
Bycicle, /*!< Bycicle type */
RacingBike, /*!< Racing bike type */
RacingBike /*!< Mountain bike type */
};

/**
* The modifier value if pedal power is used.
*
* This definition exists in the default namespace and is ungrouped.
* It will *not* be displayed if the `groups` options is used.
*/
#define PEDAL_POWER_MODIFIER 9000

#endif /* __TRANSPORT_H__ */
2 changes: 1 addition & 1 deletion example/xml/group__bicycle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
<briefdescription>
</briefdescription>
<detaileddescription>
<para>Bicycle module contains the bycicle class. Bicycles are a useful way of transporting oneself, without too much effort). </para> </detaileddescription>
<para>Bicycle module contains the bycicle class. Bicycles are a useful way of transporting oneself, without too much effort. </para> </detaileddescription>
</compounddef>
</doxygen>
5 changes: 5 additions & 0 deletions example/xml/index.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@
<compound refid="racingbike_8h" kind="file"><name>racingbike.h</name>
</compound>
<compound refid="transport_8h" kind="file"><name>transport.h</name>
<member refid="transport_8h_1afbbb18ca59257b9b19eced9dcb7c7973" kind="define"><name>PEDAL_POWER_MODIFIER</name></member>
<member refid="transport_8h_1aca1e72535e7f260e54ed8bbf984dade9" kind="enum"><name>TransportType</name></member>
<member refid="transport_8h_1aca1e72535e7f260e54ed8bbf984dade9a8e8125cebd24bc06c2dbc178336da70f" kind="enumvalue"><name>Bycicle</name></member>
<member refid="transport_8h_1aca1e72535e7f260e54ed8bbf984dade9ac34fdf94888bac1e847f369e76c9d15b" kind="enumvalue"><name>RacingBike</name></member>
<member refid="transport_8h_1aca1e72535e7f260e54ed8bbf984dade9ac34fdf94888bac1e847f369e76c9d15b" kind="enumvalue"><name>RacingBike</name></member>
</compound>
<compound refid="group__bicycle" kind="group"><name>bicycle</name>
</compound>
Expand Down
56 changes: 55 additions & 1 deletion example/xml/transport_8h.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,52 @@
<label>transport/bicycle.h</label>
</node>
</incdepgraph>
<sectiondef kind="define">
<memberdef kind="define" id="transport_8h_1afbbb18ca59257b9b19eced9dcb7c7973" prot="public" static="no">
<name>PEDAL_POWER_MODIFIER</name>
<initializer>9000</initializer>
<briefdescription>
</briefdescription>
<detaileddescription>
<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>
<inbodydescription>
</inbodydescription>
<location file="src/transport.h" line="47" column="9" bodyfile="src/transport.h" bodystart="47" bodyend="-1"/>
</memberdef>
</sectiondef>
<sectiondef kind="enum">
<memberdef kind="enum" id="transport_8h_1aca1e72535e7f260e54ed8bbf984dade9" prot="public" static="no">
<name>TransportType</name>
<enumvalue id="transport_8h_1aca1e72535e7f260e54ed8bbf984dade9a8e8125cebd24bc06c2dbc178336da70f" prot="public">
<name>Bycicle</name>
<briefdescription>
</briefdescription>
<detaileddescription>
<para>Bycicle type </para> </detaileddescription>
</enumvalue>
<enumvalue id="transport_8h_1aca1e72535e7f260e54ed8bbf984dade9ac34fdf94888bac1e847f369e76c9d15b" prot="public">
<name>RacingBike</name>
<briefdescription>
</briefdescription>
<detaileddescription>
<para>Racing bike type </para> </detaileddescription>
</enumvalue>
<enumvalue id="transport_8h_1aca1e72535e7f260e54ed8bbf984dade9ac34fdf94888bac1e847f369e76c9d15b" prot="public">
<name>RacingBike</name>
<briefdescription>
</briefdescription>
<detaileddescription>
<para>Mountain bike type </para> </detaileddescription>
</enumvalue>
<briefdescription>
</briefdescription>
<detaileddescription>
<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>
<inbodydescription>
</inbodydescription>
<location file="src/transport.h" line="35" column="1" bodyfile="src/transport.h" bodystart="35" bodyend="39"/>
</memberdef>
</sectiondef>
<briefdescription>
</briefdescription>
<detaileddescription>
Expand All @@ -40,7 +86,15 @@
<codeline lineno="20"><highlight class="normal"></highlight></codeline>
<codeline lineno="27"><highlight class="preprocessor">#include<sp/>&lt;transport/mountainbike.h&gt;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="28"><highlight class="normal"></highlight></codeline>
<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>
<codeline lineno="35"><highlight class="keyword">enum<sp/>class</highlight><highlight class="normal"><sp/>TransportType<sp/>{</highlight></codeline>
<codeline lineno="36"><highlight class="normal"><sp/><sp/>Bycicle,<sp/></highlight></codeline>
<codeline lineno="37"><highlight class="normal"><sp/><sp/>RacingBike,<sp/></highlight></codeline>
<codeline lineno="38"><highlight class="normal"><sp/><sp/>RacingBike<sp/></highlight></codeline>
<codeline lineno="39"><highlight class="normal">};</highlight></codeline>
<codeline lineno="40"><highlight class="normal"></highlight></codeline>
<codeline lineno="47"><highlight class="preprocessor">#define<sp/>PEDAL_POWER_MODIFIER<sp/>9000</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="48"><highlight class="normal"></highlight></codeline>
<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>
</programlisting>
<location file="src/transport.h"/>
</compounddef>
Expand Down
17 changes: 14 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,20 @@ module.exports = {
defaultOptions: {

directory: null, /** Location of the doxygen files **/
anchors: true, /** Generate anchors for internal links **/
output: 'api.md', /** Output file **/
groups: false, /** Output doxygen groups separately **/
noindex: false, /** Disable generation of the index. Does not work with `groups` option **/
anchors: true, /** Generate anchors for internal links **/
language: 'cpp', /** Programming language **/
templates: 'templates', /** Templates directory **/
output: 'api.md', /** Output file **/

filters: {
members: [
'define',
'enum',
// 'enumvalue',
'func',
// 'variable',
'public-attrib',
'public-func',
'protected-attrib',
Expand All @@ -39,7 +45,8 @@ module.exports = {
'class',
'struct',
'union',
'typedef'
'typedef',
// 'file'
]
}
},
Expand All @@ -63,6 +70,8 @@ module.exports = {

// Parse files
doxyparser.loadIndex(options, function (err, root) {
if (err)
throw err;

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

var compounds = root.toFilteredArray('compounds');
if (!options.noindex)
compounds.unshift(root); // insert root at top if index is enabled
var contents = templates.renderArray(compounds);
helpers.writeFile(options.output, contents);
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "moxygen",
"version": "0.6.1",
"version": "0.7.3",
"description": "Doxygen XML to Markdown documentation converter",
"main": "index.js",
"scripts": {
Expand Down
1 change: 1 addition & 0 deletions src/compound.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ Compound.prototype = {
compound.filtered.members = compound.filter(compound.members, 'section', filters.members, groupid);
compound.filtered.compounds = compound.filter(compound.compounds, 'kind', filters.compounds, groupid);
});
this.filtered.members = this.filter(this.members, 'section', filters.members, groupid);
this.filtered.compounds = this.filter(this.compounds, 'kind', filters.compounds, groupid);
},

Expand Down
Loading

0 comments on commit 6e9b894

Please sign in to comment.