Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undocumented structures should show Swift declaration #141

Closed
juangamnik opened this issue Jan 6, 2015 · 15 comments
Closed

Undocumented structures should show Swift declaration #141

juangamnik opened this issue Jan 6, 2015 · 15 comments

Comments

@juangamnik
Copy link

Since #129 every undocumented structure has now a text "Undocumented" like here:
jazzy_undoc

But if I add some really meaningless documentation I get much more information (the Swift declaration):
jazzy_decl

So why not use the declaration instead of the meaningless notion "Undocumented" (I would just omit it).

@segiddins
Copy link
Collaborator

The issue here seems to be that SoureKit won't return any documentation XML when the declaration is undocumented. (See https://github.com/Realm/jazzy/blob/master/lib/jazzy/sourcekitten.rb#L97).

@juangamnik
Copy link
Author

Uh. That's bad. But https://github.com/Realm/jazzy/blob/master/lib/jazzy/sourcekitten.rb#L96 (one line before) seems to access key.doc.full_as_xml. Perhaps there is another key, for directly accessing the declaration?

Or can the declaration documentation be directly created from the declaration info? The corresponding information should be their, shouldn't it?

@juangamnik
Copy link
Author

Anything on this? The "Undocumented"-text is unfortunately not very informative and the "Declaration" would be very helpful.

@jpsim
Copy link
Collaborator

jpsim commented Apr 27, 2015

I have not worked on this functionality lately, but you're of course welcome to do so. This part of jazzy's functionality is in SourceKitten.

@juangamnik
Copy link
Author

@jpsim: I would, but unfortunately I'm neither familiar with ruby, nor with the project itself (from the source code point-of-view). Especially, if it is not an easy one (missing information from SourceKit as @segiddins said), which needs some digging in. My first approach would perhaps be to add some whitespace fake-documentation to each undocumented declaration (or even the word "Undocumented") in transient a preprocessing step ...

@jpsim
Copy link
Collaborator

jpsim commented Apr 27, 2015

SourceKitten is actually 100% written in Swift. You can find the repo here: https://github.com/jpsim/SourceKitten

@juangamnik
Copy link
Author

Oh, cool. I'll look into it as soon as I can. Thanks.

@blochberger
Copy link

blochberger commented Aug 1, 2016

Interestingly if you have a documented class declaration and an undocumented member function, then the class declaration is shown as declaration for the member function, which is just erroneous:

///
class Something {
    func doSomething() {
        
    }
}

The class documentation will render as:

Something

class Something

and the member function declaration of doSomething() will render as:

Undocumented

Declaration

class Something

Adding an empty documentation explicitly will show the correct declaration, but will mess up documentation coverage:

///
class Something {
    ///
    func doSomething() {
        
    }
}

@pigeondotdev
Copy link
Contributor

From my understanding, this bug is related to SourceKit which is out of our hands. I've tagged the issue with blocked and I'm going to close the issue. Feel free to reopen if you disagree or have more to say about it.

@jpsim
Copy link
Collaborator

jpsim commented Nov 26, 2016

Not exactly out of our hands, just more work!

@jpsim jpsim reopened this Nov 26, 2016
@pigeondotdev
Copy link
Contributor

Oh okay! Sweet, my apologies.

@juangamnik
Copy link
Author

Phew, great. Was a bit anxious, that that's it (especially as I had no time yet to look into it and it doesn't look better in the near future)

@rcbello
Copy link

rcbello commented Jan 18, 2017

Hi, I am not sure if there is already a fix on the way for this issue but I am using this fix on my copy of jazzy.
In sourcekitten.rb, I modified self.make.doc.info to

 def self.make_doc_info(doc, declaration)
      return unless should_document?(doc)

      declaration.declaration = Highlighter.highlight(
        doc['key.parsed_declaration'] || doc['key.doc.declaration'],
        Config.instance.objc_mode ? 'objc' : 'swift',
      )
      if Config.instance.objc_mode && doc['key.swift_declaration']
        declaration.other_language_declaration = Highlighter.highlight(
          doc['key.swift_declaration'], 'swift'
        )
      end

      unless doc['key.doc.full_as_xml']
        return process_undocumented_token(doc, declaration)
      end
      ...

from

 def self.make_doc_info(doc, declaration)
      return unless should_document?(doc)

      unless doc['key.doc.full_as_xml']
        return process_undocumented_token(doc, declaration)
      end

      declaration.declaration = Highlighter.highlight(
        doc['key.parsed_declaration'] || doc['key.doc.declaration'],
        Config.instance.objc_mode ? 'objc' : 'swift',
      )
      if Config.instance.objc_mode && doc['key.swift_declaration']
        declaration.other_language_declaration = Highlighter.highlight(
          doc['key.swift_declaration'], 'swift'
        )
      end
     ...

I just moved the check and handling of undocumented structure to come after adding its declaration.
I have zero experience in Ruby so I'm putting it here to see if this is the right change or if this is the right place in the code to change.

rcbello added a commit to rcbello/jazzy that referenced this issue Jan 18, 2017
@johnfairh
Copy link
Collaborator

Fixed in master via #897.

@juangamnik
Copy link
Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants