doxygen 换行较长的 c++模板类型
我有一个编译时递归类型,看起来有点像这样:
template <typename DataType, typename LeftNode, typename RightNode>
struct fixed_tree{
fixed_tree(const DataType& data, const LeftNode& left, const RightNode& right) : data_(data),left_(left),right_(right){}
DataType data_;
LeftNode left_;
RightNode right_;
};
该类对各种叶节点有一些专门化,其中左/右节点为空,但这并不重要。
然后,这个递归类作为参数传递给一个函数,创建一个有点长的类型名。
namespace some_namespace{
void some_function(int some_param0, int some_param1, fixed_tree<std::string,
fixed_tree<int,
fixed_tree<float, void, void >,
fixed_tree<double, void, void >
>,
fixed_tree<int,
fixed_tree<double,void,
fixed_tree<char,
fixed_tree<int, void,void>,
fixed_tree<int, void,void>
> >,
void
>
> somewhat_lengthy_type
);
当我通过 Doxygen 运行此函数时,函数文档严重溢出。
我的问题是:有没有办法在 doxygen 注释块之外提示/强制换行,以便查看文档与源代码中的内容类似。
我对以下解决方案不太感兴趣:
使用 typedef。尽管该示例不具有此特征,但实际类型形成了一种不言自明的语法,实际上有助于理解接口的功能。
自定义 CSS。最好避免弄乱不是 doxygen 标签的东西。
I've got a compile-time recursive type that looks somewhat like this:
template <typename DataType, typename LeftNode, typename RightNode>
struct fixed_tree{
fixed_tree(const DataType& data, const LeftNode& left, const RightNode& right) : data_(data),left_(left),right_(right){}
DataType data_;
LeftNode left_;
RightNode right_;
};
That class has some specializations for various leaf nodes where Left/Right Node is void, but that's not important.
This recursive class is then passed as an argument to a function creating a somewhat lengthy typename.
namespace some_namespace{
void some_function(int some_param0, int some_param1, fixed_tree<std::string,
fixed_tree<int,
fixed_tree<float, void, void >,
fixed_tree<double, void, void >
>,
fixed_tree<int,
fixed_tree<double,void,
fixed_tree<char,
fixed_tree<int, void,void>,
fixed_tree<int, void,void>
> >,
void
>
> somewhat_lengthy_type
);
When I run this through Doxygen the function documentation overflows the line quite badly.
My question is: Is there a way to hint/force line breaks outside the doxygen comment blocks, so that the look in the documentation resembles what's in the source.
I'm not very interested in the following solutions:
Using a typedef. Even though the example doesn't share this trait, the actual type forms a self-explanatory syntax that actually helps to make sense what the interface does.
Custom CSS. Would be nice to avoid messing around with something that's not doxygen tags.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
IMO,这绝对是你应该输入的内容。在这么长的时间里包含整个类型是不好的做法。这样做可以解决 doxygen 问题,并制作一种更简单的类型(我可以很容易地看到当前类型中的拼写错误)。如果那棵树很深,你也应该通过引用传递。
在 doxygen 中,您可以使用更具体的标签,例如:
记录特定的代码位。然而,这些通常会添加到自动生成的文档中,我不确定您是否可以完全覆盖这些文档。
很简单,它在您的代码/文档中看起来很丑陋这一事实应该是一个巨大的提示,它很丑陋并且应该重构。
IMO that's definitely something you should typedef out. Including the entire type when so long is poor practice. Doing so would solve the doxygen issue, as well as making a much simpler type (I can see typos coming from the current one quite easily). If that tree is deep, you should also pass by reference.
In doxygen, you can use more specific tags like:
to document a particular bit of code. These usually add on to the autogenerated docs, however, and I'm not sure if you can entirely overwrite those.
Quite simply, the fact it looks ugly in your code/docs should be a huge tipoff that it is ugly and should be refactored.