Docblock Explained

In programming, a docblock or DocBlock is a specially formatted comment specified in source code that is used to document a specific segment of code. This makes the DocBlock format independent of the target language (as long as it supports comments); however, it may also lead to multiple or inconsistent standards.

Implementation examples

C#

///

Adds two integers together./// First integer./// Second integer./// Sum of integers a and b.int Sum(int a, int b)

Java

See main article: Javadoc.

/** * Adds two integers together * * @param a First integer * @param b Second integer * @return Sum of integers a and b */int sum(int a, int b)

PHP

See main article: PHPDoc.

Python

def sum(a: int, b: int) -> int """Adds two integers together.

Args: a: First integer. b: Second integer.

Returns: Sum of the two integers. """ return a + b

JavaScript

See main article: JSDoc.

/** * Adds two numbers together. * @param a First number. * @param b Second number. * @returns Sum of numbers a and b */ const add = (a, b) => a + b;

Ruby

See main article: RDoc.

      1. This class represents an arbitrary shape by a series of points.

class Shape

## # Creates a new shape described by a +polyline+. # # If the +polyline+ does not end at the same point it started at the # first pointed is copied and placed at the end of the line. # # An ArgumentError is raised if the line crosses itself, but shapes may # be concave.

def initialize polyline # ... end

end

Rust

/// Adds two numbers together.////// # Examples////// ```/// let result = sum(5, 5);/// ```fn sum(a: u64, b: u64) -> u64

See also