Jump to content
Ian Branch

Procedure/Function Commenting..

Recommended Posts

Hi Team,

Like most of us I have my own local pattern procedure/function library.

I have been commenting them like this:

Quote

/// <summary>
/// Determines whether any of the specified bits are set in a given bitmask.
/// </summary>
/// <param name="bits">The bitmask to check.</param>
/// <param name="positions">An array of bit positions to check.</param>
/// <returns>True if any of the specified bits are set, False otherwise.</returns>
/// <remarks>
/// - Validates inputs to ensure meaningful results.
/// - Efficiently iterates through positions using a for loop.
/// - Uses bitwise AND and left-shift operations to check individual bits.
/// - Exits early if a matching bit is found, optimizing performance.
/// </remarks>

What this gives me then is a dropdown when I hover over the procedure/finction in my code that looks something like this:

image.thumb.png.c8286c1565403fa0ca800570be53c664.png

All very handy and a useful reminder of the procedure/function definition.

I forget where I got this from.   😞

Can somebody point me to where this style of documentation/technique is documented please?

 

Regards & TIA,

Ian

Share this post


Link to post
20 minutes ago, Ian Branch said:

Can somebody point me to where this style of documentation/technique is documented please?

https://docwiki.embarcadero.com/RADStudio/Athens/en/XML_Documentation_Comments

 

There are also tools that can help in writing those, so you don't have to do that manually, like https://devjetsoftware.com/products/documentation-insight/

Share this post


Link to post

There are also some code templates in Delphi to simplify writing these comments: summary, params, returns, remarks

 

Share this post


Link to post

It might be worth noting that XML documentation tags also work inside a normal Delphi comment (enclosed in braces {}) instead of these horrible triple slash comments copied from C# along with the XML tags themselves. Much easier to maintain in my opinion if a tag content spans several lines.

Share this post


Link to post
20 minutes ago, PeterBelow said:

It might be worth noting that XML documentation tags also work inside a normal Delphi comment (enclosed in braces {}) instead of these horrible triple slash comments copied from C# along with the XML tags themselves. Much easier to maintain in my opinion if a tag content spans several lines.

If only the triple slash was the only horrible thing about it. Whoever came up with using XML tags when there was already a working solution with a lot less noise like PasDoc? (based on JavaDoc). Especially since XML in many other areas has already been superseeded with methods that also produce less noise, e.g. JSON.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×