File: c2luadoc.sh

package info (click to toggle)
naev 0.8.2-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 386,084 kB
  • sloc: ansic: 93,149; xml: 87,292; python: 2,347; sh: 904; makefile: 654; lisp: 162; awk: 4
file content (57 lines) | stat: -rwxr-xr-x 3,757 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/sh

# Convert Doxygen comments to Luadoc comments
# CAUTION: We need to support BSD/macOS sed in addition to GNU sed.
#          If you aren't suffering, you've probably introduced a bug. :P
sed -n                                                                         \
 -e '1i\
-- This file was generated automatically from C sources to feed LDoc.'         \
`# Convert Doxygen /** to Luadoc ---`                                          \
 -e 's|^ */\*\* *$|---|p'                                                      \
`# Convert special tags to Lua expressions.`                                   \
`# Lines after @luafunc & @luamod will be ignored by Luadoc`                   \
`# Doxygen comments that do not contain any of these tags have no impact on`   \
`# the Luadoc output.`                                                         \
`# Rename some tags:`                                                          \
 -e 's|^ *\* *@luafunc|-- @function|p'                                         \
 -e 's|^ *\* *@brief|--|p'                                                     \
 -e 's|^ *\* *@luasee|-- @see|p'                                               \
 -e 's|^ *\* *@luaparam|-- @param|p'                                           \
 -e 's|^ *\* *@luatparam|-- @tparam|p'                                         \
 -e 's|^ *\* *@luareturn|-- @return|p' `#we accept both @luareturn & @return`  \
 -e 's|^ *\* *@luatreturn|-- @treturn|p'                                       \
 -e 's|^ *\* *@luamod|-- @module|p'                                            \
 -e 's|^ *\* *@luatype|-- @type|p'                                             \
 -e 's|^ *\* *@luaset|-- @set|p'                                               \
`# Keep tags Luadoc understands:`                                              \
`#   s|^ *\* *@param|-- @param|p # use luaparam; param is for C arguments`     \
`#   s|^ *\* *@see|-- @see|p # use luasee`                                     \
`#   s|^ *\* *@return|-- @return|p # use luareturn`                            \
 -e 's|^ *\* *@usage|-- @usage|p'                                              \
 -e 's|^ *\* *@description|-- @description|p'                                  \
 -e 's|^ *\* *@name|-- @name|p'                                                \
 -e 's|^ *\* *@class|-- @class|p'                                              \
 -e 's|^ *\* *@field|-- @field|p'                                              \
 -e 's|^ *\* *@release|-- @release|p'                                          \
`# Custom tags:`                                                               \
 -e 's|^ *\* *@code|-- <pre>|p'                                                \
 -e 's|^ *\* *@endcode|-- </pre>|p'                                            \
`# Remove other tags:`                                                         \
 -e '\|^ *\* *@.*|d'                                                           \
`# Insert newline between comments, replace */ with \n:`                       \
 -e '\|^ *\*/|c\
'                                                                              \
`# Keep other comments, replace * with --`                                     \
 -e 's|^ *\*|--|p'                                                             \
`# Keep blank lines`                                                           \
 -e 's|^\s*$||p'                                                               \
`# Delete everything else, just in case:`                                      \
 -e 'd'                                                                        \
   $1 | awk '
# Skips all comment blocks without an @ tag
   BEGIN {
      RS="\n\n"
   }
   /@/ {
      print $0, "\n"
   }' > $2