{"id":1275,"date":"2023-11-06T05:16:32","date_gmt":"2023-11-06T05:16:32","guid":{"rendered":"https:\/\/www.devopssupport.in\/blog\/?p=1275"},"modified":"2023-11-24T05:23:17","modified_gmt":"2023-11-24T05:23:17","slug":"how-to-do-file-level-commenting","status":"publish","type":"post","link":"https:\/\/www.devopssupport.in\/blog\/how-to-do-file-level-commenting\/","title":{"rendered":"How to do file-level commenting"},"content":{"rendered":"\n<p>Effective file-level commenting is an art that elevates your code from functional to comprehensible. Whether you are a seasoned developer or a rookie, incorporating these practices will not only make your code more understandable but also foster a collaborative coding environment. When it comes to coding, clarity is key. Both when using someone else&#8217;s code and sharing your own, effective communication is essential. File-level commenting is a powerful tool that aids not only in understanding your code but also in creating a seamless collaborative environment.<\/p>\n\n\n\n<p>the world of file-level comments by exploring a traditional yet effective way of commenting. We&#8217;ll be using JavaScript for illustration, but the principles discussed can be applied across various programming languages.<\/p>\n\n\n\n<p>In JavaScript, a comment block is typically denoted by the opening and closing of a multi-line comment.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/**\r\n * Your comments go here\r\n *\/\r\n<\/code><\/pre>\n\n\n\n<p>This block provides a canvas for detailed explanations and documentation. To make the commenting process even more structured and insightful, we can introduce tags. In Visual Studio Code (VSCode), prefixing a comment block with &#8220;@&#8221; prompts the editor to suggest relevant tags for documentation.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Syntax Styling<\/h2>\n\n\n\n<p>Before delving into tags, let&#8217;s explore some styling options within the comment block using Markdown-like syntax:<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Headings<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>#<\/code> for H1<\/li>\n\n\n\n<li><code>##<\/code> for H2<\/li>\n\n\n\n<li><code>###<\/code> for H3<\/li>\n\n\n\n<li><code>####<\/code> for H4<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Text Styles<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>**your text**<\/code> for bold<\/li>\n\n\n\n<li><code>*your text*<\/code> for italic<\/li>\n\n\n\n<li><code>~~your text~~<\/code> for strikethrough<\/li>\n\n\n\n<li><code>some text [link](https:\/\/google.com)<\/code> for adding a link<\/li>\n\n\n\n<li><code>- list item<\/code> for creating a list<\/li>\n\n\n\n<li><code>![image](image-url.png)<\/code> for adding an image<\/li>\n\n\n\n<li><code>&gt; some text<\/code> for creating a quote<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Code<\/h3>\n\n\n\n<p>To include code in your comment block with syntax highlighting.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>if (isAwesome){\r\n  return true\r\n}\r\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Table<\/h3>\n\n\n\n<p>To add a table block.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>First Header | Second Header\r\n------------ | -------------\r\nContent from cell 1 | Content from cell 2\r\nContent in the first column | Content in the second column\r\n<\/code><\/pre>\n\n\n\n<p>These Markdown-like tags enhance the visual appeal and structure of your comments.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Useful Tags<\/h2>\n\n\n\n<p>Now, let&#8217;s explore some handy tags that add functionality to our comments:<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><code>@param<\/code><\/h3>\n\n\n\n<p>Use <code>@param<\/code> to provide information about the parameters a function requires.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@param {string} queryString - A string value needed to query\r\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><code>@returns<\/code><\/h3>\n\n\n\n<p>Use <code>@returns<\/code> to specify what the method is returning.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@returns {boolean} - Whatever the method is returning\r\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><code>@link<\/code><\/h3>\n\n\n\n<p>Attach any internal\/external link to your comment easily.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>{@link file#makePublic} - Enable access to this method\r\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><code>@example<\/code><\/h3>\n\n\n\n<p>Auto-style code with <code>@example<\/code>.<\/p>\n\n\n\n<p>@example<br>readFile((chunk) =&gt; {<br>\/\/ do other processing for chunks<br>console.log(chunk)<br>})<br>.then((data) =&gt; {<br>\/\/ final processing of content<br>console.log(data)<br>})<br>.catch((e) =&gt; console.log({ e }));<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Other Handy Options<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>@class<\/code><\/li>\n\n\n\n<li><code>@private<\/code><\/li>\n\n\n\n<li><code>@const<\/code><\/li>\n\n\n\n<li><code>@see<\/code><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Effective file-level commenting is an art that elevates your code from functional to comprehensible. Whether you are a seasoned developer or a rookie, incorporating these practices will&#8230; <\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[519,518,520],"class_list":["post-1275","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-file-level-commenting","tag-how-to-do-file-level-commenting","tag-syntax-styling"],"_links":{"self":[{"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/posts\/1275","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/comments?post=1275"}],"version-history":[{"count":1,"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/posts\/1275\/revisions"}],"predecessor-version":[{"id":1276,"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/posts\/1275\/revisions\/1276"}],"wp:attachment":[{"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/media?parent=1275"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/categories?post=1275"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/tags?post=1275"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}