question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

RFC: Support for dot syntax on @param

See original GitHub issue

I’m currently working with d.ts files where methods taking object parameters are documented with the following approach:

/**
* Method description.
* @param options addItemOptions - e.g. { id: 1234, title: "someTitle" }
*             id: The unique identifier.
*             title: The title to assign.
**/

It’s challenging to parse and auto-generate documentation for these parameters given this approach. Ideally there’d be support for dot syntax e.g.:

@param options.id - The unique identifier.
@param options.title - The title to assign.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:43
  • Comments:19 (2 by maintainers)

github_iconTop GitHub Comments

17reactions
dschnarecommented, Nov 27, 2018

What’s more of a pain to document is destructured arguments:

/**
 * Call home.
 * @remarks
 * This texts Mom a message.
 * @param message - The message to send to Mom
 * @param ? - The number of seconds to delay calling home
 * @public
 */
function callHome (message: string, { delay = 0 }: { delay?: number } = {}) {
  // TODO: send a text to Mom!
  throw new Error('Unimplemented')
}
11reactions
octogonzcommented, May 26, 2018

For APIs intended for third parties, generally we recommend to give a name to the interface, for example:

/** Options for {@link ItemCollection.add} */
interface IAddItemOptions {
  /** the identifier */
  id: string;
  /** a title, not to exceed 40 characters */
  title: string;
}

class ItemCollection {
  /**
   *  Adds an item to the collection
   * @param options - information about the item to be added
   */
  public add(options: IAddItemOptions): void {
  }
}

Naming the interface improves the structure of the documentation. It also helps developers when they need to work with the object independently, for example:

const options: IAddItemOptions = this.getOptions();
collection1.add(options);
collection2.add(options);

That said, I believe TypeDoc supports the @param options.id notation. If people find it useful, we could include it in the TSDoc standard.

Read more comments on GitHub >

github_iconTop Results From Across the Web

RFC 6381 - The 'Codecs' and 'Profiles' Parameters for "Bucket ...
This document obsoletes RFC 4281; RFC 4281 defines the 'codecs' parameter, ... if it will be sufficient to support a subset of the...
Read more >
RFC 3986: Uniform Resource Identifier (URI): Generic Syntax
The URI syntax defines a grammar that is a superset of all valid URIs, ... access mechanism and the appropriate parameters necessary to...
Read more >
Parameter Serialization - Swagger
Path parameters support the following style values: simple – (default) comma-separated values. Corresponds to the {param_name} URI template. label – dot- ...
Read more >
Postfix Configuration Parameters
These parameters support the same filter syntax as described here. ... The Postfix implementation of RFC 2308 negative reply caching relies on the...
Read more >
Protocol Registries - Internet Assigned Numbers Authority
Protocol parameter registries represent the authoritative record of many of ... Distributed Denial-of-Service Open Threat Signaling (DOTS) Signal Channel.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found