Skip to content

Commit 956b3f9

Browse files
TonyWelteAnthony Welte
andauthored
Add support for more doxygen directive (#9)
* Changed the math format to use the reST math role * Add support for warnings * Added deprecated, since and todo directives * Fixed \since directive Co-authored-by: Anthony Welte <anthony.welte@hds.utc.fr>
1 parent adc8312 commit 956b3f9

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

pybind11_mkdoc/mkdoc_lib.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,23 @@ def process_comment(comment):
147147

148148
s = re.sub(r'[\\@]code\s?(.*?)\s?[\\@]endcode',
149149
r"```\n\1\n```\n", s, flags=re.DOTALL)
150+
s = re.sub(r'[\\@]warning\s?(.*?)\s?\n\n',
151+
r'$.. warning::\n\n\1\n\n', s, flags=re.DOTALL)
152+
# Deprecated expects a version number for reST and not for Doxygen. Here the first word of the
153+
# doxygen directives is assumed to correspond to the version number
154+
s = re.sub(r'[\\@]deprecated\s(.*?)\s?(.*?)\s?\n\n',
155+
r'$.. deprecated:: \1\n\n\2\n\n', s, flags=re.DOTALL)
156+
s = re.sub(r'[\\@]since\s?(.*?)\s?\n\n',
157+
r'.. versionadded:: \1\n\n', s, flags=re.DOTALL)
158+
s = re.sub(r'[\\@]todo\s?(.*?)\s?\n\n',
159+
r'$.. todo::\n\n\1\n\n', s, flags=re.DOTALL)
150160

151161
# HTML/TeX tags
152162
s = re.sub(r'<tt>(.*?)</tt>', r'``\1``', s, flags=re.DOTALL)
153163
s = re.sub(r'<pre>(.*?)</pre>', r"```\n\1\n```\n", s, flags=re.DOTALL)
154164
s = re.sub(r'<em>(.*?)</em>', r'*\1*', s, flags=re.DOTALL)
155165
s = re.sub(r'<b>(.*?)</b>', r'**\1**', s, flags=re.DOTALL)
156-
s = re.sub(r'[\\@]f\$(.*?)[\\@]f\$', r'$\1$', s, flags=re.DOTALL)
166+
s = re.sub(r'[\\@]f\$(.*?)[\\@]f\$', r':math:`\1`', s, flags=re.DOTALL)
157167
s = re.sub(r'<li>', r'\n\n* ', s)
158168
s = re.sub(r'</?ul>', r'', s)
159169
s = re.sub(r'</li>', r'\n\n', s)

0 commit comments

Comments
 (0)