C++ 的注释弹出窗口(Visual Studio),类似于 Eclipse 和 Javadoc

发布于 2024-12-25 08:45:34 字数 904 浏览 6 评论 0原文

在大学期间,我学会了 Java 编程,这是我在 Eclipse 中完成的。我喜欢 Eclipse 中关于如何在窗口中弹出 Javadoc 注释的功能。目前我正在编写 C++ 程序,我真的开始怀念这个功能。

这就是为什么我要问:是否有一个插件可以达到相同的结果。目前我正在使用 Visual Studio Express 2010 进行 c++ 编程,除了在自动完成窗口中显示函数接口之外,没有类似的东西。我想阅读更多信息,例如阅读前置条件和后置条件,无论是现有库中的代码(如果存在)还是仅适用于我自己编写的代码。

现在我知道了 Doxygen,但它并不是我真正想要的。这是一个足够好的回退机制,但我真的很喜欢从我编写代码的同一个窗口中轻松使用它。Visual

Studio 是否存在类似的东西?或者我可以开始使用 C++ 版本的 Eclipse 并在那里运行 Javadoc 生成器(我实际上还没有尝试过这个!)以获得那些不错的弹出评论?

编辑: 我一直在尝试让 XML 样式注释正常工作,但是类似:

/// <summary>This constructor takes parameters to set the 
/// members of the Cow class.
/// <param name="ho">Hobby as string of the cow.</param>
/// <param name="wt">Weight of the cow as a double.</param>
/// </summary>
Cow(const char * nm, double wt);

仍然只在弹出窗口中给出字符串“Cow(const char * nm, double wt)”。使用 \doc 选项构建,我确实生成了一个 .xml 文件(在我的调试文件夹中)。

In my years at college I've learned to program Java, which I did in Eclipse. I loved the feature in Eclipse on how Javadoc comments were able to pop-up in a window. At the moment I'm programming C++ and I'm really starting to miss this feature.

That's why I'm asking: is there a plug-in of something that acchieves the same result. Currently I am programming c++ with Visual Studio Express 2010, that does not have anything like this except for showing a function interface in the auto completion window. I would like to read more info such as reading up on pre- and postconditions for example, either for code from existing libraries (if they exist) or otherwise only for code I wrote myself.

Now I know of Doxygen, but that it not really what I'm looking for. It is a good enough fall back mechanism, but I really like to have it readily available from the same window I'm writing my code in.

Does something like this exist for Visual Studio? Or can I start using the C++ version of Eclipse and run the Javadoc generator there (I actually haven't tried this!) to get those nice pop-up comments?

EDIT:
I've been trying to get XML style comments working, but something like:

/// <summary>This constructor takes parameters to set the 
/// members of the Cow class.
/// <param name="ho">Hobby as string of the cow.</param>
/// <param name="wt">Weight of the cow as a double.</param>
/// </summary>
Cow(const char * nm, double wt);

still only gives me the string "Cow(const char * nm, double wt)" in the pop-up window. Built with the \doc option, I do have a .xml file generated (in my Debug folder).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

临走之时 2025-01-01 08:45:34

在 C# 中,你可以编写

///

它会生成一个 XML 风格的注释,例如:

/// <summary>
///
/// </summary>
/// <param name="parameter"> </param>
/// <returns> </returns>

你可以让 Visual Studio 生成一个 XML 文件,可以对其进行处理以获取 javadoc 之类的内容。我 100% 确定它适用于 C#,但 C++ 似乎使用了不同的风格。如果我进入项目选项>配置选项> XML 文档生成器 >常规,并将“验证 IntelliSense”设置为“是”,您可以在 .h 文件中添加注释:

class Test {
    public:
        // The constructor
        Test(void);
        // The destructor
        ~Test(void);
        // The function description
        void Function();
};

如果我转到我的 main.cpp,并输入以下内容:

Test * test = new Test();
test->

一旦我点击“>”,就会弹出一个框带有函数列表(本例中的析构函数和函数)。例如,如果我选择“功能”,则会弹出一个工具提示,其中显示“功能描述”:

void Test::Function();

The function description
File: test.h

我不确定是否有任何插件,但希望我在这里对您有所帮助!

In C# you can write

///

And it will generate a XML style comment like:

/// <summary>
///
/// </summary>
/// <param name="parameter"> </param>
/// <returns> </returns>

You can let Visual Studio generate an XML file, which can be processed to get something like javadoc. I'm 100% sure it works on C#, but it seems that C++ uses a different style. If I go to project options > Configuration Options > XML Document Generator > General, and set the "Validate IntelliSense" to Yes, you can place comments in your .h file:

class Test {
    public:
        // The constructor
        Test(void);
        // The destructor
        ~Test(void);
        // The function description
        void Function();
};

If I go to my main.cpp, and type this:

Test * test = new Test();
test->

As soon as I hit the '>', a box pops up with a list of functions (destructor and the function in this case). If I select Function for example, a tooltip pops up with "The function description":

void Test::Function();

The function description
File: test.h

I'm not sure if there are any plugins, but I hope I helped you a bit here!

清君侧 2025-01-01 08:45:34

如果您有 CodeRush/Refactor,您可以尝试 CR_Documenter 插件(使用 VS Extension Manager)。它提供了一个带有此类文档的新可停靠窗口。

我同意你的观点 - Eclipse 更适合查看文档。

If you have CodeRush/Refactor you can try the CR_Documenter plugin (use VS Extension Manager). It provides a new dockable window with such documentation.

I am with you - Eclipse is so much better for viewing documentation.

白馒头 2025-01-01 08:45:34

使用 SandCastle 与内置帮助 (F1) 集成。它不如 Eclipse 中的内联帮助那么好,但您可以将鼠标悬停在类型上,按 F1,然后就可以了。

为此,请安装 Sandcastle 和 Sandcastle 帮助文件生成器。然后在您的 Sandcastle 帮助文件生成器项目中,确保选中 MSHelpViewer 框。这将生成文档和脚本,您可以运行该脚本将自定义文档集成到 F1 帮助中。

Use SandCastle to integrate with the builtin help (F1). Its not as good as inline help like you get in Eclipse, but you can hover over a type, press F1 and then you are there.

To do this, install Sandcastle and Sandcastle Help File Builder. Then in your Sandcastle Help File Builder project, make sure to tick the box for MSHelpViewer. This will generate documentation and a script you can run to integrate your custom documentation into the F1 help.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文