Syntax for documenting JSON structure

In theory JSON Schema could serve this purpose, but in practice I am not sure it does. Worth mentioning I hope. Other than this, my personal opinion is that since JSON is predominantly used for transferring objects, documenting equivalent objects in language client uses (Java, C#, various scripting languages) may make most sense — after … Read more

How to document magic (_call and _callStatic) methods for IDEs

Use class-level PHPDoc comment — specifically @method tag — works fine in PhpStorm: /** * @method static someClass get_by_user_id(int $id) Bla-bla * @method static someClass get_first_by_id(int $id) */ abstract class a { … In the above: @method — PHPDoc tag static — tells that this is static method someClass or $this — return type get_by_user_id … Read more

How to document fields and properties in Python?

Python has a PEP (257) that defines Docstring Conventions. Regarding documentation of attributes, it states: String literals occurring immediately after a simple assignment at the top level of a module, class, or __init__ method are called “attribute docstrings”. So the following are considered documented attributes: class Foo(object): velocity = 1 “””Foo’s initial velocity – class … Read more

How to specify resolution and rejection type of the promise in JSDoc?

Even if they don’t exist in Javascript, I found that JSdoc understands “generic types”. So you can define your custom types and then use /* @return Promise<MyType> */. The following result in a nice TokenConsume(token) → {Promise.<Token>} with a link to your custom Token type in the doc. /** * @typedef Token * @property {bool} … Read more

Ways to synchronize interface and implementation comments in C#

You can do this quite easily using the Microsoft Sandcastle (or NDoc) inheritdoc tag. It’s not officially supported by the specification, but custom tags are perfectly acceptable, and indeed Microsoft chose to copy this (and one or two other tags) from NDoc when they created Sandcastle. /// <inheritdoc/> /// <remarks> /// You can still specify … Read more