function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
paul-lmipaul-lmi 

Using javadoc to generate Apex code documentation

Is anyone doing this successfully?  We're at a point where I'd like to migrate from just using regular code comments to using full blown javadoc-accessible documentation, to make it easier and more appealing for our devs to reuse code.

 

Can anyone provide any examples of generating javadoc html from the .cls files stored by Eclipse?

gv007gv007
we are also trying to do that ,and able find any tool.if you find something let us know
paul-lmipaul-lmi
i'm looking at doxygen too.  the problem is, apex is "like" java, but it isn't quite java, so these java-based interpreters are getting fould up on syntax differences.
mmenaframmenafra

Hello,

 

We have also encountered this problem and haven't been able to find a third party tool which could generate JavaDoc style documentation.

 

So having said that we took it upon our selfs to create such a plugin in Java. This is still a work in progress, but what I can say is that it will comply with all standard JavaDoc tags ( including some new ones we've added ), will create a HTML base API documentation similar to Javadoc, it will be able to run as a standalone app or installed as a Eclipse plugin.

 

We have high hopes for this and as soon as it enters a beta testing phase , it will be publicly available to everyone.

 

So i'll keep everyone posted on the progress of this.

 

piz 

 

paul-lmipaul-lmi

hi,

 

were you able to make any headway here?

dke01dke01

@ mmenafra

 

Did you make any more progress on this yet?



gv007gv007

Anybody found any solution.

aslamaslam

Hi All,

I created one tool, this may be what you need.

 

http://www.aslambari.com/apexdoc.html

 

Thanks

Aslam Bari

tomcollinstomcollins

I was disappointed with ApexDoc, since it's trying to be Doxygen/javadoc from scratch.  It's a very simple parser that wouldn't even match my "@param" tag since it didn't have a "* " in front of it.

 

Here's a question I've posted on Stack Overflow that will hopefully get some responses.

 

In my opinion, getting Doxygen to generate documentation is the way to go.  Whether we accomplish that with changes to Doxygen, or tools to convert an Apex .cls file to a dummy Java .java file that Doxygen can handle, I don't know.

 

-Tom

LesKLesK

We had some code, tried ApexDoc and didn't like it  since we wrote javadoc and were too lazy  smart to change it.

 

So... we added some SED and got this cobbled together - This fits out use case, but could def. be refined. What follows is a BASH script that should work if you're running a Mac. 

 

#! /bin/bash

# Clean the directory up and transfer files. 
# I create a dir called 'doc' in my Eclipse project.
rm *.html
rm *.css
rm -r resources/
rm *.java
cp ../src/classes/*.cls .

# Change the file endings from .cls to .java
for file in *.cls ; do mv $file ${file%.cls}.java ; done

# Pre-Processing the .java files
# 1.) Escape double quotes inside single quotes. 
# Since they are never outside of single quote, just escape 'em
sed -i '' 's/\"/\\\"/g' *.java

# 2.) Remove single quotes and replace with double quotes.
sed -i '' s/\'/\"/g *.java

# 3.) Remove the { get; set; } and replace with a ";"
sed -i '' 's/{ get; set; }/;/g' *.java

# 4.) Remove keywords such as "virtual", "override", "with sharing", etc...
sed -i '' 's/virtual//g' *.java
sed -i '' 's/override//g' *.java
sed -i '' 's/with sharing//g' *.java
sed -i '' 's/testmethod//g' *.java

# 5.) Remove lines with System.assert...
sed -i '' '/System\.assert/d' *.java

# 6.) Remove lines with [SELECT] style queries
sed -i '' '/\[SELECT/d' *.java

# Javadoc it... 
javadoc *.java

# "Post-process" files to remove "java.lang" references. ;) Sshh...
sed -i '' 's/java\.lang\.//g' *.html

# Remove the java.lang.Object inherited methods.
sed -i '' 's/clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait//g' *.html

 

(That last sed command should be all on one line...)

scox67scox67

I've made some improvements to ApexDoc. Check out the writeup here:http://scox67.blogspot.com/2013/08/sf-apexdoc.html.

In a nutshell, SfApexDoc:

 

  1. Parses javadoc-style comments and creates HTML documentation
  2. recognizes standard tags such as @description, @author, @date, @return, @param, @see.
  3. creates links to standard Apex types as well as your own classes
  4. includes full class, method, and property signatures - even those that span multiple lines.

I'm actively working on fixing issues and adding features, so please send me a note if you find problems.

docbilldocbill
If you use a script like:

find src -name \*.cls -print0 |xargs -0 -n 100 perl -pi.bak -e 'undef $/; s/(\s+)(with\s+sharing|without\s+sharing|testmethod)(\s+)/$1$3/gi; s/(\n[ \t]*)([^\n]*?)(\w+)(\s*\{\s*(private\s+|public\s+|protected\s+|)(get|set)\s*[;\{])/$1$2$3;$1private class Mutator_$3$4/ig; s/([\{\};]\s*)(private\s+|public\s+|)get(\s*[\{\};])/$1$2Object get()$3/ig; s/([;\{\}]\s*)(private\s+|public\s+|)set(\s*[;\{\}])/$1$2void set(Object value)$3/ig'

and use the following settings in doxygen:

EXTENSION_MAPPING      = cls=Javascript
FILE_PATTERNS          = *.cls

Then doxygen will produce reasonable output.   The setters and getters are what confuse doxygen most, and the script takes care of that.  Most of the other attibutes are seem to work fine in javascript mode, as well as using the apostrophe for strings.   There is probably some usage this still misses.   If find when doxygen gets confused it simply stops parsing the rest of the file.


 
scox67scox67
Hey all - I just posted a new version of SfApexDoc (https://gitlab.com/StevenWCox/sfapexdoc/wikis/home). Check out the release notes (https://gitlab.com/StevenWCox/sfapexdoc/wikis/ReleaseNotes), documentation format (https://gitlab.com/StevenWCox/sfapexdoc/wikis/DocFormat), and usage details (https://gitlab.com/StevenWCox/sfapexdoc/wikis/Usage).
  • parses javadoc-style comments and creates HTML documentation
  • recognizes standard tags such as @description, @author, @date, @return, @param, @see, and @throws
  • creates links to standard Apex types as well as your own classes
  • includes full class, method, and property signatures - even those that span multiple lines
  • allows customization of output styling