ServiceStack使用 c# 属性标记 Web 服务的休息路径。
例如
[RestService("/hello1")]
[RestService("/hello2")]
public class Hello
我想让 Doxygen 在 Hello 类的 doxygen 输出中包含 RestService 属性的值。如果输出文档中包含带括号的整行,我并不太关心漂亮的格式。
有什么建议吗?
快速而肮脏的技巧比编写 Doxygen 扩展更可取 ;)
干杯
泰美克
====编辑
doxygen 用户答案的 Python 版本(因此很容易在 Windows 上运行)是:
#!/usr/bin/env python
import sys
import re
if (len(sys.argv) < 2):
print "No input file"
else:
f = open(sys.argv[1])
line = f.readline()
while line:
re1 = re.compile("\[RestService\(\"(.*)\",.*\"(.*)\"\)]")
re1.search(line)
sys.stdout.write(re1.sub(r"/** \\b RestService: \2 \1\\n */\n", line))
#sys.stdout.write(line)
line = f.readline()
f.close()
并且 DOXYFILE 将具有:
INPUT_FILTER = "doxygenFilter.py"
最佳答案
你可以制作一个输入过滤器来转换一行
[RestService("/hello1")]
到
/** \b RestService: "/hello1"\n */
例如,将以下 perl 魔法放入名为 filter.pl
的文件中:
open(F, "<", $ARGV[0]);
while(<F>) { /^\s*\[RestService\((.*)\)\]\s*$/ ?
print "/** \\b RestService: $1\\n */\n" : print $_; }
并将其与 Doxyfile 中的 INPUT_FILTER
标签一起使用:
INPUT_FILTER = "perl filter.pl"
关于c# - Doxygen 并将属性值添加到输出文档,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9290340/