Documentation compiler that produces rich API reference documentation and interactive tutorials for your Swift framework or package.
Swift-DocC is a documentation compiler for Swift frameworks and packages aimed at making it easy to write and publish great developer documentation
For an example of Swift-DocC in action, check out developer.apple.com. Much of Apple's developer documentation, from Reference documentation to Tutorials, and long-form content is built using Swift-DocC.
To learn more about the essentials of this tool refer to the user documentation.
Swift-DocC is being actively developed. For more information about the Swift-DocC project, see the introductory blog post here.
The Swift Forums are the best place to get help with Swift-DocC and discuss future plans.
As an open-source project, we value any contribution made to this tool. Please see the contributing guide for more information on how to contribute and build DocC from source.
docc is the command line interface (CLI) for Swift-DocC and provides
support for generating and previewing documentation.
There are multiple ways you can make use of DocC depending on your use case:
1. For documenting packages via SwiftPM:
If you want to generate documentation for your Swift package we recommend using the Swift-DocC Plugin. Please refer to the Plugin's documentation to get started with building, previewing, and publishing your documentation to your website or GitHub Pages.
2. For standalone documentation:
If you have Xcode installed, it's recommended to generate documentation using the xcrun command.
You can get DocC working by invoking xcrun docc in your terminal.
Swift-DocC is also included in the Swift toolchain for both macOS and Linux.
To see instructions on how to use DocC from the CLI run
docc --help
3. For documenting apps, frameworks, and packages using Xcode:
If you want to generate an API reference for your project you can use DocC via Xcode. Please refer to the Xcode documentation to learn the essentials of how to get started.
If you want to learn how to write and format your documentation please refer to Formatting Your Documentation Content. For publishing go to Distributing Documentation to Other Developers.
To learn more about how Swift-DocC works internally please see CONTRIBUTING.md.
Swift-DocC's CLI tool (docc) is integrated into the Swift toolchain
and follows the Swift compiler's versioning scheme.
The SwiftDocC library is versioned separately from docc. SwiftDocC is under
active development and source stability is not guaranteed.
Swift-DocC tracks all bug reports with GitHub Issues. When you submit a bug report we ask that you follow the provided template and provide as many details as possible.
Note: You can use the
environmentscript in this repository to gather helpful environment information to paste into your bug report by running the following:bin/environment
If you can confirm that the bug occurs when using the latest commit of Swift-DocC
from the main branch (see Building Swift-DocC),
it will help us track down the bug faster..
For feature requests, please feel free to file a GitHub issue or start a discussion on the Swift Forums.
Don't hesitate to submit a feature request if you see a way Swift-DocC can be improved to better meet your needs.
All user-facing features must be discussed in the Swift Forums before being enabled by default.
good first issue 또는 help wanted 이슈가 없습니다.
Thank you for considering contributing to Swift-DocC.
Please know that everyone is welcome to contribute to Swift-DocC. Contributing doesn’t just mean submitting pull requests—there are many different ways for you to get involved, including answering questions on the Swift Forums, reporting or screening bugs, and writing documentation.
No matter how you want to get involved, we ask that you first learn what’s expected of anyone who participates in the project by reading the Swift Community Guidelines as well as our Code of Conduct.
This document focuses on how to contribute code and documentation to this repository.
By submitting a pull request, you represent that you have the right to license your
contribution to Apple and the community, and agree by submitting the patch that your
contributions are licensed under the Apache 2.0 license (see LICENSE.txt).
Swift-DocC is an open source project and we encourage contributions from the community.
Before contributing code or documentation to Swift-DocC, we encourage you to first open a GitHub issue for a bug report or feature request. This will allow us to provide feedback on the proposed change. However, this is not a requirement. If your contribution is small in scope, feel free to open a PR without first creating an issue.
All changes to Swift-DocC source must go through the PR review process before
being merged into the main branch.
See the Code Contribution Guidelines below for
more details.
docc is the command line interface (CLI) for Swift-DocC and provides
support for generating and previewing documentation.
Swift-DocC is a Swift package. If you're new to Swift package manager, the documentation here provides an explanation of how to get started and the software you'll need installed.
Checkout this repository using:
git clone git@github.com:swiftlang/swift-docc.git
Navigate to the root of your cloned repository with:
cd swift-docc
Create a new branch off of main for your change using:
git checkout -b branch-name-here
Note that main (the repository's default branch) will always hold the most
recent approved changes. In most cases, you should branch off of main when
starting your work and open a PR against main when you're ready to merge
that work.
Build Swift-DocC from the command line by running:
swift build
Alternatively, to use Xcode, open the Package.swift file
at the repository's root. Then, build it by pressing Command-B.
You can run your newly built version of docc with:
swift run docc
Or, in Xcode, run the docc
scheme.
Both the JSON output and HTML output of Swift-DocC are optimized for file size.
If you need to inspect either output format for debugging purposes set the DOCC_JSON_PRETTYPRINT or DOCC_HTML_PRETTYPRINT environment variables to "YES" to enable pretty printing.
Alternatively, you can set the DOCC_PRETTYPRINT environment variable to "YES" to enable pretty printing regardless of output format.
export DOCC_JSON_PRETTYPRINT="YES"
Do your best to keep the git history easy to understand.
Use informative commit titles and descriptions.
All changes must go through the pull request review process.
Follow the Swift API Design guidelines.
When you're ready to have your change reviewed, please make sure you've completed the following requirements:
Add tests to cover any new functionality or to prevent regressions of a bug fix.
Run the /bin/test script and confirm that the test suite passes.
(See Testing Swift-DocC.)
Add source code documentation to all added or modified APIs that explains the new behavior.
When opening a pull request, please make sure to fill out the pull request template and complete all tasks mentioned there.
Your PR should mention the number of the GitHub issue your work is addressing.
Most PRs should be against the main branch. If your change is intended
for a specific release, you should also create a separate branch
that cherry-picks your commit onto the associated release branch.
All PRs will need approval from someone on the core team (someone with write access to the repository) before being merged.
All PRs must pass the required continuous integration tests as well. If you have commit access, you can run the required tests by commenting the following on your PR:
@swift-ci Please smoke test
If you do not have commit access, please ask one of the code owners to trigger them for you. For more details on Swift-DocC's continuous integration, see the Continuous Integration section below.
We try to avoid source breaking changes, for example:
That said, sometimes there are good r