Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I show C++ code documentation in Xcode 9.3?

I´m developing software based on C++ in Xcode and want to have (at least) the same convenience for code documentation as if I was developing for Swift or objc.

Example:

std::string myString("hello");
if (myString.empty()) {
    // do something
}

If I want to know exactly what .empty() does, I would like to Option-Click on the function and get the documentation overlay with information from e.g. http://en.cppreference.com/w/cpp/string/basic_string/empty, exactly as it does for objc and Swift.

How is this possible?

Current output just looks like this: enter image description here

like image 875
stk Avatar asked May 04 '18 12:05

stk


People also ask

How do I add documents to Xcode?

You can use ⌥ + ⌘ + / (option + command + ) to add function documentation.

How do I use DocC in Xcode?

Building DocC DocumentationOpen the Product menu, and select Build Documentation. Xcode starts building the documentation for a few seconds, and then the Developer Documentation window opens. The project's documentation appears on the left Navigator.

How do you code a document in Swift?

Type /// or /** */ to begin a documentation comment and then use DocC's special dialect of Markdown to write the content. This dialect supports many keywords like - Parameters: for describing function arguments or - Returns: for describing return values.


2 Answers

You cannot. According to Apple's Xcode release notes, as of Xcode 8.3

3rd party docset support is now deprecated and will no longer be supported in a future release of Xcode. (30584489)

There are alternate doc browsers, like Dash which allow you to install your own documentation. But this does not give you what you're hoping for.

I have verified that adding a C++.docset into ~/Library/Developer/Shared/Documentation does not work. (likely a directory left over from an earlier Xcode) In fact, removing this directory entirely does not affect Xcode 9.x from correctly displaying the default documentation.

like image 134
christopherdrum Avatar answered Oct 15 '22 17:10

christopherdrum


This is for your custom class. You can add your comment like this - in the header I do this

 /**
     * Method name: name
     * Description: returns name
     * Parameters: none
     */

here is a sample I did -

#ifndef test_hpp
#define test_hpp

#include <iostream>
#include <string>

class myclass{
private:
    std::string name_;

public:

    myclass(std::string);
    /**
     * Method name: name
     * Description: returns name
     * Parameters: none
     */
    std::string name();
};

#endif /* test_hpp */

enter image description here

like image 5
Deb S Avatar answered Oct 15 '22 17:10

Deb S