|
1 | 1 | # Moxygen |
2 | 2 |
|
3 | | -Moxygen is a Doxygen XML to Markdown converter for C++ developers who want a minimal and beautiful solution for documentating their projects. |
| 3 | +[](https://github.com/sourcey/moxygen/actions/workflows/ci.yml) |
| 4 | +[](https://www.npmjs.com/package/moxygen) |
| 5 | +[](https://nodejs.org) |
| 6 | +[](https://github.com/sourcey/moxygen/blob/master/LICENCE) |
4 | 7 |
|
5 | | -Moxygen is currently used in conjunction with GitBook to generate the API documentation for [LibSourcey](http://sourcey.com/libsourcey/). |
| 8 | +Doxygen XML to Markdown converter for C++ and Java developers who want minimal, beautiful API documentation. |
6 | 9 |
|
7 | 10 | ## Features |
8 | 11 |
|
9 | | -* **Multi page output**: Output single or multiple files |
10 | | -* **Internal linking**: Anchors in comments and function definitions are supported |
11 | | -* **Markdown comments**: Markdown in Doxygen comments are rendered |
12 | | -* **Doxygen groups**: Doxygen [grouping](http://www.doxygen.nl/manual/grouping.html) is supported for more organised documentation |
13 | | -* **Custom templates**: Modify the core Markdown templates to add your own flavour |
14 | | -* **Optional index**: Optionally render a top level index |
| 12 | +- **Multi-language** - C++ and Java supported out of the box |
| 13 | +- **Multi-page output** - single file, per-group, per-class, or per-page |
| 14 | +- **Internal linking** - anchors in comments and function definitions |
| 15 | +- **Markdown comments** - Markdown in Doxygen comments is rendered |
| 16 | +- **Doxygen groups** - [grouping](http://www.doxygen.nl/manual/grouping.html) support for organised docs |
| 17 | +- **Custom templates** - modify the Handlebars templates to suit your needs |
| 18 | +- **Optional index** - optionally render a top-level index |
15 | 19 |
|
16 | | -## Usage |
| 20 | +## Install |
17 | 21 |
|
18 | | -1. Add `GENERATE_XML=YES` to your `Doxyfile` first. |
19 | | -2. Run `doxygen` to generate the XML documentation. |
20 | | -3. Install `moxygen` like so: `npm install moxygen -g`. |
21 | | -4. Run `moxygen` providing the folder location of the XML documentation as the first argument ie. `{OUTPUT_DIRECTORY}/xml`. |
22 | | - ``` |
23 | | - Usage: moxygen [options] <doxygen XML directory> |
| 22 | +``` |
| 23 | +npm install moxygen -g |
| 24 | +``` |
24 | 25 |
|
25 | | - Options: |
| 26 | +Requires Node.js 18+. |
26 | 27 |
|
27 | | - -V, --version output the version number |
28 | | - -o, --output <file> output file, must contain "%s" when using `groups` or `classes` |
29 | | - -g, --groups output doxygen groups into separate files |
30 | | - -c, --classes output doxygen classes into separate files |
31 | | - -p, --pages output doxygen pages into separate files |
32 | | - -n, --noindex disable generation of the index, ignored with `groups` or `classes` |
33 | | - -a, --anchors add anchors to internal links |
34 | | - -H, --html-anchors add html anchors to internal links |
35 | | - -l, --language <lang> programming language |
36 | | - -t, --templates <dir> custom templates directory |
37 | | - -L, --logfile [file] output log messages to file |
38 | | - -q, --quiet quiet mode |
39 | | - -h, --help output usage information |
40 | | - ``` |
| 28 | +## Usage |
41 | 29 |
|
42 | | -## Multi-page Output |
| 30 | +1. Add `GENERATE_XML=YES` to your `Doxyfile` |
| 31 | +2. Run `doxygen` to generate the XML documentation |
| 32 | +3. Run `moxygen` pointing to the XML output directory |
43 | 33 |
|
44 | | -Moxygen supports the doxygen [groups](http://www.doxygen.nl/manual/grouping.html#modules) syntax for generating multi page documentation. Every [\defgroup](http://www.doxygen.nl/manual/commands.html#cmddefgroup) in your source code will be parsed and output into a separate markdown file, with internal reference updated accordingly. |
| 34 | +``` |
| 35 | +moxygen [options] <doxygen XML directory> |
| 36 | +
|
| 37 | +Options: |
| 38 | + -V, --version output the version number |
| 39 | + -o, --output <file> output file, must contain "%s" when using groups or classes |
| 40 | + -g, --groups output doxygen groups into separate files |
| 41 | + -c, --classes output doxygen classes into separate files |
| 42 | + -p, --pages output doxygen pages into separate files |
| 43 | + -n, --noindex disable generation of the index |
| 44 | + -a, --anchors add anchors to internal links |
| 45 | + -H, --html-anchors add HTML anchors to internal links |
| 46 | + -l, --language <lang> programming language (default: cpp) |
| 47 | + -t, --templates <dir> custom templates directory |
| 48 | + -L, --logfile [file] output log messages to file (default: moxygen.log) |
| 49 | + -q, --quiet quiet mode |
| 50 | + -h, --help display help |
| 51 | +``` |
45 | 52 |
|
46 | | -Example: |
| 53 | +## Examples |
47 | 54 |
|
| 55 | +Single file output: |
48 | 56 | ``` |
49 | | -moxygen --anchors --groups --output api-%s.md /path/to/doxygen/xml |
| 57 | +moxygen --anchors /path/to/doxygen/xml |
50 | 58 | ``` |
51 | 59 |
|
52 | | -## Example |
| 60 | +Multi-file grouped output: |
| 61 | +``` |
| 62 | +moxygen --anchors --groups --output api-%s.md /path/to/doxygen/xml |
| 63 | +``` |
53 | 64 |
|
54 | | -To get a feel for how Moxygen works you can play with the example which is located in the [example](/example) folder. The example contains: |
| 65 | +Per-class files: |
| 66 | +``` |
| 67 | +moxygen --classes --output api-%s.md /path/to/doxygen/xml |
| 68 | +``` |
55 | 69 |
|
56 | | -* Documented C++ example code |
57 | | -* A `Doxyfile` file (for doxygen 1.8.13) |
58 | | -* Pre-generated XML output in [example/xml](/example/xml) |
59 | | -* Pre-generated output Markdown files in [example/doc](/example/doc) |
| 70 | +Java project: |
| 71 | +``` |
| 72 | +moxygen --language java --anchors /path/to/doxygen/xml |
| 73 | +``` |
60 | 74 |
|
61 | | -To fully build the example, follow these steps (once you've installed `doxygen`. See **Development & Contribution**, below): |
| 75 | +## Custom Templates |
62 | 76 |
|
63 | | -1. Rebuild the XML: run `doxygen` from within the example folder. |
64 | | -2. Rebuild the Moxygen output: from within this directory, |
| 77 | +Moxygen uses Handlebars templates for output. The default modern templates produce clean Markdown with code-block signatures and parameter tables. |
65 | 78 |
|
| 79 | +To use the classic (pre-1.0) template style: |
66 | 80 | ``` |
67 | | -node bin/moxygen.js --groups --pages --anchors --output=example/doc/api-%s.md example/xml |
| 81 | +moxygen --templates ./templates/classic /path/to/xml |
| 82 | +``` |
| 83 | + |
| 84 | +To create your own templates, copy the `templates/cpp/` directory and modify. Templates receive the full parsed compound data including structured parameter info, inheritance, and more. |
| 85 | + |
| 86 | +## Programmatic API |
| 87 | + |
| 88 | +```typescript |
| 89 | +import { run } from 'moxygen'; |
| 90 | + |
| 91 | +await run({ |
| 92 | + directory: '/path/to/doxygen/xml', |
| 93 | + output: 'api.md', |
| 94 | + anchors: true, |
| 95 | +}); |
68 | 96 | ``` |
69 | 97 |
|
70 | | -## Development & Contribution |
| 98 | +## Development |
71 | 99 |
|
72 | | -You can develop this project as you would any other Node project: |
| 100 | +```bash |
| 101 | +npm install |
| 102 | +npm run build |
| 103 | +npm test |
| 104 | +``` |
73 | 105 |
|
74 | | -1. Clone this repo. |
75 | | -2. `npm install` from this directory. |
| 106 | +To test against the example: |
| 107 | +```bash |
| 108 | +npm run example |
| 109 | +``` |
76 | 110 |
|
77 | | -This project is tested through integration, by building the `example/`. To quickly test this project: |
| 111 | +## Licence |
78 | 112 |
|
79 | | -1. Install `doxygen` (`brew install doxygen`, `choco install doxygen`, for example). Only must be done once per computer. |
80 | | -2. `npm test` from this directory. This will run Doxygen on the `example/` and build the output. |
| 113 | +MIT |
0 commit comments