Doxygen and add a value of an attribute to the output documentation

倖福魔咒の 提交于 2019-12-01 01:00:40

问题


ServiceStack marks rest paths for web services using c# attributes.

For example

[RestService("/hello1")]
[RestService("/hello2")]
public class Hello

I would like to make Doxygen include values of the RestService attribute in the doxygen output for the Hello class. I'm not concerned too much with pretty formattin if the full line with brackets is included in the output document.

Any suggestions?

A quick and dirty trick would be a preferable to writing a Doxygen extension ;)

Cheers

Tymek

====EDIT

The Python version (so will work on Windows easily) of doxygen user's answer would be:

#!/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()

and the DOXYFILE would have:

INPUT_FILTER           = "doxygenFilter.py"

回答1:


You could make an input filter that converts a line with

[RestService("/hello1")]

to

/** \b RestService: "/hello1"\n */

like for instance by putting following piece of perl magic in a file called filter.pl:

open(F, "<", $ARGV[0]);
while(<F>) { /^\s*\[RestService\((.*)\)\]\s*$/ ? 
             print "/** \\b RestService: $1\\n */\n" : print $_; }

and use that with the INPUT_FILTER tag in the Doxyfile:

INPUT_FILTER           = "perl filter.pl"


来源:https://stackoverflow.com/questions/9290340/doxygen-and-add-a-value-of-an-attribute-to-the-output-documentation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!