Debian Codegraph @

doc/doxydown/README.md

raw
1 # Doxydown - documentation utility
2
3 ## Introduction
4
5 Doxydown is an utility to convert `doxygen`-like comments from the source code to markdown.
6 Unlike other documentation systems, `doxydown` is specifically designed to generate markdown output only.
7 At the moment, doxydown can work with C and lua comments and produce kramdown/pandoc or github
8 flavoured markdown. Doxydown produces output with anchors, links and table of content.
9 It also can highlight syntax for examples in the documentation.
10
11 ### Why markdown
12
13 Markdown is used by many contemporary engines and can be rendered to HTML using
14 advanced templates, styles and scripts. Markdown provides excellent formatting
15 capabilities while it doesn't require authors to be web designers to create
16 documentation. Markdown is rendered by [`github`](https://github.com) and
17 doxydown can generate documentation easily viewed directly inside github. Moreover,
18 doxydown supports pandoc style of markdown and that means that markdown output
19 can be converted to all formats supported by pandoc (html, pdf, latex,
20 man pages and many others).
21
22 ### Why not `other documentation generator`
23
24 Doxydown is extremely simple as it can output markdown only but it is very
25 convenient tool to generate nice markdown with all features required from the
26 documentation system. Doxydown uses input format that is very close to `doxygen`
27 that allows to re-use the existing documentation comments. Currently, doxydown
28 does not support many features but they could be easily added on demand.
29
30 ## Input format
31
32 Doxydown extracts documentation from the comments blocks. The start of block is indicated by
33
34 /***
35
36 in `C` or by
37
38 --[[[
39
40 in `lua`. The end of documentation block is the normal multiline comment ending
41 specific for the input language. Doxydown also strips an initial comment character,
42 therefore the following inputs are equal:
43
44 ~~~c
45 /***
46 * some text
47 * other text
48 *
49 */
50 ~~~
51 and
52
53 ~~~c
54 /***
55 some text
56 other text
57
58 */
59 ~~~
60
61 Note that doxydown preserves empty lines and all markdown elements.
62
63 ### Documentation blocks
64
65 Each documentation block describes either module or function/method. Modules are
66 logical compounds of functions and methods. The difference between method and
67 function is significant for languages with methods support (e.g. by `lua` via
68 metatables). To define method or function you can use the following:
69
70 /***
71 @function my_awesome_function(param1[, param2])
72 This function is awesome.
73 */
74
75 All text met in the current documentation block is used as function or method description.
76 You can also define parameters and return values for functions and methods:
77
78 @param {type} param1 mandatory param
79
80 Here, `{type}` is optional type description for a parameter, `param1` is parameter's name
81 and the rest of the string is parameter description. Currently, you cannot split
82 parameter description by newline character. In future versions of doxydown this might
83 be fixed.
84
85 You can specify return type of your function by using of `@return` tag:
86
87 @return {type} some cool result
88
89 This tag is similar to `@param` and has the same limitation regarding newlines.
90 You can also add some example code by using of `@example` tag:
91
92 @example
93 my_awesome_function('hello'); // returns 42
94
95 All text after `@example` tag and until documentation block end is used as an example
96 and is highlighted in markdown. Also you can switch the language of example by using
97 the extended `@example` tag:
98
99 @example lua
100
101 In this example, the code will be highlighted as `lua` code.
102
103 Modules descriptions uses the same conventions, but `@param` and `@return` are
104 meaningless for the modules. Function and methods blocks that follows some `@module`
105 block are automatically attached to that module.
106
107 Both modules and function can use links to other functions and methods by using of
108 `@see` tag:
109
110 @see my_awesome_function
111
112 This inserts a hyperlink to the specified function definition to the markdown.
113
114 ## Output format
115
116 Doxydown can generate github flavoured markdown and pandoc/kramdown compatible
117 markdown. The main difference is in how anchors are organized. In kramdown and
118 pandoc it is possible to specify an explicit id for each header, whilst in
119 GH flavoured markdown we can use only implicit anchors.
120
121 ### Examples
122
123 You can see an example of github flavoured markdown render at
124 [libucl github page](https://github.com/vstakhov/libucl/blob/master/doc/lua_api.md).
125 The same page bu rendered by kramdown engine in `jekyll` platform can be
126 accessed by [this address](https://rspamd.com/doc/lua/ucl.html).
127
128 ## Program invocation
129
130 doxydown [-hg] [-l language] < input_source > markdown.md
131
132 * `-h`: help message
133 * `-e`: sets default example language (default: lua)
134 * `-l`: sets input language (default: c)
135 * `-g`: use github flavoured markdown (default: kramdown/pandoc)
136
137 ## License
138
139 Doxydown is published by terms of `MIT` license.