Use docgen to generate, and serve, the documentation for your Dart package.
Docgen generates documentation from Dart code in the
The files are output in either JSON or YAML format.
When using the
--serve option, docgen serves your files so you can
see them locally in a browser.
To deploy your documentation to the web,
along with your generated files.
Here is a simple example of using docgen to generate docs
on the command line. The docs are generated from the source
code in the
Run this command from the top-level directory of your Dart package,
after you have run
pub get to get the dependencies:
This command generates documentation, in the JSON
file format, and places it in a top-level directory named
See options for information on how to configure
Here is a simple example of using docgen to generate, and then serve, the generated docs to the viewer.
docgen --serve .
After generating the documentation,
this command puts
dartdoc-viewer in a top-level directory
(if not already present), and starts it up.
The generated docs can now be viewed in your browser at
To deploy your documentation to the web, do the following:
docsunder the main URL.
Common command-line options for docgen include:
library_list.json. Add the newly generated documentation to the docs directory, library_list.json, and index.txt. When this flag is specified, the
--no-jsonflags are ignored.
<directory>. If not specified, the default is
Some other handy options include:
Docgen includes a number of options that apply only to generating
the Dart SDK documentation. Those are not documented here, but
you can obtain a list by using the
docgen -h command.