Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
J

jazzy

> 编程语言
Open source

Soulful docs for Swift & Objective-C

7.4K stars0 likes5 views
WebsiteGitHub

About

Soulful docs for Swift & Objective-C

jazzy is a command-line utility that generates documentation for Swift or Objective-C

About

Both Swift and Objective-C projects are supported.

Instead of parsing your source files, jazzy hooks into [Clang][clang] and [SourceKit][sourcekit] to use the [AST][ast] representation of your code and its comments for more accurate results. The output matches the look and feel of Apple’s official reference documentation, post WWDC 2014.

Jazzy can also generate documentation from compiled Swift modules using their symbol graph instead of source code.

This project adheres to the Contributor Covenant Code of Conduct. By participating, you are expected to uphold this code. Please report unacceptable behavior to [email protected].

Requirements

You need development tools to build the project you wish to document. Jazzy supports both [Xcode][xcode] and [Swift Package Manager][spm] projects.

Jazzy expects to be running on macOS. See below for tips to run Jazzy on Linux.

Installation

bash
[sudo] gem install jazzy

See Installation Problems for solutions to some common problems.

Usage

Run jazzy from your command line. Run jazzy -h for a list of additional options.

If your Swift module is the first thing to build, and it builds fine when running xcodebuild or swift build without any arguments from the root of your project, then just running jazzy (without any arguments) from the root of your project should succeed too!

If Jazzy generates docs for the wrong module then use --module to tell it which one you'd prefer. If this doesn't help, and you're using Xcode, then try passing extra arguments to xcodebuild, for example jazzy --build-tool-arguments -scheme,MyScheme,-target,MyTarget.

If you want to generate docs for several modules at once then see Documenting multiple modules.

You can set options for your project’s documentation in a configuration file, .jazzy.yaml by default. For a detailed explanation and an exhaustive list of all available options, run jazzy --help config.

Supported documentation keywords

Swift documentation is written in markdown and supports a number of special keywords. Here are some resources with tutorials and examples, starting with the most modern:

  • Apple's Writing Symbol Documentation in Your Source Files article.
  • Apple's Formatting Your Documentation Content article.
  • Apple's Xcode Markup Formatting Reference.
  • Erica Sadun's Swift header documentation in Xcode 7 post and her book on Swift Documentation Markup.

For Objective-C documentation the same keywords are supported, but note that the format is slightly different. In Swift you would write - returns:, but in Objective-C you write @return. See Apple's HeaderDoc User Guide for more details. Note: jazzy currently does not support all Objective-C keywords listed in this document, only @param, @return, @warning, @see, @note, @code, @endcode, and @c.

Jazzy can also generate cross-references within your documentation. A symbol name in backticks generates a link, for example:

  • `MyClass` - a link to documentation for MyClass.
  • `MyClass.method(param1:)` - a link to documentation for that method.
  • `MyClass.method(...)` - shortcut syntax for the same thing.
  • `method(...)` - shortcut syntax to link to method from the documentation of another method or property in the same class.
  • `[MyClass method1]` - a link to an Objective-C method.
  • `-[MyClass method2:param1]` - a link to another Objective-C method.

Jazzy understands Apple's DocC-style links too, for example:

  • ``MyClass/method(param1:)`` - a link to the documentation for that method that appears as just method(param1:) in the rendered page.
  • ``<doc:method(_:)-e873>`` - a link to a specific overload of method(_:). Jazzy can't tell which overload you intend and links to the first one.

If your documentation is for multiple modules then symbol name resolution works approximately as though all the modules have been imported: you can use `TypeName` to refer to a top-level type in any of the modules, or `ModuleName.TypeName` to be specific. If there is an ambiguity then you can use a leading slash to indicate that the first part of the name should be read as a module name: `/ModuleName.TypeName`.

Math

Jazzy can render math equations written in LaTeX embedded in your markdown:

  • `$equation$` renders the equation in an inline style.
  • `$$equation$$` renders the equation in a display style, centered on a line of its own.

For example, the markdown:

markdown
Inline: `$ax^2+bx+c=0$`

Block: `$$x={\frac {-b\pm {\sqrt {b^{2}-4ac}}}{2a}}$$`

..renders as:

Math support is provided by KaTeX.

Swift

Swift documentation is generated by default.

Example

This is how Realm Swift docs are generated:

bash
jazzy \
  --clean \
  --author Realm \
  --author_url https://realm.io \
  --source-host github \
  --source-host-url https://github.com/realm/realm-cocoa \
  --source-host-files-url https://github.com/realm/realm-cocoa/tree/v0.96.2 \
  --module-version 0.96.2 \
  --build-tool-arguments -scheme,RealmSwift \
  --module RealmSwift \
  --root-url https://realm.io/docs/swift/0.96.2/api/ \
  --output docs/swift_output \
  --theme docs/themes

This is how docs are generated for a project that uses the Swift Package Manager:

bash
jazzy \
  --module DeckOfPlayingCards \
  --swift-build-tool spm \
  --build-tool-arguments -Xswiftc,-swift-version,-Xswiftc,5

Objective-C

To generate documentation for a simple Objective-C project, you must pass the following parameters:

  • --objc
  • --umbrella-header ...
  • --framework-root ...

...and optionally:

  • --sdk [iphone|watch|appletv][os|simulator]|macosx (default value of macosx)
  • --hide-declarations [objc|swift] (hides the selected language declarations)

For example, this is how the AFNetworking docs are generated:

bash
jazzy \
  --objc \
  --author AFNetworking \
  --author_url http://afnetworking.com \
  --source-host github \
  --source-host-url https://github.com/AFNetworking/AFNetworking \
  --source-host-files-url https://github.com/AFNetworking/AFNetworking/tree/2.6.2 \
  --module-version 2.6.2 \
  --umbrella-header AFNetworking/AFNetworking.h \
  --framework-root . \
  --module AFNetworking

For a more complicated Objective-C project, instead use --build-tool-arguments to pass arbitrary compiler flags. For example, this is how Realm Objective-C docs are generated:

bash
jazzy \
  --objc \
  --clean \
  --author Realm \
  --author_url https://realm.io \
  --source-host github \
  --source-host-url https://github.com/realm/realm-cocoa \
  --source-host-files-url https://github.com/realm/realm-cocoa/tree/v2.2.0 \
  --module-version 2.2.0 \
  --build-tool-arguments --objc,Realm/Realm.h,--,-x,objective-c,-isysroot,$(xcrun --show-sdk-path),-I,$(pwd) \
  --module Realm \
  --root-url https://realm.io/docs/objc/2.2.0/api/ \
  --output docs/objc_output \
  --head "$(cat docs/custom_head.html)"

See the Objective-C docs for more information and some tips on troubleshooting.

Mixed Objective-C / Swift

This feature has some rough edges.

To generate documentation for a mixed Swift and Objective-C project you must first generate two [SourceKitten][sourcekitten] files: one for Swift and one for Objective-C.

Then pass these files to Jazzy together using --sourcekitten-sourcefile.

Example

This is how docs are generated from an Xcode project for a module containing both Swift and Objective-C files:

bash
# Generate Swift SourceKitten output
sourcekitten doc -- -workspace MyProject.xcworkspace -scheme MyScheme > swiftDoc.json

# Generate Objective-C SourceKitten output
sourcekitten doc --objc $(pwd)/MyProject/MyProject.h \
      -- -x objective-c  -isysroot $(xcrun --show-sdk-path --sdk iphonesimulator) \
      -I $(pwd) -fmodules > objcDoc.json

# Feed both outputs to Jazzy as a comma-separated list
jazzy --module MyProject --sourcekitten-sourcefile swiftDoc.json,objcDoc.json

Docs from .swiftmodules or frameworks

Swift 5.3 added support for symbol graph generation from .swiftmodule files.

Jazzy can use this to generate API documentation. This is faster than using the source code directly but does have limitations: for example documentation comments are available only for public declarations, and the presentation of Swift extensions may not match the way they are written in code.

Some examples:

  1. Generate docs for the Apple Combine framework for macOS:
    bash
    jazzy --module Combine --swift-build-tool symbolgraph
    The SDK's library directories are included in the search path by default.
  2. Same but for iOS:
    bash
    jazzy --module Combine --swift-build-tool symbolgraph
          --sdk iphoneos
          --build-tool-arguments -target,arm64-apple-ios14.1
    The target is the LLVM target triple and needs to match the SDK. The default here is the target of the host system that Jazzy is running on, something like x86_64-apple-darwin19.6.0.
  3. Generate docs for a personal .swiftmodule:
    bash
    jazzy --module MyMod --swift-build-tool symbolgraph
          --build-tool-arguments -I,/Build/Products
    This implies that /Build/Products/MyMod.swiftmodule exists. Jazzy's --source-directory (default current directory) is searched by default, so you only need the -I override if that's not enough.
  4. For a personal framework:
    bash
    jazzy --module MyMod --swift-build-tool symbolgraph
          --build-tool-arguments -F,/Build/Products
    This implies that /Build/Products/MyMod.framework exists and contains a .swiftmodule. Again the --source-directory is searched by default if -F is not passed in.
  5. With pre-generated symbolgraph files:
    bash
    jazzy --module MyMod --swift-build-tool symbolgraph
          --symbolgraph-directory Build/symbolgraphs
    If you've separately generated symbolgraph files by the use of -emit-symbol-graph, you can pass the location of these files using --symbolgraph-directory from where they can be parsed directly.

See swift symbolgraph-extract -help for all the things you can pass via --build-tool-arguments: if your module has dependencies then you may need to add various search path options to let Swift load it.

Documenting multiple modules

This feature is new, bugs and feedback welcome

Sometimes it's useful to document multiple modules together in the same site, for example an app and its extensions, or an SDK that happens to be implemented as several modules.

Jazzy can build docs for all these together and create a single site with search, cross-module linking, and navigation.

Build configuration

If all the modules share the same build flags then the easiest way to do this is with --modules, for example jazzy --modules ModuleA,ModuleB,ModuleC.

If your modules have different build flags then you have to use the config file. For example:

yaml
modules:
  - module: ModuleA
  - module: ModuleB
    build_tool_arguments:
      - -scheme
      - SpecialScheme
      - -target

Issues· 74 open

View all issuesOpen on GitHub
  • #1435

    jazzy 0.15.4 fails at startup with mustache 1.1.3: `undefined method 'map' for an instance of Pathname`

    Updated Sep 1, 2026
  • #1419

    Can't leverage github action variables due to config file requirement

    helpUpdated Jul 8, 2026
  • #1060

    @name in single line comment is parsed incorrectly

    bugsourcekittenUpdated Jul 5, 2026
  • #190

    Use inherited docs when local ones are missing

    featurepriority-lowdifficulty-moderateUpdated Oct 20, 2025
  • #1202

    Generate Sitemap

    enhancementUpdated Dec 15, 2023
  • #382

    Multi-framework Doc Generation for Obj-C

    sourcekittenpriority-highdifficulty-moderateUpdated Nov 4, 2023
  • #806

    Drop raw values from declarations

    enhancementUpdated Nov 4, 2023
  • #909

    Parameter not included when using swift style commenting with obj-c

    enhancementsourcekittenUpdated Nov 4, 2023
  • #867

    Break up autolinking of generic types.

    enhancementUpdated Nov 4, 2023
  • #1170

    Custom categories from code comments

    enhancementUpdated Sep 10, 2023

> Tags

Rubyrubysourcekitsourcekittenswift

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedOct 2, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言