2016-10-28 42 views
7

Làm cách nào để hiển thị mô tả ngắn gọn về chức năng trong khi nhập như hình ảnh hiển thị bên dưới? Tôi đã thử nhiều tùy chọn khác nhau tất cả đều thất bại.Xcode 8 cách hiển thị mô tả chức năng khi nhập

enter image description here

Option + nhấp chuột hoạt động nhưng đó không phải là những gì tôi đang tìm kiếm.

Lựa chọn 1

/// Testing... 
    /// - returns: false 
    func testing()->Bool{ 
    return false 
    } 

Lựa chọn 2

/** 
Testing option two 
*/ 
func testing()->Bool{ 
     return false 
} 

Vấn đề này đã được cố định trong Xcode 9

+0

Nó không hoạt động trên Xcode 8.1 cũng – kamwysoc

+2

kiểm tra câu trả lời này - http://stackoverflow.com/questions/38071289/xcode-8-auto-generated-quick-help-documentation –

+0

@SunilSharma không phải những gì tôi tìm kiếm – kye

Trả lời

2

Bạn đã thiết lập:

Preferences -> Text Editing -> Đề nghị hoàn trong khi gõ

Nó cũng có thể giúp đỡ để cài đặt các hướng dẫn và mẫu mã tại địa chỉ:

Preferences -> Components -> Documentation Tab -> "Kiểm tra và Install Now "hoặc mũi tên bên cạnh hướng dẫn và mã mẫu để tải xuống chỉ một lần

5

Nếu bạn đang tìm cách tạo tài liệu phương pháp tự tạo nhanh chóng thì điều này có thể giúp bạn thoát ra.

import Foundation 
/// A two-wheeled, human-powered mode of transportation. 
class Bicycle { 
/** 
    Frame and construction style. 

    - Road: For streets or trails. 
    - Touring: For long journeys. 
    - Cruiser: For casual trips around town. 
    - Hybrid: For general-purpose transportation. 
*/ 
enum Style { 
    case Road, Touring, Cruiser, Hybrid 
} 

/** 
    Mechanism for converting pedal power into motion. 

    - Fixed: A single, fixed gear. 
    - Freewheel: A variable-speed, disengageable gear. 
*/ 
enum Gearing { 
    case Fixed 
    case Freewheel(speeds: Int) 
} 

/** 
    Hardware used for steering. 

    - Riser: A casual handlebar. 
    - Café: An upright handlebar. 
    - Drop: A classic handlebar. 
    - Bullhorn: A powerful handlebar. 
*/ 
enum Handlebar { 
    case Riser, Café, Drop, Bullhorn 
} 

/// The style of the bicycle. 
let style: Style 

/// The gearing of the bicycle. 
let gearing: Gearing 

/// The handlebar of the bicycle. 
let handlebar: Handlebar 

/// The size of the frame, in centimeters. 
let frameSize: Int 

/// The number of trips travelled by the bicycle. 
private(set) var numberOfTrips: Int 

/// The total distance travelled by the bicycle, in meters. 
private(set) var distanceTravelled: Double 

/** 
    Initializes a new bicycle with the provided parts and specifications. 

    - Parameters: 
     - style: The style of the bicycle 
     - gearing: The gearing of the bicycle 
     - handlebar: The handlebar of the bicycle 
     - frameSize: The frame size of the bicycle, in centimeters 

    - Returns: A beautiful, brand-new bicycle, custom built 
     just for you. 
*/ 
init(style: Style, gearing: Gearing, handlebar: Handlebar, frameSize centimeters: Int) { 
    self.style = style 
    self.gearing = gearing 
    self.handlebar = handlebar 
    self.frameSize = centimeters 

    self.numberOfTrips = 0 
    self.distanceTravelled = 0 
} 

/** 
    Take a bike out for a spin. 

    - Parameter meters: The distance to travel in meters. 
*/ 
func travel(distance meters: Double) { 
    if meters > 0 { 
     distanceTravelled += meters 
     ++numberOfTrips 
    } 
} 
} 

enter image description here

Swift-Documentation on NSHipster

+0

Mặc dù liên kết này có thể trả lời câu hỏi, nhưng tốt hơn nên đưa các phần quan trọng của câu trả lời vào đây và cung cấp liên kết để tham khảo. Câu trả lời chỉ liên kết có thể trở thành không hợp lệ nếu trang được liên kết thay đổi. - [Từ đánh giá] (/ đánh giá/chất lượng thấp-bài viết/14656877) – Himanshu

+0

Cảm ơn hoàn toàn đúng. –

3

Chọn chức năng của bạn hoặc đặt con trỏ trước khi chức năng của bạn, sau đó nhấp vào

Xcode - Editor - Structure -> Add Documentation. 

/** 
<#Description#> 
*/ 

Lưu tập tin, hoặc đơn giản là khởi động lại Xcode. Sau đó kiểm tra gợi ý trong khi gọi hàm tương ứng. Tôi hy vọng điều này có thể hữu ích.

Các vấn đề liên quan