cesarParra / apexdocs

Node.js tool to generate documentation for your Salesforce Apex Classes.
https://www.npmjs.com/package/@cparra/apexdocs
MIT License
102 stars 18 forks source link

Issue with test class parsing #50

Closed Kenji776 closed 2 years ago

Kenji776 commented 2 years ago

Hey there. I just updated to the new version and now I'm having issues when generating documentation for test classes. It seems to be choking on the @isTest annotation.

Running command: apexdocs-generate -s input -t temp\markdown\

5/17/2022, 2:55:43 PM: Parsing error Exception: Error parsing Apex Body. Line 2:0 - no viable alternative at input '@isTest\n/** \n* @Name StripeIntegrationWrapperTest\n* \n* @Date 2/28/2022\n* @Group Stripe Integration\n* @See StripeIntegrationWrapper\n* @Description Test class for StripeIntegrationWrapper\n**/'
5/17/2022, 2:55:44 PM: Parsing error Exception: Error parsing Apex Body. Line 2:0 - no viable alternative at input '@isTest\n/** \n* @Name StripeRESTServiceTest\n* \n* @Date 3/2/2022\n* @Group Stripe Integration\n* @See StripeRESTService\n* @Description Test class for StripeRESTService. Ensures all methos in the class work as expected.\n**/'
5/17/2022, 2:55:44 PM: Parsed 1 files
StripeRESTService - Doc comment parsing error. Level: Type
Comment:
 /**
* @Name StripeRESTService
* @Date 3/2/2022
* @Group Stripe Integration
* @See StripeRESTServiceTest
* @Description Apex class that creates and exposes a REST endpoint by the name of 'Stripe'. [ORG_URL]/services/apexrest/Stripe (case sensitive!)
* 
*
cesarParra commented 2 years ago

Thanks @Kenji776

The issue seems to be when the annotation is on top of the doc block, rather than right on top of the class/method it belongs to. I'm investigating

cesarParra commented 2 years ago

I've added support to have the annotations before and/or after the doc block in the latest release (v2.2.5). Hopefully that resolves the issue.

Kenji776 commented 2 years ago

@cesarParra Thank you for the quick update. I am sorry to be a pain, but it looks like there is still a problem. It's saying line 3 has a . which it doesn't like. That may be the . in my email address I have in the author line as that is line 3 of the source file.

`Running command: apexdocs-generate -s input -t temp\markdown\ Markdown files generated successfully 5/18/2022, 12:13:54 PM: Parsed 1 files StripeRESTService - Doc comment parsing error. Level: Type Comment: /**

cesarParra commented 2 years ago

Thanks @Kenji776

The issue for this one is that it thinks that the @ in the email address is the start of a brand new tag, and it is complaining about the tag name containing a dot.

I'll see what can be done about this.

cesarParra commented 2 years ago

@Kenji776

I've somewhat addressed this in the latest release (v2.3.0). I say somewhat because I had to make some compromises because I wanted to still be able to support single line docs, but it was difficult to distinguish between what was an email address vs. what was a doc tag because of the @ symbol.

What I did was add support for emails to be embedded within a new inline tag: {@email EMAIL_ADDRESS}, similar to what the {@link CLASS_NAME} does for classes.

So now something like this can be done:

/**
 * @description My Class
 * @contact {@email someone@example.com}
 */
class MyClass {}

Let me know if that sounds good and if you have any suggestions on things to improve for this.


On a different note, from your sample docs I see you have some descriptions that get pretty long, so I've also added support for some HTML tags (<br>, <p></p>, <ul></ul>, and <li></li> that might help you with the output, so it's not just one long paragraph, in case you are interested in using that. The release notes has more info: https://github.com/cesarParra/apexdocs/releases/tag/v2.3.0

Thanks for the feedback!

Kenji776 commented 2 years ago

@cesarParra Great, thanks for the update. I like the email format idea, that's slick. I'll give it a test here soon.

cesarParra commented 2 years ago

Closing this for now. Please feel free to reopen if you find any issues or suggestions for things to improve.