HOME

TheInfoList



OR:

In programming, a docblock or DocBlock is a specially formatted
comment Comment may refer to: * Comment (linguistics) or rheme, that which is said about the topic (theme) of a sentence * Bernard Comment (born 1960), Swiss writer and publisher Computing * Comment (computer programming), explanatory text or informat ...
specified in
source code In computing, source code, or simply code, is any collection of code, with or without comment (computer programming), comments, written using a human-readable programming language, usually as plain text. The source code of a Computer program, p ...
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

/** * 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


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

/** * 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

## # 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 { a + b }


See also

*
Docstring In programming, a docstring is a string literal specified in source code that is used, like a comment, to document a specific segment of code. Unlike conventional source code comments, or even specifically formatted comments like docblocks, docs ...
– Language-specific non-volatile documentation *
Comparison of documentation generators The following tables compare general and technical information for a number of documentation generators. Please see the individual products' articles for further information. Unless otherwise specified in footnotes, comparisons are based on the ...
Programming constructs Software documentation String (computer science)