documentalist icon indicating copy to clipboard operation
documentalist copied to clipboard

Duplicate documentation found when forward-referencing a class

Open jspahrsummers opened this issue 10 years ago • 14 comments

This header excerpt:

@class RACStream;

/// A block which accepts a value from a RACStream and returns a new instance
/// of the same stream class.
///
/// Setting `stop` to `YES` will cause the bind to terminate after the returned
/// value. Returning `nil` will result in immediate termination.
typedef RACStream * (^RACStreamBindBlock)(id value, BOOL *stop);

/// An abstract class representing any stream of values.
///
/// This class represents a monad, upon which many stream-based operations can
/// be built.
///
/// When subclassing RACStream, only the methods in the main @interface body need
/// to be overridden.
@interface RACStream : NSObject

results in two documented entries for RACStream:

DecNode (Just 
    # Summary: An abstract class representing any stream of values.
    # Description:
    This class represents a monad, upon which many stream-based operations can
    be built.

    When subclassing RACStream, only the methods in the main @interface body need
    to be overridden.
) `RACStream` (Class []) [],
DecLeaf (Just 
    # Summary: A block which accepts a value from a RACStream and returns a new instance
    of the same stream class.
    # Description:
    Setting `stop` to `YES` will cause the bind to terminate after the returned
    value. Returning `nil` will result in immediate termination.
) `RACStreamBindBlock` (TypeAlias `foobar`),
DecNode (Just 
    # Summary: An abstract class representing any stream of values.
    # Description:
    This class represents a monad, upon which many stream-based operations can
    be built.

    When subclassing RACStream, only the methods in the main @interface body need
    to be overridden.
) `RACStream` (Class []) […]

The second one is the only one with inner declarations, so that's what we should keep.

jspahrsummers avatar Aug 27 '13 07:08 jspahrsummers

Do you want to return Nothing if it is a Class or Protocol with no inside? In parseDecl. I think this is fair enough for now, because

@class MXObject : NSObject
// Nothing!
@end

is a really edge case. Does this occur in RAC even?

mxswd avatar Aug 27 '13 07:08 mxswd

An empty class is completely valid. One does occur in RAC (though only after stripping a deprecated declaration):

// Represents one end of a RACChannel.
//
// An terminal is similar to a socket or pipe -- it represents one end of
// a connection (the RACChannel, in this case). Values sent to this terminal
// will _not_ be received by its subscribers. Instead, the values will be sent
// to the subscribers of the RACChannel's _other_ terminal.
//
// For example, when using the `followingTerminal`, _sent_ values can only be
// _received_ from the `leadingTerminal`, and vice versa.
//
// To make it easy to terminate a RACChannel, `error` and `completed` events
// sent to either terminal will be received by the subscribers of _both_
// terminals.
//
// Do not instantiate this class directly. Create a RACChannel instead.
@interface RACChannelTerminal : RACSignal <RACSubscriber>
@end

jspahrsummers avatar Aug 27 '13 07:08 jspahrsummers

Ah ok then. Does clang have something to see if it is a forward declaration?

mxswd avatar Aug 27 '13 07:08 mxswd

Probably. I've just been reading clang-c/Index.h to find stuff like that.

jspahrsummers avatar Aug 27 '13 07:08 jspahrsummers

clang_getCanonicalCursor?

mxswd avatar Aug 27 '13 07:08 mxswd

Yeah, I might throw that in.

mxswd avatar Aug 27 '13 07:08 mxswd

I'm stuck. :/ I can't figure out how to compare them to see if this cursor is pointing to the canonical cursor.

mxswd avatar Aug 27 '13 07:08 mxswd

There's a clang_equalCursors() function.

jspahrsummers avatar Aug 27 '13 08:08 jspahrsummers

This doesn't work. Everything is a canonicalCursor (or not). https://github.com/jspahrsummers/documentalist/commit/f781bb2d4a8b0da32082211b682ccc4c372b562c :stuck_out_tongue_closed_eyes: (with FFI.isCanonical cxCursor == 0 or FFI.isCanonical cxCursor /= 0).

mxswd avatar Aug 27 '13 08:08 mxswd

Should we fold them and take the one with the most decls?…

mxswd avatar Aug 27 '13 08:08 mxswd

Should we fold them and take the one with the most decls?

Yeah, I think that should work.

jspahrsummers avatar Aug 27 '13 08:08 jspahrsummers

'clang_getCursorDefinition' looks like it will do it! I'm going to try it tomorrow.

mxswd avatar Aug 27 '13 15:08 mxswd

I can't get super classes out in Class $ super objcClassRef ++ super objcProtocolRef ++ super firstRef. They are all (Class []). Did you have any luck?

mxswd avatar Aug 28 '13 02:08 mxswd

I meant to file that and forgot. See #34.

jspahrsummers avatar Aug 28 '13 02:08 jspahrsummers