For the complete Mojo documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /docs/manual/basics.md).
mojo doc
Compiles docstrings from a Mojo file.
Synopsis
mojo doc [options] <path>
Description
This is an early version of a documentation tool that generates an API reference from Mojo code comments. Currently, it generates a structured output of all docstrings into a JSON file, and it does not generate HTML. This output format is subject to change.
The input may be a single file or a directory. If you specify a directory, it will generate a single JSON output with documentation for all modules found in that path, recursively.
Options
Output options
-o <PATH>
Sets the path and filename for the JSON output. If not provided, output is written to stdout.
--docs-base-path <PATH>
Sets the path prefix for generated documentation links.
Compilation options
-I <PATH>
Appends the given path to the list of directories to search for imported Mojo files.
Compilation diagnostic options
Controls how the Mojo compiler outputs diagnostics related to compiling and running Mojo source code.
--diagnose-missing-doc-strings
Emits diagnostics for missing or partial doc strings.
--max-notes-per-diagnostic <INTEGER>
When the Mojo compiler emits diagnostics, it sometimes also prints notes with additional information. This option sets an upper threshold on the number of notes that can be printed with a diagnostic. If not specified, the default maximum is 10.
--disable-builtins
Do not use builtins when create package.
--disable-warnings
Do not print warning messages.
--Werror
Treat warnings as errors.
--Wno-error
Do not treat warnings as errors.
--warn-on-unstable-apis
Warn when using unstable APIs from the standard library.
--ignore-incompatible-precompiled-file-errors
Ignore errors encountered when loading incompatible Mojo precompiled files.
--ignore-deprecated <NAME>
Suppress the deprecation warning for the given declaration (e.g. Foo.bar, or some_fn for a top-level declaration).
Common options
--help, -h
Displays help information.
--help-hidden
Displays help for hidden options.
--diagnostic-format <FORMAT>
The format in which diagnostics and error messages are printed. Must be one of "text" or "json" ("text" is the default).