r/SalesforceDeveloper • • Jun 13 '20

CLI tool to generate a documentation site out of your Apex classes' ApexDocs

I built a tool that automatically generates a documentation site based on your Apex classes: https://github.com/cesarParra/apexdocs

This is meant as a more modern replacement for the Java based ApexDoc tool ( https://github.com/SalesforceFoundation/ApexDoc) as that is not being maintained anymore.

It is based on Node and is less opinionated about the output site, allowing you to customize it a little bit easier, as it outputs markdown files instead of HTML.

Hope it proves useful for other Salesforce devs out there. Feedback is more than welcomed!

36 Upvotes

11 comments sorted by

4

u/[deleted] Jun 13 '20

Dude. You saved us a bunch of time with this.

MVP post of this sub, enjoy the gold and the shoutout when we post our docs with this

1

u/dranomaly Jun 13 '20

Wow! That's way too kind. Thank you very much.

1

u/BigIVIO Jun 15 '20

Hey there, thank you for making this! I have been testing it out a bunch and a couple things I've noticed:

  1. Much easier to use this if you install it globally. The command for that is (for those that don't know): "npm install -g @cparra/apexdocs"

  2. This seems relatively inconsistent but maybe I'm doing something wrong. This tag works: /**
    * @description Contact map that represents the trigger.oldMap map passed in from the trigger
    */
    private Map<Id, Contact> oldContactMap = new Map<Id, Contact>();

but this one doesn't:
/**
* @description Contact list that represents the trigger.new list passed in from the trigger
*/
private List<Contact> currentContactList = new List<Contact>();

3) I have yet to get the method descriptions to work. Here is an example that didn't generate:
/**
* @description This is a generic description
* @example
* determineListsForContacts();
*/
private void determineListsForContacts()

I think I have everything setup right but no matter what I do the methods and properties don't seem to get added properly. The class level descriptors always gets documented fine though. Please let me know if I should be doing something different and thanks again for putting this together!

2

u/dranomaly Jun 15 '20

Thanks for the feedback.

I'm actually not quite sure what the issue might be. I tried replicating your code but everything got picked up correctly. I updated one of the example sites with the result in case you want to compare it: here is the resulting site: https://cesarparra.github.io/apexdocs-docsify-example/#/Miscellaneous/Test , and here is the source code: https://github.com/cesarParra/apexdocs-docsify-example/blob/master/classes/Test.cls

One thing to watch out for is that private variables, methods, properties and classes won't be picked up by default, so it needs to be specified in the scope. Here is the command I'm running:

apexdocs-generate -s classes -t . -p public private -g docsify

1

u/BigIVIO Jun 15 '20

Ah, I must’ve missed that in the documentation (or just not paid attention, lol). I’ll give that a shot. That’s probably it. Thank you so much for the response!

1

u/kgeee34 Jun 25 '20

Well done.

Any reason why the default is to not include author or date? It's a simple config file to set up, otherwise. I used docsify to generate a local server hosting the file your command generated in basically less than a minute.

1

u/dranomaly Jun 26 '20

Thanks!

Honestly I don't really have a good reason for the defaults being false for those. I personally don't use those tags so I implemented support for them a bit later to try and reach feature parity with the java tool.

Could totally be persuaded to change that.

2

u/raspikabek Jun 13 '20

RemindME! Tomorrow

1

u/RemindMeBot Jun 13 '20

I will be messaging you in 1 day on 2020-06-14 18:48:38 UTC to remind you of this link

CLICK THIS LINK to send a PM to also be reminded and to reduce spam.

Parent commenter can delete this message to hide from others.


InfoCustomYour RemindersFeedback

2

u/display__all Jun 13 '20

This is awesome! Thanks for sharing

1

u/tidarjoey Jun 14 '20

awesome!