3

I want to document my swift project, and I find jazzy on the github. after a look at the guide, I create a new simple project and want to have a try, here is my ViewController with some document info:

import UIKit
/**
a view controller
*/
class ViewController: UIViewController {
// MARK: property
/// a simple var
var hello = 200

// MARK: Func
/// view did load
override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.
    print(add(2, b: 2))
}
/// did receiveMemoryWarning
override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}

/// a document test func
func add(a:Int, b:Int)->Int{
    return a + b
    }
}

here is my command:

    ➜  DocumentDemo git:(master) ✗ jazzy --swift-version 2.1.1 \
--clean \
--author helloworld \
-x -scheme,DocumentDemo
Running xcodebuild
Parsing ViewController.swift (1/3)
Parsing AppDelegate.swift (2/3)
Parsing My.swift (3/3)
building site
jam out ♪♫ to your fresh new docs in `docs`
➜  DocumentDemo git:(master) ✗

and I expect the html to have some info about my view controller,but the result is nothing there:

enter image description here

I want to know how to use jazzy, hope some advices.

Nicolas Miari
  • 16,006
  • 8
  • 81
  • 189
Xingou
  • 1,141
  • 1
  • 10
  • 20
  • Search the wikis and issues of Jazzy on GitHub; there are several pitfalls. Also, there is a "default access-control-level" of visibility for Jazzy, and if I remember correctly it is `public` (not the default `protected`); that's why your docs end up empty I think. – Nicolas Miari Dec 24 '15 at 09:18
  • @NicolasMiari i tried public, this the issue, thanks a lot – Xingou Dec 24 '15 at 09:23
  • 2
    Mmh... Did you try using a configuration file (.jazzy.yaml)? Mine starts with `clean: true \n min_acl: private`. This means anything above-and-including private is documented. – Nicolas Miari Dec 24 '15 at 09:25
  • 2
    Save the file in the same directory where your `.xcodeproj` resides, and run jazzy from there, without arguments (it will read them from the file instead). – Nicolas Miari Dec 24 '15 at 09:26
  • aha, it's perfect , now everything works fine .thanks again – Xingou Dec 24 '15 at 09:44
  • You can specify the same options from the command line, but it's a pain to have to remember and type them every time. – Nicolas Miari Dec 24 '15 at 09:51
  • i have changed acl to private but still everything is undocumented. any clue ? – Alok C May 03 '16 at 05:45
  • Possible duplicate of [Jazzy is not working as expected for generating swift documentation](http://stackoverflow.com/questions/33533188/jazzy-is-not-working-as-expected-for-generating-swift-documentation) – Caleb Kleveter Jul 27 '16 at 21:02

3 Answers3

5

By default, Jazzy only documents public classes, functions, properties, etc. So you can do one of two things:

  1. Add the public keyword to classes, methods and properties you want document.
  2. Change the privacy level that Jazzy will document. You can change this with the --min-acl flag:

    jazzy --swift-version 2.1.1 --min-acl=internal
    
Caleb Kleveter
  • 11,170
  • 8
  • 62
  • 92
3

On swift 3 just

jazzy --min-acl=internal
Momo Id
  • 31
  • 2
1

Yes, if you just run jazzy, jazzy just assume you want default access control level is public.

So unless we annotate things with public, the final document won't show theses. Default level is internal.


Tip

You can create a .jazzy.yaml, and put configuration in there. So after this, can just run.

$ jazzy

Jazzy will parse our configured yaml file.

Reference: Siesta's jazzy

Vinh Nguyen
  • 816
  • 1
  • 13
  • 27