Add parameter direction to doxygen pydoc output
For doxygen comments that specify parameter direction (i.e., \param[in], \param[out], and \param[in,out]), the direction is appended to the type definition in the generated Python documentation. Updated expected python output for doxygen test case.
This commit is contained in:
parent
eb11c025c7
commit
36f0e9919f
2 changed files with 31 additions and 4 deletions
|
|
@ -210,11 +210,11 @@ Maybe even multiline
|
|||
|
||||
:type a: int
|
||||
:param a: the first param
|
||||
:type b: int
|
||||
:type b: int, in
|
||||
:param b: parameter with intent(in)
|
||||
:type c: int
|
||||
:type c: int, out
|
||||
:param c: parameter with intent(out)
|
||||
:type d: int
|
||||
:type d: int, in/out
|
||||
:param d: parameter with intent(in,out)""")
|
||||
|
||||
comment_verifier.check(inspect.getdoc(doxygen_translate_all_tags.func08),
|
||||
|
|
|
|||
|
|
@ -184,6 +184,21 @@ static string padCodeAndVerbatimBlocks(const string &docString) {
|
|||
return result;
|
||||
}
|
||||
|
||||
// Helper function to extract the option value from a command,
|
||||
// e.g. param[in] -> in
|
||||
static std::string getCommandOption(const std::string &command) {
|
||||
string option;
|
||||
|
||||
size_t opt_begin, opt_end;
|
||||
opt_begin = command.find('[');
|
||||
opt_end = command.find(']');
|
||||
if (opt_begin != string::npos && opt_end != string::npos)
|
||||
option = command.substr(opt_begin+1, opt_end-opt_begin-1);
|
||||
|
||||
return option;
|
||||
}
|
||||
|
||||
|
||||
/* static */
|
||||
PyDocConverter::TagHandlersMap::mapped_type PyDocConverter::make_handler(tagHandler handler) {
|
||||
return make_pair(handler, std::string());
|
||||
|
|
@ -636,8 +651,19 @@ void PyDocConverter::handleTagParam(DoxygenEntity &tag, std::string &translatedC
|
|||
const std::string ¶mName = paramNameEntity.data;
|
||||
|
||||
const std::string paramType = getParamType(paramName);
|
||||
|
||||
// Get command option, e.g. "in", "out", or "in,out"
|
||||
string commandOpt = getCommandOption(tag.typeOfEntity);
|
||||
if (commandOpt == "in,out") commandOpt = "in/out";
|
||||
|
||||
// If provided, append the parameter direction to the type
|
||||
// information via a suffix:
|
||||
std::string suffix;
|
||||
if (commandOpt.size() > 0)
|
||||
suffix = ", " + commandOpt;
|
||||
|
||||
if (!paramType.empty()) {
|
||||
translatedComment += ":type " + paramName + ": " + paramType + "\n";
|
||||
translatedComment += ":type " + paramName + ": " + paramType + suffix + "\n";
|
||||
translatedComment += indent.getFirstLineIndent();
|
||||
}
|
||||
|
||||
|
|
@ -909,3 +935,4 @@ String *PyDocConverter::makeDocumentation(Node *n) {
|
|||
|
||||
return NewString(pyDocString.c_str());
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue