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.

Standardize API docs

See original GitHub issue

Today the standard in which the different APIs are documented varies quite a bit throughout the documentation. For consistency, it would be best to align on one way to document each API method.

Here’s a proposal given in the form of an example of a documented API method where the first argument is required and the two latter arguments are optional. The style is mainly inspired by the official Node.js documentation.

[[apm-my-function]]
==== `agent.myFunction(foo[, options][, callback])`

[small]#Added in: v1.2.3#

* `foo` {uri-number}[`<number>`] Some description of this argument.
* `options` {uri-object}[`<Object>`]
** `bar` {uri-string}[`<string>`] Some description of this argument. **Default:** 42.
** `baz` {uri-boolean}[`<boolean>`] | {uri-symbol}[`<symbol>`] Some description of this argument.
* `callback` {uri-function}[`<Function>`]
** `err` {uri-error}[`<Error>`]
** `exitCode` {uri-number}[`<integer>`]
* Returns: <<agent-api,`<Agent>`>>

Full description goes here...

Somewhere central we need to define these attributes:

:uri-number: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type
:uri-string: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type
:uri-boolean: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type
:uri-symbol: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Symbol_type
:uri-object: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object
:uri-function: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function
:uri-error: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error

Here’s the rendered result:

image

Obviously, this documentation could maybe be generated based on a TypeScript Declaration File or JSDoc. So we should consider that as well. The TypeScript file would only have the signatures and types of course, but nothing of the actual documentation, so that might be a no-go.

@Qard @bmorelli25: What do you think?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:13 (13 by maintainers)

github_iconTop GitHub Comments

1reaction
watsoncommented, Mar 27, 2019

Let’s not spend too much time researching the “Added in” field for now. We can add those later in separate PRs.

0reactions
watsoncommented, Mar 27, 2019

I’ve removed the discuss label as I think we’ve reached a conclusion. Let’s go ahead with this 💯

Read more comments on GitHub >

github_iconTop Results From Across the Web

The Importance of Standardized API Design - Swagger
Design standards are meant to be a set of design recommendations and best practices for use across all APIs within a company. These...
Read more >
Standardizing API Documentation - MEGAComm
Covering the major programming API languages and technologies, such as Java, JavaScript, MS.NET, REST and OData, and based on the widely adopted industry ......
Read more >
What to consider when standardizing your REST APIs - Courier
Standardization helps your users avoid bugs and code debt. As with most things in life, when it comes to writing a REST API,...
Read more >
Standardizing API Documentation For Use Across The API ...
This demonstrates for me the importance of API documentation, not just in helping API consumers understand what an API does at integration time, ......
Read more >
Standardize API best practices across multiple teams and ...
A platform dedicated to connectivity. Gravitee supports API Management and Standardization across traditional and modern protocols and querying technologies.
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