Want to take your software engineering career to the next level? Join the mailing list for career tips & advice Click here

jazzy

Soulful docs for Swift & Objective-C

Star full 4f7b624809470f25b6493d5a7b30d9b9cb905931146e785d67c86ef0c205a402Star full 4f7b624809470f25b6493d5a7b30d9b9cb905931146e785d67c86ef0c205a402Star full 4f7b624809470f25b6493d5a7b30d9b9cb905931146e785d67c86ef0c205a402Star full 4f7b624809470f25b6493d5a7b30d9b9cb905931146e785d67c86ef0c205a402Star full 4f7b624809470f25b6493d5a7b30d9b9cb905931146e785d67c86ef0c205a402 (1 ratings)
Rated 5.0 out of 5
Subscribe to updates I use jazzy


Statistics on jazzy

Number of watchers on Github 6574
Number of open issues 120
Average time to close an issue 13 days
Main language Ruby
Average time to merge a PR 4 days
Open pull requests 35+
Closed pull requests 35+
Last commit 4 months ago
Repo Created over 6 years ago
Repo Last Updated 3 months ago
Size 73.6 MB
Homepage https://realm.io
Organization / Authorrealm
Latest Releasev0.13.5
Contributors17
Page Updated
Do you use jazzy? Leave a review!
View open issues (120)
View jazzy activity
View on github
Book a Mock Interview With Me (Silicon Valley Engineering Leader, 100s of interviews conducted)
Software engineers: It's time to get promoted. Starting NOW! Subscribe to my mailing list and I will equip you with tools, tips and actionable advice to grow in your career.
Evaluating jazzy for your project? Score Explanation
Commits Score (?)
Issues & PR Score (?)

jazzy

Build Status

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

About

Both Swift and Objective-C projects are supported.

SwiftPM support was recently added, so please report any issues you find.

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

Screenshot

This project adheres to the Contributor Covenant Code of Conduct. By participating, you are expected to uphold this code. Please report unacceptable behavior to info@realm.io.

Requirements

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

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

Installation

[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 -target,MyTarget.

You can set options for your projects 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 keywords

Swift documentation is written in markdown and supports a number of special keywords. For a complete list and examples, see Erica Sadun's post on Swift header documentation in Xcode 7, her book on Swift Documentation Markup, and the Xcode Markup Formatting Reference.

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, and @note.

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.

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:

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

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

..renders as:

math

Math support is provided by KaTeX.

Swift

Swift documentation is generated by default.

Example

This is how Realm Swift docs are generated:

jazzy \
  --clean \
  --author Realm \
  --author_url https://realm.io \
  --github_url https://github.com/realm/realm-cocoa \
  --github-file-prefix 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:

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

Objective-C

To generate documentation for Objective-C headers, you must pass the following parameters to jazzy:

  • --objc
  • --umbrella-header ...
  • --framework-root ...
  • --sdk [iphone|watch|appletv][os|simulator]|macosx (optional, default value of macosx)
  • --hide-declarations [objc|swift] (optional, hides the selected language declarations)
Example

This is how Realm Objective-C docs are generated:

jazzy \
  --objc \
  --clean \
  --author Realm \
  --author_url https://realm.io \
  --github_url https://github.com/realm/realm-cocoa \
  --github-file-prefix 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)"

This is how the AFNetworking docs are generated:

jazzy \
  --objc \
  --author AFNetworking \
  --author_url http://afnetworking.com \
  --github_url https://github.com/AFNetworking/AFNetworking \
  --github-file-prefix https://github.com/AFNetworking/AFNetworking/tree/2.6.2 \
  --module-version 2.6.2 \
  --umbrella-header AFNetworking/AFNetworking.h \
  --framework-root . \
  --module AFNetworking

Mixed Objective-C / Swift

This feature is new and has some rough edges.

To generate documentation for a mixed Swift and Objective-C project you must first generate two 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:

# 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 --sourcekitten-sourcefile swiftDoc.json,objcDoc.json

Themes

Three themes are provided with jazzy: apple (default), fullwidth and jony.

You can specify which theme to use by passing in the --theme option. You can also provide your own custom theme by passing in the path to your theme directory.

Guides

Description Command
Command line option --documentation={file pattern}
Example --documentation=Docs/*.md
jazzy.yaml example documentation: Docs/*.md

By default, jazzy looks for one of README.md, README.markdown, README.mdown or README (in that order) in the directory from where it runs to render the index page at the root of the docs output directory. Using the --documentation option, extra markdown files can be integrated into the generated docs and sidebar navigation.

Any files found matching the file pattern will be parsed and included as a document with the type 'Guide' when generated. If the files are not included using the custom_categories config option, they will be grouped under 'Other Guides' in the sidebar navigation.

There are a few limitations:

  • File names must be unique from source files.
  • Readme should be specified separately using the readme option.

Section description abstracts

Description Command
Command line option --abstract={file pattern}
Example --abstract=Docs/Sections/*.md
jazzy.yaml example abstract: Docs/Sections/*.md

Using the --abstract options, extra markdown can be included after the heading of section overview pages. Think of it as a template include.

The list of files matching the pattern is compared against the list of sections generated and if a match is found, it's contents will be included in that section before listing source output.

Unlike the --documentation option, these files are not included in navigation and if a file does not match a section title, it is not included at all.

This is very helpful when using custom_categories for grouping types and including relevant documentation in those sections.

For an example of a project using both --documentation and --abstract see: https://reswift.github.io/ReSwift/

Controlling what is documented

In Swift mode, Jazzy by default documents only public and open declarations. To include declarations with a lower access level, set the --min-acl flag to internal, fileprivate, or private.

In Objective-C mode, Jazzy documents all declarations found in the --umbrella-header header file and any other header files included by it.

You can control exactly which declarations should be documented using --exclude, --include, or :nodoc:.

The --include and --exclude flags list source files that should be included/excluded respectively in the documentation. Entries in the list can be absolute pathnames beginning with / or relative pathnames. Relative pathnames are interpreted relative to the directory from where you run jazzy or, if the flags are set in the config file, relative to the directory containing the config file. Entries in the list can match multiple files using * to match any number of characters including /. For example:

  • jazzy --include=/Users/fred/project/Sources/Secret.swift -- include a specific file
  • jazzy --exclude=/*/Internal* -- exclude all files with names that begin with Internal and any files under any directory with a name beginning Internal.
  • jazzy --exclude=Impl1/*,Impl2/* -- exclude all files under the directories Impl1 and Impl2 found in the current directory.

Note that the --include option is applied before the --exclude option. For example:

  • jazzy --include=/*/Internal* --exclude=Impl1/*,Impl2/* -- include all files with names that begin with Internal and any files under any directory with a name beginning Internal, except for those under the directories Impl1 and Impl2 found in the current directory

Declarations with a documentation comment containing :nodoc: are excluded from the documentation.

Documentation structure

By default Jazzy does not create separate web pages for declarations that do not have any members: instead they are nested into some parent page. Use the --separate-global-declarations flag to change this and always create pages for declarations that can be directly accessed from client code.

Choosing the Swift language version

Jazzy normally uses the Swift compiler from the Xcode currently configured by xcode-select. Use the --swift-version flag to compile with a different Xcode.

The value you pass to --swift-version must be the Swift language version given by swift --version in the Xcode you want to use.

For example to use Xcode 9.4:

jazzy --swift-version 4.1.2

Linux

Jazzy uses SourceKitten to communicate with the Swift build environment and compiler. The sourcekitten binary included in the Jazzy gem is built for macOS and so does not run on other operating systems.

To use Jazzy on Linux you first need to install and build sourcekitten following instructions from SourceKitten's GitHub repository.

Then to generate documentation for a SwiftPM project, instead of running just jazzy do:

sourcekitten doc --spm > doc.json
jazzy --sourcekitten-sourcefile doc.json

We hope to improve this process in the future.

Troubleshooting

Swift

Only extensions are listed in the documentation?

Check the --min-acl setting -- see above.

Unable to find an Xcode with swift version X

  1. The value passed with --swift-version must exactly match the version number from swiftc --version. For example Xcode 10.1 needs --swift-version 4.2.1. See the flag documentation.
  2. The Xcode you want to use must be in the Spotlight index. You can check this using mdfind 'kMDItemCFBundleIdentifier == com.apple.dt.Xcode'. Some users have reported this issue being fixed by a reboot; mdutil -E may also help. If none of these work then you can set the DEVELOPER_DIR environment variable to point to the Xcode you want before running Jazzy without the --swift-version flag.

Installation Problems

Can't find header files / clang

Some of the Ruby gems that Jazzy depends on have native C extensions. This means you need the Xcode command-line developer tools installed to build them: run xcode-select --install to install the tools.

/Applications/Xcode: No such file or directory

The path of your active Xcode installation must not contain spaces. So /Applications/Xcode.app/ is fine, /Applications/Xcode-10.2.app/ is fine, but /Applications/Xcode 10.2.app/ is not. This restriction applies only when installing Jazzy, not running it.

MacOS Before 10.14.4

Starting with Jazzy 0.10.0, if you see an error similar to dyld: Symbol not found: _$s11SubSequenceSlTl then you need to install the Swift 5 Runtime Support for Command Line Tools.

Alternatively, you can:

  • Update to macOS 10.14.4 or later; or
  • Install Xcode 10.2 or later at /Applications/Xcode.app.

Development

Please review jazzy's contributing guidelines when submitting pull requests.

jazzy is composed of two parts:

  1. The parser, SourceKitten (written in Swift)
  2. The site generator (written in ruby)

To build and run jazzy from source:

  1. Install bundler.
  2. Run bundle install from the root of this repo.
  3. Run jazzy from source by running bin/jazzy.

Instructions to build SourceKitten from source can be found at SourceKitten's GitHub repository.

Design Goals

  • Generate source code docs matching Apple's official reference documentation
  • Support for standard Objective-C and Swift documentation comment syntax
  • Leverage modern HTML templating (Mustache)
  • Leverage the power and accuracy of the Clang AST and SourceKit
  • Support for Dash docsets
  • Support Swift and Objective-C

License

This project is released under the MIT license.

About

Jazzy is maintained and funded by Realm Inc. The names and logos for Realm are trademarks of Realm Inc.

We :heart: open source software! See our other open source projects, read our blog or say hi on twitter (@realm).

jazzy open issues Ask a question     (View All Issues)
  • almost 4 years Jazzy Ignores Xcodebuild Arguments.
  • almost 4 years Duplicate parameters, returns in docs
  • almost 4 years error handling xcodebuild parameters in objc
  • about 4 years Parameter to exclude overridden functions & properties.
  • about 4 years If Xcode is named something else, make command exits.
  • about 4 years ObjC Import file not found when using SPM directory structure
  • about 4 years Module version is not available in templates
  • about 4 years xcodebuild succeeds, but no documentation is generated
  • about 4 years Create docs for Swift from Objective-C for Swift 2.x and 3.x
  • about 4 years Unable to install with install jazzy command
  • about 4 years Jazzy 0.7.2 crashes with "comparison of Array with Array failed" ArgumentError
  • about 4 years Enums are not documented in my Swift code.
  • about 4 years Cannot generate documentation for CocoaPod lib with Swift 3, Xcode 8
  • about 4 years Jazzy generated documentation for // TODO: comments
  • about 4 years Swift 3.0, Xcode 8: jazzy generates empty docs
  • about 4 years Jazzy doesn’t run on XC 8 GM when Swift version explicitly specified
  • about 4 years Comma in Xcode Build Arguments is treated as a delimeter
  • about 4 years using jazzy when podpsec includes dependencies from a private spec repo
  • about 4 years Bug: README: Supported keywords: Objc: Broken link to HeaderDoc user guide
  • about 4 years Jazzy can not parse open classes from Swift 3
  • about 4 years Jazzy 0.7.0 not compatible with latest XCode8 betas
  • about 4 years Jazzy crashes when parsing extension with init
  • about 4 years Jazzy overgrabs for headers
  • about 4 years Jazzy should ignore properties annotated with NS_UNAVAILABLE
  • about 4 years Docs for methods include parameters and returns asides in the abstract, and once again after that
  • about 4 years error: use of '@import' when modules are disabled
  • about 4 years Doc truncated after "Example:"
  • about 4 years Can jazzy generate all files include alamofire,chart and myproject.xcodeproj into one display html?
  • about 4 years Jazzy won't parse symbols that have the @available attribute.
  • about 4 years List of todos
jazzy open pull requests (View All Pulls)
  • Merge ObjC categories into docs of the extended class
  • support Objective-C module imports
  • Integrated markdown
  • Add --skip-documentation option.
  • Add --lint-report option.
  • Add a Tasks list to the left column.
  • Added support for Bitbucket repos - as opposed to gitHub
  • Autolink declarations
  • Support documenting "substructures" such as Extensions.
  • Bump version to 0.6.0
  • Add ability to exclude directories in addition to files.
  • Integrated markdown parsing and guide support
  • update CocoaPods gem to 1.0
  • Escape question marks in URLs
  • Remove directories before symlinking, fixes installation from Gemfile
  • Group operators by name
  • Bugfix/bugfix 518
  • Fix abstract injection
  • Change Dash type for typedefs
  • Initial search implementation (fullwidth-only)
  • Fixed wildcards in file exclude config
  • WIP: Generate badges displaying doc coverage
  • Build integration specs with Xcode 8.3.2
  • Add -fmodules flag for default objective-c options list
  • Fix an issue when additional xcodebuild arguments are ignored in Objective-C mode
  • [fix] do not document '//TODO: ' comments
  • Add Test Fixtures for Treatment of Undocumented Symbols
  • Make --skip-undocumented less aggressive
  • Fix space before parameter abstract in output
  • Adds a modern Apple docs theme
  • Improve Swift declarations using SourceKit's version
  • Drop Sass dependency to pre-3.5 to avoid ffi
  • Swift SymbolGraph importer
  • Minimize the amount of specs being built by jazzy and improve checking which targets to build.
  • [WIP] Allow nested categories with recursive navigation.
jazzy questions on Stackoverflow (View All Questions)
  • jazzy spell check showing correctly spelled words as misspelled
  • Cannot install Jazzy Cocoapod
  • How to use jazzy to document my swift project?
  • Jazzy is not working as expected for generating swift documentation
  • Jazzy ViewPager with MVVMCROSS
  • refreshable listview using jazzy listview android
  • Xcode integration script for jazzy, the doc generator for Swift projects
  • Creating Custom Dictionary in Jazzy - java Spell Checker API
  • Jazzy GridView is not responding on click event
  • EPub Spell Checker using Jazzy (Word with wrong spelling doesn't appear in JTable) - Closed
  • How to use efficiently Jazzy ViewPager
  • C# Application with Jazzy UI
  • Aspel dictionaries for Jazzy libraires in Java
  • Java web framework with Jazzy UI
jazzy list of languages used
jazzy latest release notes
v0.13.5 0.13.5
Breaking
  • None.
Enhancements
  • Add search function to apple theme. Giles Payne #726

  • Add option --[no-]separate-global-declarations to always create separate documentation pages for top-level declarations as well as classes, structures, enums etc. even if they don't have members. As part of this, improve the main page declaration in all modes. Nikolay Volosatov John Fairhurst

Bug Fixes
v0.13.4 0.13.4
Breaking
  • None.
Enhancements
  • Update JavaScript libraries: jQuery 3.5.1 (all themes), Lunr 2.3.8, typeahead.js 1.3.1 (fullwidth theme only). John Fairhurst
Bug Fixes
v0.13.3 0.13.3
Breaking
  • None.
Enhancements
  • Added a config option to provide sources of privately hosted pod dependencies when using the --podspec option. --pod-sources url1,url2,urlN. Jonathan Bailey #650

  • Improve Dash docset support: support online redirection when --root-url is set, and provide --docset-playground-url to support docset playground links. John Fairhurst

Bug Fixes
Other projects in Ruby
Powered by Autocode - Instant Webhooks, Scripts and APIs
Autocode logo wordmark