Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Standardization of our documentation comments #12912

Merged
24 commits merged into from
Dec 17, 2020
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
7d3107c
[ESLint plugin] Use TSDoc plugin
deyaaeldeen Dec 15, 2020
65480b6
Fix tsdoc issues in abort-controller
deyaaeldeen Dec 15, 2020
e1dfdfa
Fix tsdoc issues in logger
deyaaeldeen Dec 15, 2020
76352ca
Fix tsdoc issues in core-tracing
deyaaeldeen Dec 15, 2020
7a1f774
Fix tsdoc issues in core-lro
deyaaeldeen Dec 15, 2020
bbbb801
Fix tsdoc issues in core-auth
deyaaeldeen Dec 15, 2020
e9616d3
Fix tsdoc issues in core-http
deyaaeldeen Dec 15, 2020
29ceb4a
Fix tsdoc issues in identity
deyaaeldeen Dec 15, 2020
f8cee2a
Fix tsdoc issues in keyvault-secrets
deyaaeldeen Dec 15, 2020
ffb4336
Fix tsdoc issues in keyvault-certificates
deyaaeldeen Dec 15, 2020
7fe51c4
Fix tsdoc issues in keyvault-keys
deyaaeldeen Dec 15, 2020
a6d015c
Fix tsdoc issues in keyvault-common
deyaaeldeen Dec 15, 2020
365d315
Fix tsdoc issues in keyvault-admin
deyaaeldeen Dec 15, 2020
8e21687
Fix tsdoc issues in schemaregistery
deyaaeldeen Dec 15, 2020
463b5e9
Fix tsdoc issues in textanalytics
deyaaeldeen Dec 15, 2020
0669122
Fix tsdoc issues in anomalydetector
deyaaeldeen Dec 15, 2020
a940843
Fix tsdoc issues in formrecognizer
deyaaeldeen Dec 15, 2020
bf40c44
Fix tsdoc issues in metricsadvisor
deyaaeldeen Dec 15, 2020
3197ed1
Fix tsdoc issues in tables
deyaaeldeen Dec 15, 2020
5084c10
Fix tsdoc issues in eventgrid
deyaaeldeen Dec 15, 2020
37ce528
adding hidden tag
deyaaeldeen Dec 16, 2020
ec0b33c
adding --stripInternal to ignore definitions tagged with @internal
deyaaeldeen Dec 16, 2020
f3c3c94
replace deleted @ignore with @hidden
deyaaeldeen Dec 16, 2020
8a471bb
adding tsdoc.json to packages that use @hidden
deyaaeldeen Dec 17, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions common/config/rush/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion common/tools/eslint-plugin-azure-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@
"@typescript-eslint/parser": "^4.9.0",
"eslint": "^7.15.0",
"eslint-plugin-no-only-tests": "^2.4.0",
"eslint-plugin-promise": "^4.2.1"
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-tsdoc": "^0.2.10"
},
"dependencies": {
"@typescript-eslint/typescript-estree": "^4.9.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default {
sourceType: "module",
extraFileExtensions: [".json"]
},
plugins: ["@typescript-eslint", "no-only-tests", "promise"],
plugins: ["@typescript-eslint", "no-only-tests", "promise", "eslint-plugin-tsdoc"],
extends: [
"plugin:@typescript-eslint/recommended",
"eslint:recommended",
Expand Down Expand Up @@ -111,6 +111,7 @@ export default {
// https://github.com/Azure/azure-sdk-for-js/issues/7609
"@azure/azure-sdk/ts-pagination-list": "off",
// https://github.com/Azure/azure-sdk-for-js/issues/7610
"@azure/azure-sdk/ts-doc-internal": "off"
"@azure/azure-sdk/ts-doc-internal": "off",
"tsdoc/syntax": "error"
}
};
1 change: 1 addition & 0 deletions eng/tools/generate-doc/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ const executeTypedoc = async (exclusionList, inclusionList, generateIndexWithTem
"--excludeNotExported",
'--exclude "node_modules/**/*"',
"--ignoreCompilerErrors",
"--stripInternal",
"--mode file",
docOutputFolder,
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ export class AnomalyDetectorClient {

/**
* @internal
* @ignore
* A reference to the auto-generated AnomalyDetector HTTP client.
*/
private client: GeneratedClient;
Expand All @@ -61,9 +60,9 @@ export class AnomalyDetectorClient {
* new AzureKeyCredential("<api key>")
* );
* ```
* @param string endpointUrl Url to an Azure Anomaly Detector service endpoint
* @param {TokenCredential | KeyCredential} credential Used to authenticate requests to the service.
* @param FormRecognizerClientOptions options Used to configure the Form Recognizer client.
* @param endpointUrl - Url to an Azure Anomaly Detector service endpoint
* @param credential - Used to authenticate requests to the service.
* @param options - Used to configure the Form Recognizer client.
*/
constructor(
endpointUrl: string,
Expand Down Expand Up @@ -107,9 +106,9 @@ export class AnomalyDetectorClient {
* This operation generates a model using an entire series, each point is detected with the same model.
* With this method, points before and after a certain point are used to determine whether it is an
* anomaly. The entire detection can give user an overall status of the time series.
* @param body Time series points and period if needed. Advanced model parameters can also be set in
* @param body - Time series points and period if needed. Advanced model parameters can also be set in
* the request.
* @param options The options parameters.
* @param options - The options parameters.
*/
public detectEntireSeries(
body: DetectRequest,
Expand Down Expand Up @@ -138,9 +137,9 @@ export class AnomalyDetectorClient {
* This operation generates a model using points before the latest one. With this method, only
* historical points are used to determine whether the target point is an anomaly. The latest point
* detecting operation matches the scenario of real-time monitoring of business metrics.
* @param body Time series points and period if needed. Advanced model parameters can also be set in
* @param body - Time series points and period if needed. Advanced model parameters can also be set in
* the request.
* @param options The options parameters.
* @param options - The options parameters.
*/
public detectLastPoint(
body: DetectRequest,
Expand All @@ -167,9 +166,9 @@ export class AnomalyDetectorClient {

/**
* Evaluate change point score of every series point
* @param body Time series points and granularity is needed. Advanced model parameters can also be set
* @param body - Time series points and granularity is needed. Advanced model parameters can also be set
* in the request if needed.
* @param options The options parameters.
* @param options - The options parameters.
*/
detectChangePoint(
body: DetectChangePointRequest,
Expand Down
2 changes: 1 addition & 1 deletion sdk/anomalydetector/ai-anomaly-detector/src/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
import { createClientLogger } from "@azure/logger";

/**
* The @azure/logger configuration for this package.
* The \@azure/logger configuration for this package.
*/
export const logger = createClientLogger("ai-anomaly-detector");
4 changes: 2 additions & 2 deletions sdk/anomalydetector/ai-anomaly-detector/src/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export interface DetectRequest {
*/
granularity: TimeGranularity;
/**
* Custom Interval is used to set non-standard time interval, for example, if the series is 5 minutes, request can be set as {"granularity":"minutely", "customInterval":5}.
* Custom Interval is used to set non-standard time interval, for example, if the series is 5 minutes, request can be set as `{"granularity":"minutely", "customInterval":5}`.
*/
customInterval?: number;
/**
Expand All @@ -77,7 +77,7 @@ export interface DetectChangePointRequest {
*/
granularity: TimeGranularity;
/**
* Custom Interval is used to set non-standard time interval, for example, if the series is 5 minutes, request can be set as {"granularity":"minutely", "customInterval":5}.
* Custom Interval is used to set non-standard time interval, for example, if the series is 5 minutes, request can be set as `{"granularity":"minutely", "customInterval":5}`.
*/
customInterval?: number;
/**
Expand Down
6 changes: 3 additions & 3 deletions sdk/anomalydetector/ai-anomaly-detector/src/tracing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import { OperationOptions } from "@azure/core-http";

/**
* Creates a span using the global tracer.
* @ignore
* @param name The name of the operation being performed.
* @param tracingOptions The options for the underlying http request.
* @internal
* @param name - The name of the operation being performed.
* @param tracingOptions - The options for the underlying http request.
*/
export function createSpan<T extends OperationOptions>(
operationName: string,
Expand Down
33 changes: 14 additions & 19 deletions sdk/core/abort-controller/src/AbortController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { AbortSignal, abortSignal, AbortSignalLike } from "./AbortSignal";
* error matches `"AbortError"`.
*
* @example
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note for another time, not for this PR: Check if @example tag is still valid in the latest typedoc tool. I recall that the docs at docs.microsoft.com/javascript/api simply ignore this tag and anything that comes after it based on our experience. cc @HarshaNalluru and @willmtemple for confirmation

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TypeDoc plans to have full support for TSDoc in the upcoming year. Until then, we can perhaps use the following plugin: https://github.com/ardalanamini/typedoc-plugin-example-tag.

* ```ts
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Lets make this js. We generally want all our code snippets to be in JavaScript, not TypeScript

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. This is for just highlighting though and I think color scheme should be the same for both languages.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the color scheme would be same. My reason to call this out was to avoid someone in the future looking at this and trying to add TypeScript code

* const controller = new AbortController();
* controller.abort();
* try {
Expand All @@ -18,6 +19,7 @@ import { AbortSignal, abortSignal, AbortSignalLike } from "./AbortSignal";
* // handle abort error here.
* }
* }
* ```
*/
export class AbortError extends Error {
constructor(message?: string) {
Expand All @@ -31,44 +33,44 @@ export class AbortError extends Error {
* that an asynchronous operation should be aborted.
*
* @example
* // Abort an operation when another event fires
* Abort an operation when another event fires
* ```ts
* const controller = new AbortController();
* const signal = controller.signal;
* doAsyncWork(signal);
* button.addEventListener('click', () => controller.abort());
* ```
*
* @example
* // Share aborter cross multiple operations in 30s
* Share aborter cross multiple operations in 30s
* ```ts
* // Upload the same data to 2 different data centers at the same time,
* // abort another when any of them is finished
* const controller = AbortController.withTimeout(30 * 1000);
* doAsyncWork(controller.signal).then(controller.abort);
* doAsyncWork(controller.signal).then(controller.abort);
*```
*
* @example
* // Cascaded aborting
* Cascaded aborting
* ```ts
* // All operations can't take more than 30 seconds
* const aborter = Aborter.timeout(30 * 1000);
*
* // Following 2 operations can't take more than 25 seconds
* await doAsyncWork(aborter.withTimeout(25 * 1000));
* await doAsyncWork(aborter.withTimeout(25 * 1000));
*
* @export
* @class AbortController
* @implements {AbortSignalLike}
* ```
*/
export class AbortController {
private _signal: AbortSignal;

/**
* @param {AbortSignalLike[]} [parentSignals] The AbortSignals that will signal aborted on the AbortSignal associated with this controller.
* @constructor
* @param parentSignals - The AbortSignals that will signal aborted on the AbortSignal associated with this controller.
*/
constructor(parentSignals?: AbortSignalLike[]);
/**
* @param {...AbortSignalLike} parentSignals The AbortSignals that will signal aborted on the AbortSignal associated with this controller.
* @constructor
* @param parentSignals - The AbortSignals that will signal aborted on the AbortSignal associated with this controller.
*/
constructor(...parentSignals: AbortSignalLike[]);
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
Expand Down Expand Up @@ -102,8 +104,6 @@ export class AbortController {
* when the abort method is called on this controller.
*
* @readonly
* @type {AbortSignal}
* @memberof AbortController
*/
public get signal(): AbortSignal {
return this._signal;
Expand All @@ -112,19 +112,14 @@ export class AbortController {
/**
* Signal that any operations passed this controller's associated abort signal
* to cancel any remaining work and throw an `AbortError`.
*
* @memberof AbortController
*/
abort(): void {
abortSignal(this._signal);
}

/**
* Creates a new AbortSignal instance that will abort after the provided ms.
*
* @static
* @params {number} ms Elapsed time in milliseconds to trigger an abort.
* @returns {AbortSignal}
* @param ms - Elapsed time in milliseconds to trigger an abort.
*/
public static timeout(ms: number): AbortSignal {
const signal = new AbortSignal();
Expand Down
25 changes: 7 additions & 18 deletions sdk/core/abort-controller/src/AbortSignal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,10 @@ export interface AbortSignalLike {
* cannot or will not ever be cancelled.
*
* @example
* // Abort without timeout
* Abort without timeout
* ```ts
* await doAsyncWork(AbortSignal.none);
*
* @export
* @class AbortSignal
* @implements {AbortSignalLike}
* ```
*/
export class AbortSignal implements AbortSignalLike {
constructor() {
Expand All @@ -61,8 +59,6 @@ export class AbortSignal implements AbortSignalLike {
* Status of whether aborted or not.
*
* @readonly
* @type {boolean}
* @memberof AbortSignal
*/
public get aborted(): boolean {
if (!abortedMap.has(this)) {
Expand All @@ -76,27 +72,21 @@ export class AbortSignal implements AbortSignalLike {
* Creates a new AbortSignal instance that will never be aborted.
*
* @readonly
* @static
* @type {AbortSignal}
* @memberof AbortSignal
*/
public static get none(): AbortSignal {
return new AbortSignal();
}

/**
* onabort event listener.
*
* @memberof AbortSignal
*/
public onabort: ((ev?: Event) => any) | null = null;

/**
* Added new "abort" event listener, only support "abort" event.
*
* @param {"abort"} _type Only support "abort" event
* @param {(this: AbortSignalLike, ev: any) => any} listener
* @memberof AbortSignal
* @param _type - Only support "abort" event
* @param listener - The listener to be added
*/
public addEventListener(
// tslint:disable-next-line:variable-name
Expand All @@ -114,9 +104,8 @@ export class AbortSignal implements AbortSignalLike {
/**
* Remove "abort" event listener, only support "abort" event.
*
* @param {"abort"} _type Only support "abort" event
* @param {(this: AbortSignalLike, ev: any) => any} listener
* @memberof AbortSignal
* @param _type - Only support "abort" event
* @param listener - The listener to be removed
*/
public removeEventListener(
// tslint:disable-next-line:variable-name
Expand Down
4 changes: 2 additions & 2 deletions sdk/core/core-auth/src/azureKeyCredential.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class AzureKeyCredential implements KeyCredential {
* Create an instance of an AzureKeyCredential for use
* with a service client.
*
* @param key the initial value of the key to use in authentication
* @param key - The initial value of the key to use in authentication
*/
constructor(key: string) {
if (!key) {
Expand All @@ -45,7 +45,7 @@ export class AzureKeyCredential implements KeyCredential {
* Updates will take effect upon the next request after
* updating the key value.
*
* @param newKey the new key value to be used
* @param newKey - The new key value to be used
*/
public update(newKey: string): void {
this._key = newKey;
Expand Down
Loading