有没有办法生成 Javascript API 文档,比如 Google Closure Library API 文档?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3818875/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-25 02:22:18  来源:igfitidea点击:

Is there a way to generate Javascript API documentation like the Google Closure Library API Documentation?

javascriptdocumentation-generationgoogle-closuregoogle-closure-library

提问by Homer6

I'm trying to find a tool that generates HTML documentation for my Javascript source code.

我正在尝试找到一种为我的 Javascript 源代码生成 HTML 文档的工具。

Does anyone know if the tool that Google uses to generate the interface at the following URLs is open source? Would I be able to generate similar output?

有谁知道谷歌用于在以下网址生成界面的工具是否开源?我能产生类似的输出吗?

http://closure-library.googlecode.com/svn/docs/class_goog_proto2_Serializer.html

http://closure-library.googlecode.com/svn/docs/class_goog_proto2_Serializer.html

http://closure-library.googlecode.com/svn/docs/namespace_goog_date.html

http://closure-library.googlecode.com/svn/docs/namespace_goog_date.html

http://closure-library.googlecode.com/svn/docs/namespace_goog_events.html

http://closure-library.googlecode.com/svn/docs/namespace_goog_events.html

http://closure-library.googlecode.com/svn/docs/class_goog_gears_Database.html

http://closure-library.googlecode.com/svn/docs/class_goog_gears_Database.html

http://closure-library.googlecode.com/svn/docs/class_goog_ui_DatePicker.html

http://closure-library.googlecode.com/svn/docs/class_goog_ui_DatePicker.html

I'm aware of http://code.google.com/p/jsdoc-toolkit/

我知道http://code.google.com/p/jsdoc-toolkit/

But I'd like to know if the specific generator that Google uses is available for me to use for my own source (which is going to be open source, if that matters).

但我想知道 Google 使用的特定生成器是否可供我用于我自己的源代码(如果重要的话,它将是开源的)。

Thanks in advance...

提前致谢...

采纳答案by haylem

Google Closure + JSDoc

谷歌关闭 + JSDoc

As you mentioned yourself in your comment, they build on JSDoc Toolkitto add special annotations used by the Closure Compiler for type-checking and other things, but this means you can also just use JSDoc on top of closure code to generate your documentation. Generating an output with the desired look and feel is then only a matter of writing your own template and stylesheet.

正如您在评论中提到的,它们建立在JSDoc Toolkit之上,以添加闭包编译器用于类型检查和其他事情的特殊注释,但这意味着您也可以仅在闭包代码之上使用 JSDoc 来生成您的文档。生成具有所需外观的输出只需编写您自己的模板和样式表。

The Google Closure Tools are all open source except for some bits that aren't disclosed at the moment. In any case, you can have a look at the documentation and source code and see what they use to generate Javadocs.

除了一些目前没有公开的部分之外,Google Closure Tools 都是开源的。在任何情况下,您都可以查看文档和源代码,并了解它们用于生成 Javadoc 的内容。

ExtJS + Ext-Doc

ExtJS + Ext-Doc

Another one you could possibly have a look at for inspiration and to see how they do it is the online doc for ExtJS. I find it a bit confusing to navigate at first, but you get used to it fairly quickly. An open source project, Ext-Doc, generates documentation with a similar style, though it is now a bit outdated.

另一个您可能会寻找灵感并了解他们是如何做到的,那就是ExtJS在线文档。我觉得一开始导航有点混乱,但你很快就会习惯它。一个开源项目Ext-Doc生成具有类似风格的文档,尽管它现在有点过时了。

YUI Doc

YUI文档

As mentioned by Matthew Manela, YUI Doc produces pretty good online documentation as well.

正如 Matthew Manela 所提到的,YUI Doc 也生成了非常好的在线文档。

My advice would be to go for JSDoc as it is the de-facto standard for many tools and it reflects Java practices, but it's really up to what you want.

我的建议是使用 JSDoc,因为它是许多工具的事实上的标准,它反映了 Java 实践,但这真的取决于你想要什么。

回答by Utensil

For the ones using ExtJs, https://github.com/senchalabs/jsduckis awesome.

对于使用 ExtJs 的人来说,https://github.com/senchalabs/jsduck很棒。

For the ones not using ExtJS but familiar with Ruby, https://github.com/b-studios/doc.jsis great.

对于那些不使用 ExtJS 但熟悉 Ruby 的人来说,https://github.com/b-studios/doc.js很棒。

回答by Andrew

A newer option is http://documentation.js.org/which uses JSDoc and generates HTML:

较新的选项是http://documentation.js.org/,它使用 JSDoc 并生成 HTML:

Documentation.js example

Documentation.js 示例

You can run it with gulp https://github.com/documentationjs/gulp-documentation

您可以使用 gulp https://github.com/documentationjs/gulp-documentation运行它

回答by Matthew Manela

Check out YUI Doc.

查看YUI 文档

回答by owler

Dossieris currently (2016) being used to build the Closure Library documentation. It is a fantastic tool that is built on top of Closure Compiler itself, so it actually reads all the type information using the compiler and then outputs documentation instead of code.

Dossier目前 (2016) 用于构建Closure Library 文档。它是建立在 Closure Compiler 本身之上的出色工具,因此它实际上使用编译器读取所有类型信息,然后输出文档而不是代码。

There are still some things being worked out about the user interface of the docs. Currently that Closure Library docs page looks rather empty -- you have to click on the "hamburger menu" symbol in upper left to get started.

关于文档的用户界面,仍有一些事情正在解决中。目前,Closure Library 文档页面看起来相当空旷——您必须单击左上角的“汉堡菜单”符号才能开始使用。