Looking for documentation/insight on .swiftdoc

Hello, I’m curious about the swiftdoc format. I’ve looked through the swift codebase and have been unable to find either documentation about it or the relevant source code. Could somebody point me in the right direction? I’m thinking about building a swift documentation viewer and want to figure out if I would have to extract docs from source by hand, or if I can leverage the compiler in some way to do the parsing and document syntax rendering.

Thank you,
George

It’s a serialized format, emitted by Serialization::writeDocToStream(), here:

  https://github.com/apple/swift/blob/master/lib/Serialization/Serialization.cpp#L4656-L4678

It would be a pain to write another client to read the binary format. Better would be to use SourceKit to walk the compiler’s AST and ask for the documentation for the various declarations.

  - Doug

···

On Oct 23, 2017, at 11:27 AM, George King via swift-dev <swift-dev@swift.org> wrote:

Hello, I’m curious about the swiftdoc format. I’ve looked through the swift codebase and have been unable to find either documentation about it or the relevant source code. Could somebody point me in the right direction? I’m thinking about building a swift documentation viewer and want to figure out if I would have to extract docs from source by hand, or if I can leverage the compiler in some way to do the parsing and document syntax rendering.

Or libSyntax!

~Robert Widmann

···

On Oct 24, 2017, at 4:06 PM, Douglas Gregor via swift-dev <swift-dev@swift.org> wrote:

On Oct 23, 2017, at 11:27 AM, George King via swift-dev <swift-dev@swift.org> wrote:

Hello, I’m curious about the swiftdoc format. I’ve looked through the swift codebase and have been unable to find either documentation about it or the relevant source code. Could somebody point me in the right direction? I’m thinking about building a swift documentation viewer and want to figure out if I would have to extract docs from source by hand, or if I can leverage the compiler in some way to do the parsing and document syntax rendering.

It’s a serialized format, emitted by Serialization::writeDocToStream(), here:

  https://github.com/apple/swift/blob/master/lib/Serialization/Serialization.cpp#L4656-L4678

It would be a pain to write another client to read the binary format. Better would be to use SourceKit to walk the compiler’s AST and ask for the documentation for the various declarations.

  - Doug

_______________________________________________
swift-dev mailing list
swift-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-dev

Or libSyntax!

If it doesn’t do comments yet… it certainly should!

  - Doug

···

On Oct 24, 2017, at 3:05 PM, Robert Widmann <devteam.codafi@gmail.com> wrote:

~Robert Widmann

On Oct 24, 2017, at 4:06 PM, Douglas Gregor via swift-dev <swift-dev@swift.org> wrote:

On Oct 23, 2017, at 11:27 AM, George King via swift-dev <swift-dev@swift.org> wrote:

Hello, I’m curious about the swiftdoc format. I’ve looked through the swift codebase and have been unable to find either documentation about it or the relevant source code. Could somebody point me in the right direction? I’m thinking about building a swift documentation viewer and want to figure out if I would have to extract docs from source by hand, or if I can leverage the compiler in some way to do the parsing and document syntax rendering.

It’s a serialized format, emitted by Serialization::writeDocToStream(), here:

  https://github.com/apple/swift/blob/master/lib/Serialization/Serialization.cpp#L4656-L4678

It would be a pain to write another client to read the binary format. Better would be to use SourceKit to walk the compiler’s AST and ask for the documentation for the various declarations.

  - Doug

_______________________________________________
swift-dev mailing list
swift-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-dev

Thanks for the pointers. Doug, I take it from your initial comment that there is no matching “readDocFromStream”? (I don’t see one in Deserialization.cpp). If not, then what consumes the swiftdoc files?

···

On Oct 24, 2017, at 6:09 PM, Douglas Gregor <dgregor@apple.com> wrote:

On Oct 24, 2017, at 3:05 PM, Robert Widmann <devteam.codafi@gmail.com> wrote:

Or libSyntax!

If it doesn’t do comments yet… it certainly should!

  - Doug

~Robert Widmann

On Oct 24, 2017, at 4:06 PM, Douglas Gregor via swift-dev <swift-dev@swift.org> wrote:

On Oct 23, 2017, at 11:27 AM, George King via swift-dev <swift-dev@swift.org> wrote:

Hello, I’m curious about the swiftdoc format. I’ve looked through the swift codebase and have been unable to find either documentation about it or the relevant source code. Could somebody point me in the right direction? I’m thinking about building a swift documentation viewer and want to figure out if I would have to extract docs from source by hand, or if I can leverage the compiler in some way to do the parsing and document syntax rendering.

It’s a serialized format, emitted by Serialization::writeDocToStream(), here:

  https://github.com/apple/swift/blob/master/lib/Serialization/Serialization.cpp#L4656-L4678

It would be a pain to write another client to read the binary format. Better would be to use SourceKit to walk the compiler’s AST and ask for the documentation for the various declarations.

  - Doug

_______________________________________________
swift-dev mailing list
swift-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-dev

1 Like

Just have the same requirements here, any suggestion @Douglas_Gregor ?