Skip to content
This repository was archived by the owner on Jun 1, 2023. It is now read-only.
This repository was archived by the owner on Jun 1, 2023. It is now read-only.

Strange results with extensions and types in same file. #34

@crayment

Description

@crayment

Thanks this looks awesome! I did a quick test and I think I found some bugs.

I created a new Swift package and put the following in the source file:

/// Says hello
public func sayHello() {
    print("Hello!")
}

public extension NSNumber {
    /// Does this number represent a Bool
    public var isBool: Bool { return CFBooleanGetTypeID() == CFGetTypeID(self) }
}

public extension Result where Failure == Error {
    /// Converts a throwing block into a Result
    /// If any error is thrown a failure result is returned with the error. Otherwise success with the blocks return value.
    public static func of(_ block: () throws -> Success) -> Result<Success, Error> {
        do {
            return try .success(block())
        } catch {
            return .failure(error)
        }
    }
}

/**
 The default generated struct!
 */
struct spm_test {
    var text = "Hello, World!"
}

When I run the generator via swift doc generate Sources --module-name spm-test I get the following:

Home.md

# Types

  - [NSNumber.Result.spm\_test](NSNumber_Result_spm_test)

# Operators

  - [sayHello()](sayHello\(\))

NSNumber_Result_spm_test.md

# NSNumber.Result.spm\_test

The default generated struct\!

``` swift
struct spm_test
```

## Properties

## text

``` swift
var text = "Hello, World!"
```

sayHello().md

# sayHello()

## sayHello()

Says hello

``` swift
public func sayHello()
```

I think there are three bugs here:

  1. Notice how the spm_test struct is nested under the NSNumber and Result types.
  2. I don't get any docs for the public extensions.
  3. The top level sayHello function is documented as an operator.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions