Back to all reviewers

Follow Swift conventions

tensorflow/swift
Based on 2 comments
Markdown

When designing and documenting APIs in Swift, adhere to Swift's established naming conventions and documentation practices: 1. **Use correct initializer syntax**: Swift initializers should not form phrases with argument labels. Avoid prepositions in argument labels.

API Markdown

Reviewer Prompt

When designing and documenting APIs in Swift, adhere to Swift’s established naming conventions and documentation practices:

  1. Use correct initializer syntax: Swift initializers should not form phrases with argument labels. Avoid prepositions in argument labels.

    // Incorrect
    let tensor = Tensor(fromNumpyArray: array)
       
    // Correct
    let tensor = Tensor(numpy: array)
    
  2. Document APIs completely: When referencing APIs in documentation, include both the original framework name and the complete Swift method signature with parameter names.

    // Incomplete
    The saveV2 and restoreV2 ops are now supported.
       
    // Complete
    `SaveV2` (`Raw.saveV2(prefix:tensorNames:shapeAndSlices:tensors:)`), `RestoreV2` (`Raw.restoreV2(prefix:tensorNames:shapeAndSlices:dtypes:)`)
    
  3. Use official terminology: Maintain consistent terminology across documentation and code (e.g., use “operator” instead of “op”).

  4. Add API links: Where possible, include links to API documentation to enhance discoverability and understanding.

These practices ensure that your APIs are consistent with Swift ecosystem standards, making them more intuitive and discoverable for developers.

2
Comments Analyzed
Markdown
Primary Language
API
Category

Source Discussions