Code Monkey home page Code Monkey logo

apexdoc's Introduction

This project and repository are no longer maintained by Salesforce.org

ApexDoc

ApexDoc is a java app that you can use to document your Salesforce Apex classes. You tell ApexDoc where your class files are, and it will generate a set of static HTML pages that fully document each class, including its properties and methods. Each static HTML page will include an expandable menu on its left hand side, that shows a 2-level tree structure of all of your classes. Command line parameters allow you to control many aspects of ApexDoc, such as providing your own banner HTML for the pages to use.

Credits

ApexDoc was originally created by Aslam Bari (http://techsahre.blogspot.com/2011/01/apexdoc-salesforce-code-documentation.html). It was then taken and extended by David Habib, at Groundwire, in 2011. It has subsequently been enhanced by David Habib of the Salesforce Foundation in late 2014 for use with Nonprofit Success Pack (https://github.com/SalesforceFoundation/Cumulus). We are unable to offer direct support of reported issues or incorporate enhancement requests at this time, however pull requests are welcome.

Command Line Parameters

parameter description
-s source_directory The folder location which contains your apex .cls classes.
-t target_directory The folder location where documentation will be generated to.
-g source_url A URL where the source is hosted (so ApexDoc can provide links to your source). Optional.
-h home_page The full path to an html file that contains the contents for the home page's content area. Optional.
-a banner_page The full path to an html file that contains the content for the banner section of each generated page. Optional.
-p scope A semicolon separated list of scopes to document. Defaults to 'global;public;webService'. Optional.

Usage

Copy apexdoc.jar file to your local machine, somewhere on your path. Each release tag in gitHub has the matching apexdoc.jar attached to it. Make sure that java is on your path. Invoke ApexDoc like this example:

java -jar apexdoc.jar
    -s '/Users/dhabib/Workspaces/Force.com IDE/Cumulus3/src/classes'
    -t '/Users/dhabib/Dropbox/Cumulus/ApexDoc'
    -p 'global;public;private;testmethod;webService'
    -h '/Users/dhabib/Dropbox/Cumulus/ApexDoc/homepage.htm'
    -a '/Users/dhabib/Dropbox/Cumulus/ApexDoc/projectheader.htm'
    -g 'http://github.com/SalesforceFoundation/Cumulus/blob/dev/src/classes/'

Documenting Class Files

ApexDoc scans each class file, and looks for comment blocks with special keywords to identify the documentation to include for a given class, property, or method. The comment blocks must always begin with /** (or additional *'s) and can cover multiple lines. Each line must start with * (or whitespace and then *). The comment block ends with */. Special tokens are called out with @token.

Class Comments

Located in the lines above the class declaration. The special tokens are all optional.

token description
@author the author of the class
@date the date the class was first implemented
@group a group to display this class under, in the menu hierarchy
@group-content a relative path to a static html file that provides content about the group
@description one or more lines that provide an overview of the class

Example

/**
* @author Salesforce.com Foundation
* @date 2014
*
* @group Accounts
* @group-content ../../ApexDocContent/Accounts.htm
*
* @description Trigger Handler on Accounts that handles ensuring the correct system flags are set on
* our special accounts (Household, One-to-One), and also detects changes on Household Account that requires
* name updating.
*/
public with sharing class ACCT_Accounts_TDTM extends TDTM_Runnable {

Property Comments

Located in the lines above a property. The special tokens are all optional.

token description
@description one or more lines that describe the property

Example

    /*******************************************************************************************************
    * @description specifies whether state and country picklists are enabled in this org.
    * returns true if enabled.
    */
    public static Boolean isStateCountryPicklistsEnabled {
        get {

Method Comments

In order for ApexDoc to identify class methods, the method line must contain an explicit scope (global, public, private, testMethod, webService). The comment block is located in the lines above a method. The special tokens are all optional.

token description
@description one or more lines that provide an overview of the method
@param param name a description of what the parameter does
@return a description of the return value from the method
@example Example code usage. This will be wrapped in tags to preserve whitespace
Example
    /*******************************************************************************************************
    * @description Returns field describe data
    * @param objectName the name of the object to look up
    * @param fieldName the name of the field to look up
    * @return the describe field result for the given field
    * @example
    * Account a = new Account();
    */
    public static Schema.DescribeFieldResult getFieldDescribe(String objectName, String fieldName) {

apexdoc's People

Contributors

hiradimir avatar jjbennett avatar openback avatar robertbwatson avatar svc-scm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

apexdoc's Issues

support dynamic filtering by scope

allow the user to turn on/off all of the scopes they built the docset with, including global, public, private, testMethod, webService.

any issues with handling block starting with /* vs /** ?

ApexDoc was requiring slash star star, but that meant it mistakenly parsed keywords (class, public, global, etc.) in a normal comment. I changed the parser to handle just slash star, and that resolved the incorrect parsing. Any problems with this?

Invalid Arguments detected (NullPointerException)

Executing the program breaks with NullPointerException in ClassModel#compare. Paths given are relative to apexdoc.jar, which is in my project root (also tried absolute paths). The two html paths given in the parameters do exist.

The same error occurs when providing only the -s and -t flags (and only the -s flag), except that it shows nine lines of Error: null instead of two.

System: OS X El Capitan 10.11.3

$ java -version
java version "1.8.0_31"
Java(TM) SE Runtime Environment (build 1.8.0_31-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.31-b07, mixed mode)
$ java -jar apexdoc.jar -s ./src/classes \
    -t ./docs \
    -p 'global;public;private;testmethod;webService' \
    -g https://example.com/repo/src/classes \
    -h ./homepage.html \
    -a ./projectheader.html
Error: null
Error: null
java.lang.NullPointerException
    at org.salesforce.apexdoc.ClassModel$1.compare(ClassModel.java:55)
    at org.salesforce.apexdoc.ClassModel$1.compare(ClassModel.java:1)
    at java.util.TimSort.binarySort(TimSort.java:292)
    at java.util.TimSort.sort(TimSort.java:217)
    at java.util.Arrays.sort(Arrays.java:1512)
    at java.util.ArrayList.sort(ArrayList.java:1454)
    at java.util.Collections.sort(Collections.java:175)
    at org.salesforce.apexdoc.ClassModel.getMethodsSorted(ClassModel.java:48)
    at org.salesforce.apexdoc.FileManager.htmlForClassModel(FileManager.java:217)
    at org.salesforce.apexdoc.FileManager.makeFile(FileManager.java:143)
    at org.salesforce.apexdoc.FileManager.createDoc(FileManager.java:429)
    at org.salesforce.apexdoc.ApexDoc.RunApexDoc(ApexDoc.java:128)
    at org.salesforce.apexdoc.ApexDoc.main(ApexDoc.java:36)
null
ApexDoc - a tool for generating documentation from Salesforce Apex code class files.

    Invalid Arguments detected.  The correct syntax is:

apexdoc -s <source_directory> [-t <target_directory>] [-g <source_url>] [-h <homefile>] [-a <authorfile>] [-p <scope>]

<source_directory> - The folder location which contains your apex .cls classes
<target_directory> - Optional. Specifies your target folder where documentation will be generated.
<source_url> - Optional. Specifies a URL where the source is hosted (so ApexDoc can provide links to your source).
<homefile> - Optional. Specifies the html file that contains the contents for the home page's content area.
<authorfile> - Optional. Specifies the text file that contains project information for the documentation header.
<scope> - Optional. Semicolon seperated list of scopes to document.  Defaults to 'global;public'.

Will not install and run - Eclipse Mars 4.5.1.

Doesn't work when dropped into plugins or dropins directory, doesn't work when Eclipse run as admin, doesn't work when source downloaded and plug-in development installed. No context menu under any conditions.

Home content and banner pages

Is there an example of working home content and banner pages? It seems to ignore them, whether the content is bounded by <html></html> or not.

In case of multiple constructors only one shows in ApexDoc

If I create a class with multiple constructors then only one constructor is displayed in ApexDoc.

For example, ApexDoc produced using below code includes only the second constructor (one with a parameter) in the documentation.

global class ProgramService {
/*******************************************************************************************************

  • @description A private constructor to prevent object creation without connection context.
    /
    private ProgramService() {
    }
    /
    ******************************************************************************************************
  • @description Constructor for this class that requires a connection context.
    */
    global ProgramService(string serviceConnectionContext) {}

}

remove expand/collapse support

we decided that the expand/collapse ui on the pages is non-standard and not useful. we've decided to make ApexDoc more similar to Salesforce Apex documentation.

Nested Classes not supported

If you have a class defined within another class, its definition is ignored, and any methods and properties of the nested class are documented along with the documentation for the outer class.

provide better visuals to differentiate scope of classes, methods, and properties

currently, one must expand the method list to see the full method signature. It would be nice if in the collapsed state, the method name bars had some sort of visual to indicate scope.

we could potentially do something similar in the class menu. I currently am just using color of the class (blue = global, black = public, gray = private).

Splitting the method parameter name & description should allow any whitespace

This took me a bit to figure out why the first word of the description kept showing up with the parameter name styling but it seems like ApexDoc is looking for the first space, not just white space. Since I and many I work with like to separate the name and description with a tab, it would be helpful to split on any white space character.

Running Apexdoc w/o the -p scope tag set results in a runtime error

kbromer-ltm:Workspace kbromer$ java -jar apexdoc.jar 
-s '/Users/kbromer/Workspace/Cumulus/src/classes' 
-t '/Users/kbromer/Workspace/Cumulus_Apexdoc_Test' 
-g 'http://github.com/SalesforceFoundation/Cumulus/blob/dev/src/classes/'

java.lang.ArrayIndexOutOfBoundsException: 3
at org.salesforce.apexdoc.ApexDoc.RunApexDoc(ApexDoc.java:87)
at org.salesforce.apexdoc.ApexDoc.main(ApexDoc.java:34)

Works fine if I include the optional param

Support For Whitelisted HTML Tag Passthrough

I'm not sure if this is intended or not, but HTML tags will pass through for only the brief description of a method, but not for the full method description. To be more specific...

In the method htmlForClassModel() in FileManager.java, when generating the HTML for <div class="methodTOCDescription">, escapeHTML() is NOT called, but when generating the HTML for <div class="methodDescription">, escapeHTML() IS called.

I understand this is a bit tricky because you want to be able to support < and > being shown in the documentation and not embedded as html tags, but it's a bit confusing that it will pass tags through for one part and escape them in another.

As for the passthrough, perhaps escapeHTML() in FileManager.java could be overloaded to accept an array of whitelisted ignore-tags which you know won't mess up the structure of the generated doc. Then, depending on what part of the doc you are generating when you call escapeHTML() you can toss in different acceptable tags like <code>, <ul>, <ol>, <li>, <pre>, <p> and maybe <b>, <i>.

Possible object customization support enhancement

Add another level to navigation menu, to divide into classes and object customizations (and optionally triggers). Use metadata API to retrieve information about object customizations, including comments, and produce object customizations and custom objects report on separate html page.

Refactor the project to a more structured style

Right now the bulk of the project exists in one directory. This is fine for the current project size but will inhibit growth in the future. Enhancements like tests (Issue #39), build systems (Issue #38), or 3rd party libraries (Issue #33) would only become messy with our current set up.

Banner option missing

The readme mentions the option -a banner_page, but that seems to not actually exist.

Switch the html file construction over to a templating engine

Right now, html for the pages is constructed using string concatenation. Not only can this be expensive but it makes handling issues and enhancements on the page more difficult than it needs to be. I propose using a templating engine to separate the html from the logic.

Provide option to not document classes, methods, and properties that do not have a comment block.

Currently, ApexDoc will include in the documentation set all classes, methods, and properties that are of the specified scope(s).

Some users may prefer to only have it generate documentation for classes, methods, and properties that have a comment block.

It would be nice to provide an option (command line flag, and PlugIn checkbox) to control this behavior.

Feb 6, 2013 Delete comment #1 [email protected]
The skip-undocumented option is useful when documenting the global classes in a managed package, and there are some utility classes that are not included in the package.

Space in if statement causes error

I was getting an invalid argument error. I narrowed it down to a single if statement in one of my files.

An error shows up when this statement has spaces between c.commentPublic and !=
This works: if(c.commentPublic!=null){
This does not work: if(c.commentPublic !=null){

Version 1.1.5
Error log
java.lang.NullPointerException
at org.salesforce.apexdoc.ClassModel$1.compare(ClassModel.java:55)
at org.salesforce.apexdoc.ClassModel$1.compare(ClassModel.java:1)
at java.util.TimSort.countRunAndMakeAscending(TimSort.java:360)
at java.util.TimSort.sort(TimSort.java:220)
at java.util.Arrays.sort(Arrays.java:1512)
at java.util.ArrayList.sort(ArrayList.java:1454)
at java.util.Collections.sort(Collections.java:175)
at org.salesforce.apexdoc.ClassModel.getMethodsSorted(ClassModel.java:48)
at org.salesforce.apexdoc.FileManager.htmlForClassModel(FileManager.java:217)
at org.salesforce.apexdoc.FileManager.makeFile(FileManager.java:143)
at org.salesforce.apexdoc.FileManager.createDoc(FileManager.java:429)
at org.salesforce.apexdoc.ApexDoc.RunApexDoc(ApexDoc.java:128)
at org.salesforce.apexdoc.ApexDoc.main(ApexDoc.java:36)

Invalid Arguments detected.

Getting error as

Invalid Arguments detected.

i am running below command from command prompt

java -jar apexdoc.jar -s 'C:\workspace\SalesForce\src\classes' -t 'C:\Desktop\Purpose Documents'

support collapsing class groups in the menu

currently, when you click on the class group name, it shows the list of classes in the group, and displays the class group content file. but if you click on the class group name again, it just refreshes to the same state. it would be preferable if it would collapse its group, but still stay on its content file. this would make ease of use better.

<obj>'s on return values and parameters get dropped

looks like the ApexDoc parsing doesn't handle <'s >'s on return values and parameters. I did do a fix to get them handled on class names, so I need to see what was added, and add it to additional code.

Add unit tests

With the complex parsing taking place, I feel that there would be a real benefit to adding unit tests. This would help reassure a developer (especially one just getting started with the code) that a change will not break anything. Tests are never a 100% guarantee but it is way better than nothing.

Possible trigger support enhancement

Add another level to main navigation menu to separate classes, triggers (optionally object customizations and custom objects). Add a runtime switch to locate triggers. Add parsing code to determine trigger firing conditions.

Overloaded methods should be supported

ApexDoc can end up hiding methods that are overloaded, only showing the last one. If you are using these docs to communicate your api, then this is a pretty big loss.

Start using Apache Maven

I haven't seen any instructions on how this project is built but judging by the lack of either a pom.xml or a build.xml file, I would hazard that it is done by hand. This process can be enhanced by using a system like Apache Maven. This would make cutting a new release simple and repeatable.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.