Build and deploy beautiful, organic, modular documentation sites

Build and deploy beautiful, organic, modular documentation sites

OrchidSwiftdoc

Create beautiful documentation for your Swift source code within Orchid.

official docs

About

The OrchidSwiftdoc plugin integrates with the SourceKitten tool to embed class and package info from Swift source code directly in your Orchid site, producing documentation similar to Javadoc. Comment text is compiled as Markdown, and is also fully-searchable with the OrchidSearch plugin.

Demo

Usage

Basic Usage

Documenting Swift code within Orchid depends on the SourceKitten command line tool, which itself requires the full XCode environment to be installed on your system (not just the xcode command-line tools). XCode can be installed from the AppStore, and SourceKitten can be installed though Homebrew:

brew install sourcekitten

Once the Swiftdoc plugin is added to your build and the dependencies are installed to your local Mac, you need to tell Orchid where it can find your Swift code. This is set in your config.yml as a list of file paths to the root package for your code.

A typical use-case is to have Orchid be used from Gradle to document an external XCode project. For example, using docs and app subprojects with the following standard Gradle/Maven project structure:

. / (repo root)
├── app <-- this is the directory you need to reference
|   └── Main.swift
└── docs <-- Gradle project root
    └── src/orchid/resources/ <-- these are your Orchid resources
        ├── homepage.md
        └── config.yml

Your config.yml can specify a relative path from your Orchid resources to your Swift code source root:

swiftdoc:
  sourceDirs:
    - './../../../../app/'

Setting multiple sourceDirs will include them all in the generated documentation.

OrchidSwiftdoc ships with a menu item that is useful for navigating all elements in a Swift application. The swiftdocPages menu item links to all generated top-level pages, and can be filitered to just classes, packages, enums, etc.

This is best added to the Swiftdoc page Archetypes in config.yml:

swiftdoc:
  pages:  # <-- applied to Swiftdoc class and source pages
    menu:
      - { type: "swiftdocPages", docType: "class"    }
      - { type: "swiftdocPages", docType: "struct"   }
      - { type: "swiftdocPages", docType: "enum"     }
      - { type: "swiftdocPages", docType: "protocol" }
      - { type: "swiftdocPages", docType: "global"   }
dependencies {
    orchidRuntime 'io.github.javaeden.orchid:orchidswiftdoc:0.17.1'
}
<dependency>
    <groupId>io.github.javaeden.orchid</groupId>
    <artifactId>orchidswiftdoc</artifactId>
    <version>0.17.1</version>
    <type>pom</type>
</dependency>
@file:DependsOn("io.github.javaeden.orchid:orchidswiftdoc:0.17.1")