Skip to content

Commit 46ece5d

Browse files
committed
chore(docs): add custom @excludeFromDocs tag to filter generated docs
1 parent bcae57a commit 46ece5d

8 files changed

Lines changed: 87 additions & 23 deletions

File tree

etc/firebase-admin.auth.api.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export interface AllowByDefault {
3131
// @public
3232
export interface AllowByDefaultWrap {
3333
allowByDefault: AllowByDefault;
34-
// @alpha (undocumented)
34+
// (undocumented)
3535
allowlistOnly?: never;
3636
}
3737

@@ -42,7 +42,7 @@ export interface AllowlistOnly {
4242

4343
// @public
4444
export interface AllowlistOnlyWrap {
45-
// @alpha (undocumented)
45+
// (undocumented)
4646
allowByDefault?: never;
4747
allowlistOnly: AllowlistOnly;
4848
}
@@ -196,7 +196,7 @@ export abstract class BaseAuth {
196196
setCustomUserClaims(uid: string, customUserClaims: object | null): Promise<void>;
197197
updateProviderConfig(providerId: string, updatedConfig: UpdateAuthProviderRequest): Promise<AuthProviderConfig>;
198198
updateUser(uid: string, properties: UpdateRequest): Promise<UserRecord>;
199-
// @alpha (undocumented)
199+
// (undocumented)
200200
_verifyAuthBlockingToken(token: string, audience?: string): Promise<DecodedAuthBlockingToken>;
201201
verifyIdToken(idToken: string, checkRevoked?: boolean): Promise<DecodedIdToken>;
202202
verifySessionCookie(sessionCookie: string, checkRevoked?: boolean): Promise<DecodedIdToken>;
@@ -257,7 +257,7 @@ export interface CustomStrengthOptionsConfig {
257257
requireUppercase?: boolean;
258258
}
259259

260-
// @alpha (undocumented)
260+
// @public (undocumented)
261261
export interface DecodedAuthBlockingToken {
262262
// (undocumented)
263263
[key: string]: any;

etc/firebase-admin.functions.api.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ import { Agent } from 'http';
88

99
// @public
1010
export interface AbsoluteDelivery {
11-
// @alpha (undocumented)
11+
// (undocumented)
1212
scheduleDelaySeconds?: never;
1313
scheduleTime?: Date;
1414
}
1515

1616
// @public
1717
export interface DelayDelivery {
1818
scheduleDelaySeconds?: number;
19-
// @alpha (undocumented)
19+
// (undocumented)
2020
scheduleTime?: never;
2121
}
2222

generate-reports.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,40 @@ async function generateReportForEntryPoint(entryPoint, filePath) {
7373
}
7474

7575
console.error(`API Extractor completed successfully`);
76+
77+
// Strip @excludeFromDocs APIs from the generated docModel so they aren't documented in reference docs.
78+
const apiJsonPath = path.resolve('temp', `${safeName}.api.json`);
79+
await stripHiddenDocsFromApiJson(apiJsonPath);
7680
} finally {
7781
await fs.unlink(tempConfigFile);
7882
}
7983
}
8084

85+
async function stripHiddenDocsFromApiJson(apiJsonPath) {
86+
if (!await fs.exists(apiJsonPath)) {
87+
return;
88+
}
89+
const content = await fs.readFile(apiJsonPath, 'utf8');
90+
const data = JSON.parse(content);
91+
92+
let removedCount = 0;
93+
function removeHidden(node) {
94+
if (node.members) {
95+
const originalLength = node.members.length;
96+
// Filter out any member whose docComment includes @excludeFromDocs
97+
node.members = node.members.filter(m => !(m.docComment && /@excludeFromDocs\b/.test(m.docComment)));
98+
removedCount += (originalLength - node.members.length);
99+
node.members.forEach(removeHidden);
100+
}
101+
}
102+
103+
removeHidden(data);
104+
if (removedCount > 0) {
105+
console.log(`Removed ${removedCount} @excludeFromDocs items from ${path.basename(apiJsonPath)}`);
106+
await fs.writeFile(apiJsonPath, JSON.stringify(data, null, 2));
107+
}
108+
}
109+
81110
(async () => {
82111
try {
83112
await generateReports();

src/auth/auth-config.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1631,7 +1631,9 @@ export interface AllowByDefaultWrap {
16311631
* Allow every region by default.
16321632
*/
16331633
allowByDefault: AllowByDefault;
1634-
/** @alpha */
1634+
/**
1635+
* @excludeFromDocs
1636+
*/
16351637
allowlistOnly?: never;
16361638
}
16371639

@@ -1644,7 +1646,9 @@ export interface AllowlistOnlyWrap {
16441646
* allowlist.
16451647
*/
16461648
allowlistOnly: AllowlistOnly;
1647-
/** @alpha */
1649+
/**
1650+
* @excludeFromDocs
1651+
*/
16481652
allowByDefault?: never;
16491653
}
16501654

src/auth/base-auth.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1096,7 +1096,9 @@ export abstract class BaseAuth {
10961096
return Promise.reject(new FirebaseAuthError(authClientErrorCode.INVALID_PROVIDER_ID));
10971097
}
10981098

1099-
/** @alpha */
1099+
/**
1100+
* @excludeFromDocs
1101+
*/
11001102
// eslint-disable-next-line @typescript-eslint/naming-convention
11011103
public _verifyAuthBlockingToken(
11021104
token: string,

src/auth/token-verifier.ts

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,9 @@ export interface DecodedIdToken {
177177
[key: string]: any;
178178
}
179179

180-
/** @alpha */
180+
/**
181+
* @excludeFromDocs
182+
*/
181183
export interface DecodedAuthBlockingSharedUserInfo {
182184
uid: string;
183185
display_name?: string;
@@ -186,18 +188,24 @@ export interface DecodedAuthBlockingSharedUserInfo {
186188
phone_number?: string;
187189
}
188190

189-
/** @alpha */
191+
/**
192+
* @excludeFromDocs
193+
*/
190194
export interface DecodedAuthBlockingMetadata {
191195
creation_time?: number;
192196
last_sign_in_time?: number;
193197
}
194198

195-
/** @alpha */
199+
/**
200+
* @excludeFromDocs
201+
*/
196202
export interface DecodedAuthBlockingUserInfo extends DecodedAuthBlockingSharedUserInfo {
197203
provider_id: string;
198204
}
199205

200-
/** @alpha */
206+
/**
207+
* @excludeFromDocs
208+
*/
201209
export interface DecodedAuthBlockingMfaInfo {
202210
uid: string;
203211
display_name?: string;
@@ -206,12 +214,16 @@ export interface DecodedAuthBlockingMfaInfo {
206214
factor_id?: string;
207215
}
208216

209-
/** @alpha */
217+
/**
218+
* @excludeFromDocs
219+
*/
210220
export interface DecodedAuthBlockingEnrolledFactors {
211221
enrolled_factors?: DecodedAuthBlockingMfaInfo[];
212222
}
213223

214-
/** @alpha */
224+
/**
225+
* @excludeFromDocs
226+
*/
215227
export interface DecodedAuthBlockingUserRecord extends DecodedAuthBlockingSharedUserInfo {
216228
email_verified?: boolean;
217229
disabled?: boolean;
@@ -226,7 +238,9 @@ export interface DecodedAuthBlockingUserRecord extends DecodedAuthBlockingShared
226238
[key: string]: any;
227239
}
228240

229-
/** @alpha */
241+
/**
242+
* @excludeFromDocs
243+
*/
230244
export interface DecodedAuthBlockingToken {
231245
aud: string;
232246
exp: number;
@@ -333,7 +347,7 @@ export class FirebaseTokenVerifier {
333347
private readonly signatureVerifier: SignatureVerifier;
334348

335349
constructor(clientCertUrl: string, private issuer: string, private tokenInfo: FirebaseTokenInfo,
336-
private readonly app: App) {
350+
private readonly app: App) {
337351

338352
if (!validator.isURL(clientCertUrl)) {
339353
throw new FirebaseAuthError(
@@ -410,7 +424,9 @@ export class FirebaseTokenVerifier {
410424
});
411425
}
412426

413-
/** @alpha */
427+
/**
428+
* @excludeFromDocs
429+
*/
414430
// eslint-disable-next-line @typescript-eslint/naming-convention
415431
public _verifyAuthBlockingToken(
416432
jwtToken: string,
@@ -448,7 +464,7 @@ export class FirebaseTokenVerifier {
448464
);
449465
}
450466
return Promise.resolve(projectId);
451-
})
467+
});
452468
}
453469

454470
private decodeAndVerify(
@@ -521,10 +537,10 @@ export class FirebaseTokenVerifier {
521537
'"' + header.alg + '".' + verifyJwtTokenDocsMessage;
522538
} else if (typeof audience !== 'undefined' && !(payload.aud as string).includes(audience)) {
523539
errorMessage = `${this.tokenInfo.jwtName} has incorrect "aud" (audience) claim. Expected "` +
524-
audience + '" but got "' + payload.aud + '".' + verifyJwtTokenDocsMessage;
540+
audience + '" but got "' + payload.aud + '".' + verifyJwtTokenDocsMessage;
525541
} else if (typeof audience === 'undefined' && payload.aud !== projectId) {
526542
errorMessage = `${this.tokenInfo.jwtName} has incorrect "aud" (audience) claim. Expected "` +
527-
projectId + '" but got "' + payload.aud + '".' + projectIdMatchMessage +
543+
projectId + '" but got "' + payload.aud + '".' + projectIdMatchMessage +
528544
verifyJwtTokenDocsMessage;
529545
} else if (payload.iss !== this.issuer + projectId) {
530546
errorMessage = `${this.tokenInfo.jwtName} has incorrect "iss" (issuer) claim. Expected ` +

src/functions/functions-api.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ export interface DelayDelivery {
2424
* This delay is added to the current time.
2525
*/
2626
scheduleDelaySeconds?: number;
27-
/** @alpha */
27+
/**
28+
* @excludeFromDocs
29+
*/
2830
scheduleTime?: never;
2931
}
3032

@@ -36,7 +38,9 @@ export interface AbsoluteDelivery {
3638
* The time when the task is scheduled to be attempted or retried.
3739
*/
3840
scheduleTime?: Date;
39-
/** @alpha */
41+
/**
42+
* @excludeFromDocs
43+
*/
4044
scheduleDelaySeconds?: never;
4145
}
4246

tsdoc.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json",
3+
"tagDefinitions": [
4+
{
5+
"tagName": "@excludeFromDocs",
6+
"syntaxKind": "modifier"
7+
}
8+
]
9+
}

0 commit comments

Comments
 (0)