为 C# 代码创建 html 文档
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15316381/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Create html documentation for C# code
提问by jaho
I'm currently working on a C# project and VisualAssist generates these fancy /// <summary></summary>
comments for me and I've been using them do document my code.
我目前正在处理一个 C# 项目,VisualAssist/// <summary></summary>
为我生成这些花哨的注释,我一直在使用它们来记录我的代码。
I assume there must be a way to use these comments to create HTML documentation like those done by Doxygen or Javadoc. How do I do that?
我认为必须有一种方法可以使用这些注释来创建 HTML 文档,就像 Doxygen 或 Javadoc 所做的那样。我怎么做?
采纳答案by Jason Williams
Doxygenor Sandcastle help file builderare the primary tools that will extract XML documentation into HTML (and other forms) of external documentation.
Doxygen或Sandcastle 帮助文件构建器是将 XML 文档提取为外部文档的 HTML(和其他形式)的主要工具。
Note that you can combine these documentation exporters with documentation generators - as you've discovered, Resharper has some rudimentary helpers, but there are also much more advanced tools to do this specific task, such as GhostDoc(for C#/VB code with XML documentation) or my addin Atomineer Pro Documentation(for C#, C++/CLI, C++, C, VB, Java, JavaScript, TypeScript, JScript, PHP, Unrealscript code containing XML, Doxygen, JavaDoc or Qt documentation).
请注意,您可以将这些文档导出器与文档生成器结合使用 - 正如您所发现的,Resharper 有一些基本的帮助器,但也有更高级的工具来执行此特定任务,例如GhostDoc(用于 C#/VB 代码与 XML 文档) 或我的插件Atomineer Pro 文档(用于 C#、C++/CLI、C++、C、VB、Java、JavaScript、TypeScript、JScript、PHP、包含 XML、Doxygen、JavaDoc 或 Qt 文档的 Unrealscript 代码)。
回答by Kevin Lindsay
This page might interest you: http://msdn.microsoft.com/en-us/magazine/dd722812.aspx
您可能会对此页面感兴趣:http: //msdn.microsoft.com/en-us/magazine/dd722812.aspx
You can generate the XML documentation file using either the command-line compiler or through the Visual Studio interface. If you are compiling with the command-line compiler, use options /doc or /doc+. That will generate an XML file by the same name and in the same path as the assembly. To specify a different file name, use /doc:file.
If you are using the Visual Studio interface, there's a setting that controls whether the XML documentation file is generated. To set it, double-click My Project in Solution Explorer to open the Project Designer. Navigate to the Compile tab. Find "Generate XML documentation file" at the bottom of the window, and make sure it is checked. By default this setting is on. It generates an XML file using the same name and path as the assembly.
您可以使用命令行编译器或通过 Visual Studio 界面生成 XML 文档文件。如果您使用命令行编译器进行编译,请使用选项 /doc 或 /doc+。这将生成一个与程序集同名且路径相同的 XML 文件。要指定不同的文件名,请使用 /doc:file。
如果您使用的是 Visual Studio 界面,则有一个设置可控制是否生成 XML 文档文件。要设置它,请在解决方案资源管理器中双击我的项目以打开项目设计器。导航到编译选项卡。找到窗口底部的“生成 XML 文档文件”,并确保选中它。默认情况下,此设置处于开启状态。它使用与程序集相同的名称和路径生成一个 XML 文件。
回答by George Hahn
The above method for Visual Studio didn't seem to apply to Visual Studio 2013, but I was able to find the described checkbox using the Project Menu and selecting my project (probably the last item on the submenu) to get to the dialog with the checkbox (on the Build tab).
Visual Studio 的上述方法似乎不适用于 Visual Studio 2013,但我能够使用项目菜单找到描述的复选框并选择我的项目(可能是子菜单上的最后一项)以进入对话框复选框(在构建选项卡上)。
回答by mode777
In 2017, the thing closest to Javadoc would probably DocFxwhich was developed by Microsoft and comes as a Commmand-Line-Tool as well as a VS2017 plugin.
在 2017 年,最接近 Javadoc 的可能是DocFx,它由微软开发,作为命令行工具和 VS2017 插件出现。
It's still a little rough around the edges but it looks promising.
它的边缘仍然有点粗糙,但看起来很有希望。
Another alternative would be Wyamwhich has a documentation recipe suitable for net aplications. Look at the cake documentationfor an example.