logo

NJP

Introducing SNDoc - A better way to document your code

Import · Nov 13, 2018 · article

At UP3 Services, we have been discussing the best ways in which we can work together as a team on projects, specifically for developers. We have all, at some point, found ourselves in a situation where our code bases get large and difficult to manage, with functional code spread far and wide across the ServiceNow platform, in some cases this code remains un commented and forgotten about.

We began to think about solutions to this problem, some way of keeping track of the often-reusable code, so we turned to Script Includes. Script Includes are a feature of ServiceNow that we at UP3 have been using for quite some time, but we recently made a conscious effort to try and use them wherever possible to contain application specific logic and therefore keeping our codebase in one place.

The next challenge was to make sure that the code, in what were growing Script Includes remained relevant and in a state that any developer could come along and know what the specific methods could and could not be used for, so we turned to comments, but of course in a large script include, it can still become difficult to find exactly what it is that you’re looking for. We needed a better solution.

Introducing SNDoc. After 6 months of iterations we are proud to be able to share with the ServiceNow Developer community a new way of keeping control over your script includes. I’m sure many, if not all, of you have visited the ServiceNow API documentation at some stage, whether it be to refresh your memory on the little used GlideRecord method, or to read up on a new API you’ve not used before. SNDoc aims to replicate the look and feel of the already familiar ServiceNow documentation. By now You’re probably wondering how this can be possible with custom written code, and the answer is structured commenting. Those with a background in JavaScript will no doubt have heard of JSDoc, the standard in JavaScript documentation. The issue with JSDoc though is that it’s offline, it’s certainly not built for the ServiceNow platform and setups people have documented in the past have always been tricky to get running and keep updated.

SNDoc is built for the ServiceNow platform, and while it doesn’t claim to be as advanced as JSDoc, it’s got some nifty features, including dependency discovery. It’s been built as an extensible framework, so if you have a need for a new tag in your comments, you can simply create one.

Head over to Share to download your copy. We would love your feedback on it, especially if you have feature requests.

image

View original source

https://www.servicenow.com/community/developer-articles/introducing-sndoc-a-better-way-to-document-your-code/ta-p/2319914