Skip to content

chore(docs): add invisible unicode char to decorator docstrings #1755

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
34 changes: 17 additions & 17 deletions packages/idempotency/src/idempotencyDecorator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import { makeIdempotent } from './makeIdempotent';
* } from '@aws-lambda-powertools/idempotency';
* import type { LambdaInterface } from '@aws-lambda-powertools/commons';
*
* class MyLambdaFunction implements LambdaInterface{
* @idempotent({ persistenceStore: new DynamoDBPersistenceLayer() })
* async handler(event: any, context: any) {
* class MyLambdaFunction implements LambdaInterface {
* @idempotent({ persistenceStore: new DynamoDBPersistenceLayer() })
* async handler(event: unknown, _context: unknown) {
* return "Hello World";
* }
* }
Expand All @@ -28,23 +28,23 @@ import { makeIdempotent } from './makeIdempotent';
* @example
* ```ts
* import {
* DynamoDBPersistenceLayer,
* idempotentFunction
* } from '@aws-lambda-powertools/idempotency';
* import type { LambdaInterface } from '@aws-lambda-powertools/commons';
*
* class MyClass implements LambdaInterface {
* DynamoDBPersistenceLayer,
* idempotentFunction
* } from '@aws-lambda-powertools/idempotency';
* import type { LambdaInterface } from '@aws-lambda-powertools/commons';
*
* public async handler(_event: any, _context: any) {
* for(const record of _event.records){
* await this.process(record);
* }
* }
* class MyClass implements LambdaInterface {
* public async handler(event: unknown, _context: unknown) {
* for(const record of event.records){
* await this.process(record);
* }
* }
*
* @idemptent({ persistenceStore: new DynamoDBPersistenceLayer() })
* public async process(record: Record<stiring, unknown) {
* @idemptent({ persistenceStore: new DynamoDBPersistenceLayer() })
* public async process(record: Record<stiring, unknown>) {
* // do some processing
* }
* }
* }
* ```
* @see {@link DynamoDBPersistenceLayer}
* @see https://www.typescriptlang.org/docs/handbook/decorators.html
Expand Down
13 changes: 5 additions & 8 deletions packages/logger/src/Logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ import type {
*
* const logger = new Logger();
*
* const lambdaHandler = async (_event: any, _context: any) => {
* const lambdaHandler = async (_event: unknown, _context: unknown) => {
* logger.info('This is an INFO log with some context');
* };
*
Expand All @@ -77,12 +77,9 @@ import type {
* const logger = new Logger();
*
* class Lambda implements LambdaInterface {
*
* // FYI: Decorator might not render properly in VSCode mouse over due to https://github.com/microsoft/TypeScript/issues/47679 and might show as *@logger* instead of `@logger.injectLambdaContext`
*
* // Decorate your handler class method
* @logger.injectLambdaContext()
* public async handler(_event: any, _context: any): Promise<void> {
* @logger.injectLambdaContext()
* public async handler(_event: unknown, _context: unknown): Promise<void> {
* logger.info('This is an INFO log with some context');
* }
* }
Expand Down Expand Up @@ -358,8 +355,8 @@ class Logger extends Utility implements ClassThatLogs {
*
* class Lambda implements LambdaInterface {
* // Decorate your handler class method
* @logger.injectLambdaContext()
* public async handler(_event: any, _context: any): Promise<void> {
* @logger.injectLambdaContext()
* public async handler(_event: unknown, _context: unknown): Promise<void> {
* logger.info('This is an INFO log with some context');
* }
* }
Expand Down
20 changes: 9 additions & 11 deletions packages/metrics/src/Metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ import {
*
* const metrics = new Metrics({ namespace: 'serverlessAirline', serviceName: 'orders' });
*
* const lambdaHandler = async (_event: any, _context: any) => {
* const lambdaHandler = async (_event: unknown, _context: unknown) => {
* ...
* };
*
Expand All @@ -77,11 +77,9 @@ import {
* const metrics = new Metrics({ namespace: 'serverlessAirline', serviceName: 'orders' });
*
* class Lambda implements LambdaInterface {
*
* // FYI: Decorator might not render properly in VSCode mouse over due to https://github.com/microsoft/TypeScript/issues/47679 and might show as *@metrics* instead of `@metrics.logMetrics`
*
* @metrics.logMetrics({ captureColdStartMetric: true, throwOnEmptyMetrics: true })
* public handler(_event: any, _context: any): Promise<void> {
* // Decorate your handler with the logMetrics decorator
* ⁣@metrics.logMetrics({ captureColdStartMetric: true, throwOnEmptyMetrics: true })
* public handler(_event: unknown, _context: unknown): Promise<void> {
* // ...
* metrics.addMetric('test-metric', MetricUnits.Count, 10);
* // ...
Expand All @@ -103,7 +101,7 @@ import {
*
* const metrics = new Metrics({ namespace: 'serverlessAirline', serviceName: 'orders' });
*
* export const handler = async (_event: any, _context: any): Promise<void> => {
* export const handler = async (_event: unknown, __context: unknown): Promise<void> => {
* metrics.captureColdStartMetric();
* metrics.addMetric('test-metric', MetricUnits.Count, 10);
* metrics.publishStoredMetrics();
Expand Down Expand Up @@ -243,7 +241,7 @@ class Metrics extends Utility implements MetricsInterface {
*
* const metrics = new Metrics({ namespace: 'serverlessAirline', serviceName: 'orders' });
*
* export const handler = async (event: any, _context: any): Promise<void> => {
* export const handler = async (_event: unknown, __context: unknown): Promise<void> => {
* metrics.captureColdStartMetric();
* };
* ```
Expand Down Expand Up @@ -305,7 +303,7 @@ class Metrics extends Utility implements MetricsInterface {
* class Lambda implements LambdaInterface {
*
* @metrics.logMetrics({ captureColdStartMetric: true })
* public handler(_event: any, _context: any): Promise<void> {
* public handler(_event: unknown, __context: unknown): Promise<void> {
* // ...
* }
* }
Expand Down Expand Up @@ -373,7 +371,7 @@ class Metrics extends Utility implements MetricsInterface {
*
* const metrics = new Metrics({ namespace: 'serverlessAirline', serviceName: 'orders' }); // Sets metric namespace, and service as a metric dimension
*
* export const handler = async (_event: any, _context: any): Promise<void> => {
* export const handler = async (_event: unknown, __context: unknown): Promise<void> => {
* metrics.addMetric('test-metric', MetricUnits.Count, 10);
* metrics.publishStoredMetrics();
* };
Expand Down Expand Up @@ -523,7 +521,7 @@ class Metrics extends Utility implements MetricsInterface {
*
* const metrics = new Metrics({ namespace: 'serverlessAirline', serviceName:'orders' });
*
* export const handler = async (_event: any, _context: any): Promise<void> => {
* export const handler = async (_event: unknown, __context: unknown): Promise<void> => {
* metrics.throwOnEmptyMetrics();
* metrics.publishStoredMetrics(); // will throw since no metrics added.
* };
Expand Down
40 changes: 19 additions & 21 deletions packages/tracer/src/Tracer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ import { type Segment, Subsegment } from 'aws-xray-sdk-core';
*
* const tracer = new Tracer({ serviceName: 'serverlessAirline' });
*
* const lambdaHandler = async (_event: any, _context: any) => {
* const lambdaHandler = async (_event: unknown, _context: unknown) => {
* ...
* };
*
Expand All @@ -73,11 +73,9 @@ import { type Segment, Subsegment } from 'aws-xray-sdk-core';
*
* const tracer = new Tracer({ serviceName: 'serverlessAirline' });
*
* // FYI: Decorator might not render properly in VSCode mouse over due to https://github.com/microsoft/TypeScript/issues/47679 and might show as *@tracer* instead of `@tracer.captureLambdaHandler`
*
* class Lambda implements LambdaInterface {
* @tracer.captureLambdaHandler()
* public handler(event: any, context: any) {
* @tracer.captureLambdaHandler()
* public handler(_event: unknown, _context: unknown) {
* ...
* }
* }
Expand All @@ -96,7 +94,7 @@ import { type Segment, Subsegment } from 'aws-xray-sdk-core';
*
* const tracer = new Tracer({ serviceName: 'serverlessAirline' });
*
* export const handler = async (_event: any, context: any) => {
* export const handler = async (_event: unknown, _context: unknown) => {
* const segment = tracer.getSegment(); // This is the facade segment (the one that is created by AWS Lambda)
* // Create subsegment for the function & set it as active
* const subsegment = segment.addNewSubsegment(`## ${process.env._HANDLER}`);
Expand Down Expand Up @@ -246,7 +244,7 @@ class Tracer extends Utility implements TracerInterface {
* const tracer = new Tracer({ serviceName: 'serverlessAirline' });
* const AWS = tracer.captureAWS(require('aws-sdk'));
*
* export const handler = async (_event: any, _context: any) => {
* export const handler = async (_event: unknown, _context: unknown) => {
* ...
* }
* ```
Expand Down Expand Up @@ -275,7 +273,7 @@ class Tracer extends Utility implements TracerInterface {
* const tracer = new Tracer({ serviceName: 'serverlessAirline' });
* const s3 = tracer.captureAWSClient(new S3({ apiVersion: '2006-03-01' }));
*
* export const handler = async (_event: any, _context: any) => {
* export const handler = async (_event: unknown, _context: unknown) => {
* ...
* }
* ```
Expand Down Expand Up @@ -318,7 +316,7 @@ class Tracer extends Utility implements TracerInterface {
* const client = new S3Client({});
* tracer.captureAWSv3Client(client);
*
* export const handler = async (_event: any, _context: any) => {
* export const handler = async (_event: unknown, _context: unknown) => {
* ...
* }
* ```
Expand Down Expand Up @@ -352,9 +350,9 @@ class Tracer extends Utility implements TracerInterface {
* const tracer = new Tracer({ serviceName: 'serverlessAirline' });
*
* class Lambda implements LambdaInterface {
* @tracer.captureLambdaHandler()
* public handler(event: any, context: any) {
* ...
* @tracer.captureLambdaHandler()
* public handler(_event: unknown, _context: unknown) {
* // ...
* }
* }
*
Expand Down Expand Up @@ -445,13 +443,13 @@ class Tracer extends Utility implements TracerInterface {
* const tracer = new Tracer({ serviceName: 'serverlessAirline' });
*
* class Lambda implements LambdaInterface {
* @tracer.captureMethod()
* public myMethod(param: any) {
* ...
* @tracer.captureMethod()
* public myMethod(param: string) {
* // ...
* }
*
* public handler(event: any, context: any) {
* ...
* public handler(_event: unknown, _context: unknown) {
* this.myMethod('foo');
* }
* }
*
Expand Down Expand Up @@ -567,7 +565,7 @@ class Tracer extends Utility implements TracerInterface {
*
* const tracer = new Tracer({ serviceName: 'serverlessAirline' });
*
* export const handler = async (_event: any, _context: any) => {
* export const handler = async (_event: unknown, _context: unknown) => {
* const currentSegment = tracer.getSegment();
* ... // Do something with segment
* }
Expand Down Expand Up @@ -627,7 +625,7 @@ class Tracer extends Utility implements TracerInterface {
*
* const tracer = new Tracer({ serviceName: 'serverlessAirline' });
*
* export const handler = async (_event: any, _context: any) => {
* export const handler = async (_event: unknown, _context: unknown) => {
* tracer.putAnnotation('successfulBooking', true);
* }
* ```
Expand All @@ -652,7 +650,7 @@ class Tracer extends Utility implements TracerInterface {
*
* const tracer = new Tracer({ serviceName: 'serverlessAirline' });
*
* export const handler = async (_event: any, _context: any) => {
* export const handler = async (_event: unknown, _context: unknown) => {
* const res = someLogic();
* tracer.putMetadata('paymentResponse', res);
* }
Expand Down Expand Up @@ -686,7 +684,7 @@ class Tracer extends Utility implements TracerInterface {
*
* const tracer = new Tracer({ serviceName: 'serverlessAirline' });
*
* export const handler = async (_event: any, _context: any) => {
* export const handler = async (_event: unknown, _context: unknown) => {
* const subsegment = new Subsegment('### foo.bar');
* tracer.setSegment(subsegment);
* }
Expand Down