How to include Doxygen method description in Xcode's autocomplete popup?

前端 未结 3 1185
眼角桃花
眼角桃花 2020-12-07 21:21

Using Xcode , I want to have the Doxygen description of my method below the autocomplete option, like alloc:

相关标签:
3条回答
  • 2020-12-07 21:43

    What I have found to be better than a code snippet for Doxygen/Javadoc style comments is using VVDocumenter-Xcode Plugin It is great! After installing you can simply type "///" above any code you want commented and it will grab the parameters and return as well add placeholders for you to complete your comment block.

    0 讨论(0)
  • 2020-12-07 21:44

    Good news everyone! Xcode 5 now has built-in support for DOxygen style comments. So, you can comment your methods like this:

    /*!
     * Provides an NSManagedObjectContext singleton appropriate for use on the main 
     * thread. If the context doesn't already exist it is created and bound to the 
     * persistent store coordinator for the application, otherwise the existing 
     * singleton contextis returned.
     * \param someParameter You can even add parameters
     * \returns The a shared NSManagedObjectContext for the application.
     */
    + (NSManagedObjectContext *)sharedContext;
    


    Inline help will look like this:

    inline help



    Quick help will look like this:

    quick help



    And sidebar help will look like this:

    sidebar help

    Here's a handy code snippet you can add the your Xcode Code Snippet library to make method documentation simple:

    /**
     <#description#>
     @param <#parameter#>
     @returns <#retval#>
     @exception <#throws#>
     */
    

    doxygen code snippet

    Now, you can just type "doxy" and poof! You have your doxygen template.

    0 讨论(0)
  • 2020-12-07 22:08

    I was able to achieve what I wanted using Appledocs, although I fought a bit with installation and setup...

    1. Open xCode and go to xCode> Preferences > Downloads and download the 'Command Line Tools' in case you don't have it.
    2. Open up terminal and type

      git clone git://github.com/tomaz/appledoc.git
      
    3. When it's done go to the appledoc folder, type

      cd appledoc
      

      and install appledoc into your usr/local/bin folder with this command:

      sudo sh install-appledoc.sh 
      
    4. Open any xCode project and go to the package explorer on the left, and click on your main project file (the one that has the amount of targets and the sdk version detailed below)

    5. In the Build settings tab, look below for '+Add Target' button and open it

    6. Choose the 'Aggregate' template (make sure you choose iOS or macosx depending on your project and name it 'Documentation'

    7. Select Documentation, go to Build Phases tab, and below click 'Add Build Phase' and select Add Run Script.

    8. Copy and paste the code below on the Run Script field:

      #appledoc Xcode script
      # Start constants
      company="ACME";
      companyID="com.ACME";
      companyURL="http://ACME.com";
      #target="iphoneos";
      target="macosx";
      outputPath="~/help";
      # End constants
      /usr/local/bin/appledoc \
      --project-name "${PROJECT_NAME}" \
      --project-company "${company}" \
      --company-id "${companyID}" \
      --docset-atom-filename "${company}.atom" \
      --docset-feed-url "${companyURL}/${company}/%DOCSETATOMFILENAME" \
      --docset-package-url "${companyURL}/${company}/%DOCSETPACKAGEFILENAME" \
      --docset-fallback-url "${companyURL}/${company}" \
      --output "${outputPath}" \
      --publish-docset \
      --docset-platform-family "${target}" \
      --logformat xcode \
      --keep-intermediate-files \
      --no-repeat-first-par \
      --no-warn-invalid-crossref \
      --exit-threshold 2 \
      "${PROJECT_DIR}"
      
    9. In the start constants, you can replace names and such, also make sure to use the proper target (iOS or macosx)

    10. Finally, go to Product > Scheme > Edit Scheme > Build Tab and add your 'Documentation' Target, make sure every box is checked. This way each time you build your code your documentation gets updated.

    And that's it, you are good to go and start documenting your code. Note that although the documentation updates each time you build, the popover suggestions won't update until you restart Xcode. For proper documentation techniques, read this article

    0 讨论(0)
提交回复
热议问题