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

前端 未结 3 1219
眼角桃花
眼角桃花 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 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

提交回复
热议问题